summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/users_controller_test.rb1
-rw-r--r--test/support/browser_integration_test.rb1
-rw-r--r--test/unit/invite_code_test.rb42
-rw-r--r--test/unit/invite_code_validator_test.rb56
4 files changed, 57 insertions, 43 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 7d1745c..70f483e 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -158,6 +158,7 @@ class UsersControllerTest < ActionController::TestCase
login :is_admin? => true
+ @request.env['HTTP_REFERER'] = 'http://test.com/sessions/new'
post :deactivate, :id => user.id
assert !assigns(:user).enabled?
end
diff --git a/test/support/browser_integration_test.rb b/test/support/browser_integration_test.rb
index 35887cc..950a395 100644
--- a/test/support/browser_integration_test.rb
+++ b/test/support/browser_integration_test.rb
@@ -30,7 +30,6 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 5
-
# Make the Capybara DSL available
include Capybara::DSL
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