summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorazul <azul@leap.se>2015-10-13 15:20:26 +0000
committerazul <azul@leap.se>2015-10-13 15:20:26 +0000
commitfd55d71cd1cbadcc5378601c0c9dfa6292bd4725 (patch)
treec36e96d7deb8191f7bc04c2d509e9f70c6de6754 /test/unit
parent70073b1ac48f96d3e375630fb7f3904351e0f696 (diff)
parentcb89699283aeb1ef4195a5c99d0319f3232f5db7 (diff)
Merge pull request #201 from Alster-Hamburgers/multi-invite
Allow multi-use invite codes
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/invite_code_test.rb42
-rw-r--r--test/unit/invite_code_validator_test.rb56
2 files changed, 56 insertions, 42 deletions
diff --git a/test/unit/invite_code_test.rb b/test/unit/invite_code_test.rb
index b17d1bc..fd93f2f 100644
--- a/test/unit/invite_code_test.rb
+++ b/test/unit/invite_code_test.rb
@@ -21,47 +21,5 @@ class InviteCodeTest < ActiveSupport::TestCase
end
- test "Invite count >0 is not accepted for new account signup" do
- validator = InviteCodeValidator.new nil
-
- user_code = InviteCode.new
- user_code.invite_count = 1
- user_code.save
-
- user = FactoryGirl.build :user
- user.invite_code = user_code.invite_code
-
- validator.validate(user)
-
- assert_equal ["This code has already been used"], user.errors[:invite_code]
-
- end
-
- test "Invite count 0 is accepted for new account signup" do
- validator = InviteCodeValidator.new nil
-
- user_code = InviteCode.create
-
- user = FactoryGirl.build :user
- user.invite_code = user_code.invite_code
-
- validator.validate(user)
-
- assert_equal [], user.errors[:invite_code]
- end
-
- test "There is an error message if the invite code does not exist" do
- validator = InviteCodeValidator.new nil
-
- user = FactoryGirl.build :user
- user.invite_code = "wrongcode"
-
- validator.validate(user)
-
- assert_equal ["This is not a valid code"], user.errors[:invite_code]
-
- end
-
-
end
diff --git a/test/unit/invite_code_validator_test.rb b/test/unit/invite_code_validator_test.rb
index ee8f1b3..62eeae6 100644
--- a/test/unit/invite_code_validator_test.rb
+++ b/test/unit/invite_code_validator_test.rb
@@ -27,4 +27,60 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase
assert_equal errors, invalid_user.errors.messages
end
end
+
+
+ test "Invite count >= invite max uses is not accepted for new account signup" do
+ validator = InviteCodeValidator.new nil
+
+ user_code = InviteCode.new
+ user_code.invite_count = 1
+ user_code.save
+
+ user = FactoryGirl.build :user
+ user.invite_code = user_code.invite_code
+
+ validator.validate(user)
+
+ assert_equal ["This code has already been used"], user.errors[:invite_code]
+
+ end
+
+ test "Invite count < invite max uses is accepted for new account signup" do
+ validator = InviteCodeValidator.new nil
+
+ user_code = InviteCode.create
+ user_code.save
+
+ user = FactoryGirl.build :user
+ user.invite_code = user_code.invite_code
+
+ validator.validate(user)
+
+ assert_equal [], user.errors[:invite_code]
+ end
+
+ test "Invite count 0 is accepted for new account signup" do
+ validator = InviteCodeValidator.new nil
+
+ user_code = InviteCode.create
+
+ user = FactoryGirl.build :user
+ user.invite_code = user_code.invite_code
+
+ validator.validate(user)
+
+ assert_equal [], user.errors[:invite_code]
+ end
+
+ test "There is an error message if the invite code does not exist" do
+ validator = InviteCodeValidator.new nil
+
+ user = FactoryGirl.build :user
+ user.invite_code = "wrongcode"
+
+ validator.validate(user)
+
+ assert_equal ["This is not a valid code"], user.errors[:invite_code]
+ end
+
end \ No newline at end of file