diff --git a/spec/system/admin/email_domain_blocks_spec.rb b/spec/system/admin/email_domain_blocks_spec.rb index acf5027eda..807cfb3768 100644 --- a/spec/system/admin/email_domain_blocks_spec.rb +++ b/spec/system/admin/email_domain_blocks_spec.rb @@ -5,9 +5,7 @@ require 'rails_helper' RSpec.describe 'Admin::EmailDomainBlocks' do let(:current_user) { Fabricate(:admin_user) } - before do - sign_in current_user - end + before { sign_in current_user } describe 'Performing batch updates' do before do @@ -22,6 +20,27 @@ RSpec.describe 'Admin::EmailDomainBlocks' do end end + context 'with a selected block' do + let!(:email_domain_block) { Fabricate :email_domain_block } + + it 'deletes the block' do + visit admin_email_domain_blocks_path + + check_item + + expect { click_on button_for_delete } + .to change(EmailDomainBlock, :count).by(-1) + expect { email_domain_block.reload } + .to raise_error(ActiveRecord::RecordNotFound) + end + end + + def check_item + within '.batch-table__row' do + find('input[type=checkbox]').check + end + end + def button_for_delete I18n.t('admin.email_domain_blocks.delete') end diff --git a/spec/system/admin/ip_blocks_spec.rb b/spec/system/admin/ip_blocks_spec.rb index 8e8c8031c8..3bed506b68 100644 --- a/spec/system/admin/ip_blocks_spec.rb +++ b/spec/system/admin/ip_blocks_spec.rb @@ -48,6 +48,27 @@ RSpec.describe 'Admin::IpBlocks' do end end + context 'with a selected block' do + let!(:ip_block) { Fabricate :ip_block } + + it 'deletes the block' do + visit admin_ip_blocks_path + + check_item + + expect { click_on button_for_delete } + .to change(IpBlock, :count).by(-1) + expect { ip_block.reload } + .to raise_error(ActiveRecord::RecordNotFound) + end + end + + def check_item + within '.batch-table__row' do + find('input[type=checkbox]').check + end + end + def button_for_delete I18n.t('admin.ip_blocks.delete') end