Use capture_emails helper to improve email assertions in specs (#29245)
This commit is contained in:
@@ -5,6 +5,8 @@ require 'rails_helper'
|
||||
describe Admin::ResetsController do
|
||||
render_views
|
||||
|
||||
subject { post :create, params: { account_id: account.id } }
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
@@ -13,11 +15,11 @@ describe Admin::ResetsController do
|
||||
|
||||
describe 'POST #create', :sidekiq_inline do
|
||||
it 'redirects to admin accounts page' do
|
||||
expect do
|
||||
post :create, params: { account_id: account.id }
|
||||
end.to change(Devise.mailer.deliveries, :size).by(2)
|
||||
emails = capture_emails { subject }
|
||||
|
||||
expect(Devise.mailer.deliveries).to have_attributes(
|
||||
expect(emails.size)
|
||||
.to eq(2)
|
||||
expect(emails).to have_attributes(
|
||||
first: have_attributes(
|
||||
to: include(account.user.email),
|
||||
subject: I18n.t('devise.mailer.password_change.subject')
|
||||
|
||||
Reference in New Issue
Block a user