0
0
Fork 0

Provide a link to existing domain block when trying to block an already-blocked domain (#10663)

* When trying to block an already-blocked domain, provide a link to the block

* Fix styling for links in flash messages

* Allow blocks to be upgraded but not downgraded
This commit is contained in:
ThibG 2019-05-03 20:36:36 +02:00 committed by Eugen Rochko
parent eb63217210
commit 011b032300
6 changed files with 79 additions and 6 deletions

View file

@ -37,7 +37,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
end
it 'renders new when failed to save' do
Fabricate(:domain_block, domain: 'example.com')
Fabricate(:domain_block, domain: 'example.com', severity: 'suspend')
allow(DomainBlockWorker).to receive(:perform_async).and_return(true)
post :create, params: { domain_block: { domain: 'example.com', severity: 'silence' } }
@ -45,6 +45,17 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
expect(DomainBlockWorker).not_to have_received(:perform_async)
expect(response).to render_template :new
end
it 'allows upgrading a block' do
Fabricate(:domain_block, domain: 'example.com', severity: 'silence')
allow(DomainBlockWorker).to receive(:perform_async).and_return(true)
post :create, params: { domain_block: { domain: 'example.com', severity: 'silence', reject_media: true, reject_reports: true } }
expect(DomainBlockWorker).to have_received(:perform_async)
expect(flash[:notice]).to eq I18n.t('admin.domain_blocks.created_msg')
expect(response).to redirect_to(admin_instances_path(limited: '1'))
end
end
describe 'DELETE #destroy' do