summaryrefslogtreecommitdiff
path: root/test/unit/account_test.rb
diff options
context:
space:
mode:
authorAya Jaff <ayajaff@hotmail.com>2015-09-04 14:01:49 +0200
committerankonym <ankonym@gmail.com>2015-09-28 15:12:46 +0200
commit2ce3d14cfa77f985b6849dd4431db65e9abd0226 (patch)
tree14f59ede560a51ee639407bbda90f86440e48920 /test/unit/account_test.rb
parentd13e2d841a632385031a0b98a15773d8b90d05e9 (diff)
Fixed the signup bug that wrongly consumes the invite code.
Diffstat (limited to 'test/unit/account_test.rb')
-rw-r--r--test/unit/account_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb
index 8c66853..0882c43 100644
--- a/test/unit/account_test.rb
+++ b/test/unit/account_test.rb
@@ -49,4 +49,24 @@ class AccountTest < ActiveSupport::TestCase
user.account.destroy
end
+ test "Invite code count goes up by 1 when the invite code is entered" do
+
+ user = Account.create(FactoryGirl.attributes_for(:user, :invite_code => @testcode.invite_code))
+ user_code = InviteCode.find_by_invite_code user.invite_code
+ user_code.save
+ user.save
+ assert user.persisted?
+ assert_equal 1, user_code.invite_count
+
+ end
+
+ test "Invite code stays zero when invite code is not used" do
+ #user = Account.create(FactoryGirl.attributes_for(:user, :invite_code => @testcode.invite_code))
+ invalid_user = FactoryGirl.build(:user, :invite_code => @testcode.invite_code)
+ invalid_user.save
+ user_code = InviteCode.find_by_invite_code invalid_user.invite_code
+ user_code.save
+
+ assert_equal 0, user_code.invite_count
+ end
end