mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Fix blocking subdomains of an already-blocked domain
This commit is contained in:
parent
ac7d40b561
commit
9e3f0170c2
|
@ -37,7 +37,7 @@ module Admin
|
|||
@domain_block.errors.delete(:domain)
|
||||
render :new
|
||||
else
|
||||
if existing_domain_block.present?
|
||||
if existing_domain_block.present? && existing_domain_block.domain == resource_params[:domain]
|
||||
@domain_block = existing_domain_block
|
||||
@domain_block.update(resource_params)
|
||||
end
|
||||
|
|
|
@ -68,6 +68,26 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
|
|||
expect(flash[:notice]).to eq I18n.t('admin.domain_blocks.created_msg')
|
||||
expect(response).to redirect_to(admin_instances_path(limited: '1'))
|
||||
end
|
||||
|
||||
context 'when a block for a parent domain already exists' do
|
||||
subject { post :create, params: { domain_block: { domain: 'subdomain.example.com', severity: child_severity } } }
|
||||
|
||||
let(:parent_severity) { 'silence' }
|
||||
let(:child_severity) { 'suspend' }
|
||||
|
||||
before do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: parent_severity)
|
||||
end
|
||||
|
||||
it 'does not change the existing block' do
|
||||
expect { subject }.to_not change { DomainBlock.find_by(domain: 'example.com') }
|
||||
end
|
||||
|
||||
it 'creates a domain block with expected severity' do
|
||||
subject
|
||||
expect(DomainBlock.where(domain: 'subdomain.example.com', severity: child_severity)).to exist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user