forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '98b5f85f10a3af50a54fcd79e09fc9fd88f774fa' into glitch-s…
…oc/merge-upstream
- Loading branch information
Showing
9 changed files
with
125 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,12 +137,49 @@ | |
|
||
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: '[email protected]', 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: '[email protected]') | ||
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: '[email protected]', 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters