summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/v1/users_controller_test.rb3
-rw-r--r--test/unit/account_test.rb17
2 files changed, 19 insertions, 1 deletions
diff --git a/test/functional/v1/users_controller_test.rb b/test/functional/v1/users_controller_test.rb
index 7afbb02..df59c4d 100644
--- a/test/functional/v1/users_controller_test.rb
+++ b/test/functional/v1/users_controller_test.rb
@@ -102,7 +102,8 @@ class V1::UsersControllerTest < ActionController::TestCase
end
test "api monitor auth can create and destroy test users" do
- with_config(allow_registration: false) do
+ # should work even with registration off and/or invites required
+ with_config(allow_registration: false, invite_required: true) do
monitor_auth do
user_attribs = record_attributes_for :test_user
post :create, :user => user_attribs, :format => :json
diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb
index 9680b33..d56541a 100644
--- a/test/unit/account_test.rb
+++ b/test/unit/account_test.rb
@@ -21,6 +21,23 @@ class AccountTest < ActiveSupport::TestCase
user.account.destroy
end
+ test "fail to create account without invite" do
+ with_config invite_required: true do
+ user = Account.create(FactoryGirl.attributes_for(:user))
+ assert !user.valid?, "user should not be valid"
+ assert !user.persisted?, "user should not have been saved"
+ end
+ end
+
+ test "allow invite_required override" do
+ with_config invite_required: true do
+ user = Account.create(FactoryGirl.attributes_for(:user), :invite_required => false)
+ assert user.valid?, "unexpected errors: #{user.errors.inspect}"
+ assert user.persisted?, "user should have been saved"
+ user.account.destroy
+ end
+ end
+
test "create a new account" do
with_config invite_required: false do
user = Account.create(FactoryGirl.attributes_for(:user))