mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Use rspec tag for skip mx check
This commit is contained in:
parent
8d3bca3bb8
commit
fae716002d
|
@ -137,6 +137,8 @@ class User < ApplicationRecord
|
||||||
attribute :external, :boolean, default: false
|
attribute :external, :boolean, default: false
|
||||||
attribute :bypass_registration_checks, :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)
|
def self.those_who_can(*any_of_privileges)
|
||||||
matching_role_ids = UserRole.that_can(*any_of_privileges).map(&:id)
|
matching_role_ids = UserRole.that_can(*any_of_privileges).map(&:id)
|
||||||
|
|
||||||
|
@ -147,10 +149,6 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.skip_mx_check?
|
|
||||||
Rails.env.local?
|
|
||||||
end
|
|
||||||
|
|
||||||
def date_of_birth=(hash_or_string)
|
def date_of_birth=(hash_or_string)
|
||||||
@date_of_birth = begin
|
@date_of_birth = begin
|
||||||
if hash_or_string.is_a?(Hash)
|
if hash_or_string.is_a?(Hash)
|
||||||
|
|
|
@ -228,7 +228,7 @@ RSpec.describe Auth::RegistrationsController do
|
||||||
end
|
end
|
||||||
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
|
subject do
|
||||||
request.headers['Accept-Language'] = accept_language
|
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' } }
|
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
|
before do
|
||||||
Setting.registrations_mode = 'open'
|
Setting.registrations_mode = 'open'
|
||||||
Fabricate(:email_domain_block, allow_with_approval: true, domain: 'mail.example.com')
|
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')
|
configure_mx(domain: 'example.com', exchange: 'mail.example.com')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,12 @@ RSpec.configure do |config|
|
||||||
example.run
|
example.run
|
||||||
end
|
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|
|
config.around(:each, type: :search) do |example|
|
||||||
Chewy.settings[:enabled] = true
|
Chewy.settings[:enabled] = true
|
||||||
example.run
|
example.run
|
||||||
|
|
|
@ -48,11 +48,10 @@ RSpec.describe AppSignUpService do
|
||||||
end
|
end
|
||||||
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
|
before do
|
||||||
Setting.registrations_mode = 'open'
|
Setting.registrations_mode = 'open'
|
||||||
Fabricate(:email_domain_block, allow_with_approval: true, domain: 'smtp.email.com')
|
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')
|
configure_mx(domain: 'email.com', exchange: 'smtp.email.com')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user