Use deliveries.size
in mailer-related examples in controller specs (#27589)
This commit is contained in:
parent
1cc512909c
commit
2e6bf60f15
2 changed files with 9 additions and 9 deletions
|
@ -33,8 +33,6 @@ RSpec.describe Admin::Disputes::AppealsController do
|
|||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
allow(UserMailer).to receive(:appeal_approved)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
post :approve, params: { id: appeal.id }
|
||||
end
|
||||
|
||||
|
@ -47,7 +45,9 @@ RSpec.describe Admin::Disputes::AppealsController do
|
|||
end
|
||||
|
||||
it 'notifies target account about approved appeal' do
|
||||
expect(UserMailer).to have_received(:appeal_approved).with(target_account.user, appeal)
|
||||
expect(UserMailer.deliveries.size).to eq(1)
|
||||
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
|
||||
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at)))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,8 +55,6 @@ RSpec.describe Admin::Disputes::AppealsController do
|
|||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
before do
|
||||
allow(UserMailer).to receive(:appeal_rejected)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
post :reject, params: { id: appeal.id }
|
||||
end
|
||||
|
||||
|
@ -65,7 +63,9 @@ RSpec.describe Admin::Disputes::AppealsController do
|
|||
end
|
||||
|
||||
it 'notifies target account about rejected appeal' do
|
||||
expect(UserMailer).to have_received(:appeal_rejected).with(target_account.user, appeal)
|
||||
expect(UserMailer.deliveries.size).to eq(1)
|
||||
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
|
||||
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue