Add coverage for approve/reject actions in Form::AccountBatch (#40373)

This commit is contained in:
Matt Jankowski
2026-09-04 12:40:04 +00:00
committed by GitHub
parent 9d5c262d02
commit e3be977a74

View File

@@ -11,6 +11,7 @@ RSpec.describe Form::AccountBatch do
let(:account) { Fabricate(:admin_user).account }
let(:account_ids) { [] }
let(:query) { Account.none }
let(:select_all_matching) { false }
before do
account_batch.assign_attributes(
@@ -77,5 +78,42 @@ RSpec.describe Form::AccountBatch do
[target_account.reload, target_account2.reload].map(&:suspended?)
end
end
context 'when action is "approve"' do
let(:action) { 'approve' }
let(:account_ids) { [unapproved_user_account.id] }
let(:unapproved_user_account) { Fabricate :account }
before { unapproved_user_account.user.update!(approved: false) }
it 'approves the user of the supplied accounts' do
expect { subject }
.to change { unapproved_user_account.reload.user.approved? }.to(true)
end
end
context 'when action is "reject"' do
let(:action) { 'reject' }
let(:account_ids) { [reject_user_account.id] }
let(:reject_user_account) { Fabricate :account }
before { reject_user_account.user.update!(approved: false) }
it 'rejects the user of the supplied accounts' do
expect { subject }
.to change { reject_user_account.reload.suspended? }.to(true)
end
end
context 'when action is "unknown"' do
let(:action) { 'unknown' }
let(:account_ids) { [account.id] }
let(:account) { Fabricate :account }
it 'does not change the supplied accounts' do
expect { subject }
.to_not(change { account.reload.updated_at })
end
end
end
end