Expand coverage of admin/*blocks areas (#33594)

This commit is contained in:
Matt Jankowski 2025-01-15 02:47:34 -05:00 committed by GitHub
parent 68c9f91ccb
commit 9f03e5b53a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 3 deletions

View file

@ -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

View file

@ -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