|
|
|
@ -137,12 +137,49 @@ RSpec.describe Auth::RegistrationsController do
|
|
|
|
|
|
|
|
|
|
context 'when user has an email address requiring approval' do
|
|
|
|
|
subject do
|
|
|
|
|
request.headers['Accept-Language'] = accept_language
|
|
|
|
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
Setting.registrations_mode = 'open'
|
|
|
|
|
Fabricate(:email_domain_block, allow_with_approval: true, domain: 'example.com')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'creates unapproved user and redirects to setup' do
|
|
|
|
|
subject
|
|
|
|
|
expect(response).to redirect_to auth_setup_path
|
|
|
|
|
|
|
|
|
|
user = User.find_by(email: 'test@example.com')
|
|
|
|
|
expect(user).to_not be_nil
|
|
|
|
|
expect(user.locale).to eq(accept_language)
|
|
|
|
|
expect(user.approved).to be(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when user has an email address requiring approval through a MX record' do
|
|
|
|
|
subject do
|
|
|
|
|
request.headers['Accept-Language'] = accept_language
|
|
|
|
|
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
Setting.registrations_mode = 'open'
|
|
|
|
|
Fabricate(:email_domain_block, allow_with_approval: true, domain: 'mail.example.com')
|
|
|
|
|
allow(User).to receive(:skip_mx_check?).and_return(false)
|
|
|
|
|
|
|
|
|
|
resolver = instance_double(Resolv::DNS, :timeouts= => nil)
|
|
|
|
|
|
|
|
|
|
allow(resolver).to receive(:getresources)
|
|
|
|
|
.with('example.com', Resolv::DNS::Resource::IN::MX)
|
|
|
|
|
.and_return([instance_double(Resolv::DNS::Resource::MX, exchange: 'mail.example.com')])
|
|
|
|
|
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::A).and_return([])
|
|
|
|
|
allow(resolver).to receive(:getresources).with('example.com', Resolv::DNS::Resource::IN::AAAA).and_return([])
|
|
|
|
|
allow(resolver).to receive(:getresources).with('mail.example.com', Resolv::DNS::Resource::IN::A).and_return([instance_double(Resolv::DNS::Resource::IN::A, address: '2.3.4.5')])
|
|
|
|
|
allow(resolver).to receive(:getresources).with('mail.example.com', Resolv::DNS::Resource::IN::AAAA).and_return([instance_double(Resolv::DNS::Resource::IN::AAAA, address: 'fd00::2')])
|
|
|
|
|
allow(Resolv::DNS).to receive(:open).and_yield(resolver)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'creates unapproved user and redirects to setup' do
|
|
|
|
|
subject
|
|
|
|
|
expect(response).to redirect_to auth_setup_path
|
|
|
|
|