FEATURE: add site setting allow_new_registrations which can be used to block all new account registrations

This commit is contained in:
Neil Lalonde
2014-07-14 15:42:22 -04:00
parent ac3827f700
commit 766196af87
8 changed files with 57 additions and 1 deletions
+17
View File
@@ -269,6 +269,7 @@ describe UsersController do
describe '#create' do
before do
SiteSetting.stubs(:allow_new_registrations).returns(true)
@user = Fabricate.build(:user)
@user.password = "strongpassword"
DiscourseHub.stubs(:register_username).returns([true, nil])
@@ -291,6 +292,14 @@ describe UsersController do
expect(response.status).to eq(500)
end
it 'returns an error when new registrations are disabled' do
SiteSetting.stubs(:allow_new_registrations).returns(false)
post_user
json = JSON.parse(response.body)
json['success'].should be_false
json['message'].should be_present
end
it 'creates a user correctly' do
Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup))
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never
@@ -355,6 +364,14 @@ describe UsersController do
expect(JSON.parse(response.body)['active']).to be_true
end
it 'returns 500 status when new registrations are disabled' do
SiteSetting.stubs(:allow_new_registrations).returns(false)
post_user
json = JSON.parse(response.body)
json['success'].should be_false
json['message'].should be_present
end
context 'authentication records for' do
before do