diff --git a/spec/models/form/account_batch_spec.rb b/spec/models/form/account_batch_spec.rb index 8db9a2a2545..b738b69fdd9 100644 --- a/spec/models/form/account_batch_spec.rb +++ b/spec/models/form/account_batch_spec.rb @@ -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