2023-10-13 04:42:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 01:12:25 -04:00
|
|
|
RSpec.describe 'Admin::EmailDomainBlocks' do
|
2025-01-03 03:28:14 -05:00
|
|
|
let(:current_user) { Fabricate(:admin_user) }
|
2023-10-13 04:42:59 -04:00
|
|
|
|
2025-01-15 02:47:34 -05:00
|
|
|
before { sign_in current_user }
|
2023-10-13 04:42:59 -04:00
|
|
|
|
|
|
|
describe 'Performing batch updates' do
|
|
|
|
before do
|
|
|
|
visit admin_email_domain_blocks_path
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without selecting any records' do
|
|
|
|
it 'displays a notice about selection' do
|
2024-01-04 04:20:32 -05:00
|
|
|
click_on button_for_delete
|
2023-10-13 04:42:59 -04:00
|
|
|
|
|
|
|
expect(page).to have_content(selection_error_text)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-01-15 02:47:34 -05:00
|
|
|
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
|
|
|
|
|
2023-10-13 04:42:59 -04:00
|
|
|
def button_for_delete
|
|
|
|
I18n.t('admin.email_domain_blocks.delete')
|
|
|
|
end
|
|
|
|
|
|
|
|
def selection_error_text
|
|
|
|
I18n.t('admin.email_domain_blocks.no_email_domain_block_selected')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|