summaryrefslogtreecommitdiff
path: root/test/unit/invite_code_test.rb
diff options
context:
space:
mode:
authorankonym <ankonym@gmail.com>2015-08-25 14:11:00 +0200
committerankonym <ankonym@gmail.com>2015-09-28 15:12:45 +0200
commit45c3fadd930a474951bd918a50e1ea2b00af75c7 (patch)
tree3439fc94cc8e6533a92d06a2fd751a3804e71050 /test/unit/invite_code_test.rb
parent5f9aec72f124a971b765c14052363f3ce1e16c65 (diff)
Make sure codes can only be used once, fix validations
We introduced a count on invite codes to make sure that (at the moment) codes can only be used once. (The code will also allow multi-use codes in the future.) Also, some of our validations weren't validating against the correct data, which is now fixed.
Diffstat (limited to 'test/unit/invite_code_test.rb')
-rw-r--r--test/unit/invite_code_test.rb33
1 files changed, 30 insertions, 3 deletions
diff --git a/test/unit/invite_code_test.rb b/test/unit/invite_code_test.rb
index 2684f8e..b6044f4 100644
--- a/test/unit/invite_code_test.rb
+++ b/test/unit/invite_code_test.rb
@@ -10,12 +10,39 @@ class InviteCodeTest < ActiveSupport::TestCase
test "the invite code can be read from couch db correctly" do
code1 = InviteCode.new
code1.save
-
code2 = InviteCode.find_by__id code1.id
-
assert_equal code1.invite_code, code2.invite_code
+ end
+ test "the invite code count gets set to 0 upon creation" do
+ code1 = InviteCode.new
+ code1.save
+ assert_equal code1.invite_count, 0
end
+ # TODO: does the count go up when code gets entered?
+ test "Invite code count goes up by 1 when the invite code is entered" do
+
+ validator = InviteCodeValidator.new nil
+
+ user = FactoryGirl.build :user
+ user_code = InviteCode.new
+ user_code.save
+ user.invite_code = user_code.invite_code
+
+
+ validator.validate(user)
+
+ user_code.reload
+ assert_equal 1, user_code.invite_count
+
+ end
+#
+#
+# # TODO: count >0 is not accepted for signup
+ # test "Invite count >0 is not accepted for new account signup" do
+
+ # end
+
+end
-end \ No newline at end of file