Fix RSpec/AnyInstance
cop (#27810)
This commit is contained in:
parent
d562fb8459
commit
b2c5b20ef2
14 changed files with 70 additions and 60 deletions
|
@ -227,7 +227,8 @@ RSpec.describe Admin::AccountsController do
|
|||
let(:account) { Fabricate(:account, domain: 'example.com') }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(ResolveAccountService).to receive(:call)
|
||||
service = instance_double(ResolveAccountService, call: nil)
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
end
|
||||
|
||||
context 'when user is admin' do
|
||||
|
|
|
@ -13,12 +13,20 @@ describe Admin::ResetsController do
|
|||
|
||||
describe 'POST #create' do
|
||||
it 'redirects to admin accounts page' do
|
||||
expect_any_instance_of(User).to receive(:send_reset_password_instructions) do |value|
|
||||
expect(value.account_id).to eq account.id
|
||||
end
|
||||
|
||||
post :create, params: { account_id: account.id }
|
||||
expect do
|
||||
post :create, params: { account_id: account.id }
|
||||
end.to change(Devise.mailer.deliveries, :size).by(2)
|
||||
|
||||
expect(Devise.mailer.deliveries).to have_attributes(
|
||||
first: have_attributes(
|
||||
to: include(account.user.email),
|
||||
subject: I18n.t('devise.mailer.password_change.subject')
|
||||
),
|
||||
last: have_attributes(
|
||||
to: include(account.user.email),
|
||||
subject: I18n.t('devise.mailer.reset_password_instructions.subject')
|
||||
)
|
||||
)
|
||||
expect(response).to redirect_to(admin_account_path(account.id))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue