mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 13:35:20 -05:00
FEATURE: add site setting allow_new_registrations which can be used to block all new account registrations
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user