0
0
Fork 0

Add confirmation page when importing blocked domains (#1773)

* Move glitch-soc-specific strings to glitch-soc-specific locale files

* Add confirmation page when importing blocked domains
This commit is contained in:
Claire 2022-05-16 18:26:49 +02:00 committed by GitHub
parent 3a08411306
commit b91196f4b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 183 additions and 48 deletions

View file

@ -22,26 +22,14 @@ RSpec.describe Admin::ExportDomainBlocksController, type: :controller do
describe 'POST #import' do
it 'blocks imported domains' do
allow(DomainBlockWorker).to receive(:perform_async).and_return(true)
post :import, params: { admin_import: { data: fixture_file_upload('domain_blocks.csv') } }
expect(response).to redirect_to(admin_instances_path(limited: '1'))
expect(DomainBlockWorker).to have_received(:perform_async).exactly(3).times
# Header should not be imported
expect(DomainBlock.where(domain: '#domain').present?).to eq(false)
# Domains should now be added
get :export, params: { format: :csv }
expect(response).to have_http_status(200)
expect(response.body).to eq(IO.read(File.join(file_fixture_path, 'domain_blocks.csv')))
expect(assigns(:domain_blocks).map(&:domain)).to match_array ['bad.domain', 'worse.domain', 'reject.media']
end
end
it 'displays error on no file selected' do
post :import, params: { admin_import: {} }
expect(response).to redirect_to(admin_instances_path(limited: '1'))
expect(flash[:error]).to eq(I18n.t('admin.export_domain_blocks.no_file'))
expect(flash[:alert]).to eq(I18n.t('admin.export_domain_blocks.no_file'))
end
end