mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Compare commits
2 Commits
b78d408507
...
037ac20121
Author | SHA1 | Date | |
---|---|---|---|
![]() |
037ac20121 | ||
![]() |
fae716002d |
|
@ -137,6 +137,8 @@ class User < ApplicationRecord
|
|||
attribute :external, :boolean, default: false
|
||||
attribute :bypass_registration_checks, :boolean, default: false
|
||||
|
||||
class_attribute :skip_mx_check, default: Rails.env.local?
|
||||
|
||||
def self.those_who_can(*any_of_privileges)
|
||||
matching_role_ids = UserRole.that_can(*any_of_privileges).map(&:id)
|
||||
|
||||
|
@ -147,10 +149,6 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def self.skip_mx_check?
|
||||
Rails.env.local?
|
||||
end
|
||||
|
||||
def date_of_birth=(hash_or_string)
|
||||
@date_of_birth = begin
|
||||
if hash_or_string.is_a?(Hash)
|
||||
|
|
|
@ -228,7 +228,7 @@ RSpec.describe Auth::RegistrationsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when user has an email address requiring approval through a MX record' do
|
||||
context 'when user has an email address requiring approval through a MX record', :enable_mx_checks 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' } }
|
||||
|
@ -237,7 +237,6 @@ RSpec.describe Auth::RegistrationsController do
|
|||
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)
|
||||
configure_mx(domain: 'example.com', exchange: 'mail.example.com')
|
||||
end
|
||||
|
||||
|
|
|
@ -139,6 +139,12 @@ RSpec.configure do |config|
|
|||
example.run
|
||||
end
|
||||
|
||||
config.around(:each, :enable_mx_checks) do |example|
|
||||
User.skip_mx_check = false
|
||||
example.run
|
||||
User.skip_mx_check = true
|
||||
end
|
||||
|
||||
config.around(:each, type: :search) do |example|
|
||||
Chewy.settings[:enabled] = true
|
||||
example.run
|
||||
|
|
|
@ -48,11 +48,10 @@ RSpec.describe AppSignUpService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the email address requires approval through MX records' do
|
||||
context 'when the email address requires approval through MX records', :enable_mx_checks do
|
||||
before do
|
||||
Setting.registrations_mode = 'open'
|
||||
Fabricate(:email_domain_block, allow_with_approval: true, domain: 'smtp.email.com')
|
||||
allow(User).to receive(:skip_mx_check?).and_return(false)
|
||||
configure_mx(domain: 'email.com', exchange: 'smtp.email.com')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user