Fix RSpec/VerifiedDoubles
cop (#25469)
This commit is contained in:
parent
38433ccd0b
commit
05f9e39b32
50 changed files with 162 additions and 172 deletions
|
@ -23,7 +23,8 @@ RSpec.describe Admin::ChangeEmailsController do
|
|||
|
||||
describe 'GET #update' do
|
||||
before do
|
||||
allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil))
|
||||
allow(UserMailer).to receive(:confirmation_instructions)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
|
|
|
@ -38,7 +38,7 @@ RSpec.describe Admin::ConfirmationsController do
|
|||
let!(:user) { Fabricate(:user, confirmed_at: confirmed_at) }
|
||||
|
||||
before do
|
||||
allow(UserMailer).to receive(:confirmation_instructions) { double(:email, deliver_later: nil) }
|
||||
allow(UserMailer).to receive(:confirmation_instructions) { instance_double(ActionMailer::MessageDelivery, deliver_later: nil) }
|
||||
end
|
||||
|
||||
context 'when email is not confirmed' do
|
||||
|
|
|
@ -19,7 +19,8 @@ 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(double('email', deliver_later: nil))
|
||||
allow(UserMailer).to receive(:appeal_approved)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
post :approve, params: { id: appeal.id }
|
||||
end
|
||||
|
||||
|
@ -40,7 +41,8 @@ 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(double('email', deliver_later: nil))
|
||||
allow(UserMailer).to receive(:appeal_rejected)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
post :reject, params: { id: appeal.id }
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ RSpec.describe Admin::DomainAllowsController do
|
|||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'disallows the domain' do
|
||||
service = double(call: true)
|
||||
service = instance_double(UnallowDomainService, call: true)
|
||||
allow(UnallowDomainService).to receive(:new).and_return(service)
|
||||
domain_allow = Fabricate(:domain_allow)
|
||||
delete :destroy, params: { id: domain_allow.id }
|
||||
|
|
|
@ -213,7 +213,7 @@ RSpec.describe Admin::DomainBlocksController do
|
|||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'unblocks the domain' do
|
||||
service = double(call: true)
|
||||
service = instance_double(UnblockDomainService, call: true)
|
||||
allow(UnblockDomainService).to receive(:new).and_return(service)
|
||||
domain_block = Fabricate(:domain_block)
|
||||
delete :destroy, params: { id: domain_block.id }
|
||||
|
|
|
@ -23,7 +23,8 @@ RSpec.describe Api::V1::ReportsController do
|
|||
let(:rule_ids) { nil }
|
||||
|
||||
before do
|
||||
allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil))
|
||||
allow(AdminMailer).to receive(:new_report)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
post :create, params: { status_ids: [status.id], account_id: target_account.id, comment: 'reasons', category: category, rule_ids: rule_ids, forward: forward }
|
||||
end
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ describe Api::Web::EmbedsController do
|
|||
|
||||
context 'when fails to find status' do
|
||||
let(:url) { 'https://host.test/oembed.html' }
|
||||
let(:service_instance) { double('fetch_oembed_service') }
|
||||
let(:service_instance) { instance_double(FetchOEmbedService) }
|
||||
|
||||
before do
|
||||
allow(FetchOEmbedService).to receive(:new) { service_instance }
|
||||
|
|
|
@ -127,7 +127,8 @@ RSpec.describe Auth::SessionsController do
|
|||
|
||||
before do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return(current_ip)
|
||||
allow(UserMailer).to receive(:suspicious_sign_in).and_return(double('email', deliver_later!: nil))
|
||||
allow(UserMailer).to receive(:suspicious_sign_in)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later!: nil))
|
||||
user.update(current_sign_in_at: 1.month.ago)
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ describe AuthorizeInteractionsController do
|
|||
end
|
||||
|
||||
it 'renders error when account cant be found' do
|
||||
service = double
|
||||
service = instance_double(ResolveAccountService)
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('missing@hostname').and_return(nil)
|
||||
|
||||
|
@ -40,7 +40,7 @@ describe AuthorizeInteractionsController do
|
|||
|
||||
it 'sets resource from url' do
|
||||
account = Fabricate(:account)
|
||||
service = double
|
||||
service = instance_double(ResolveURLService)
|
||||
allow(ResolveURLService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('http://example.com').and_return(account)
|
||||
|
||||
|
@ -52,7 +52,7 @@ describe AuthorizeInteractionsController do
|
|||
|
||||
it 'sets resource from acct uri' do
|
||||
account = Fabricate(:account)
|
||||
service = double
|
||||
service = instance_double(ResolveAccountService)
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('found@hostname').and_return(account)
|
||||
|
||||
|
@ -82,7 +82,7 @@ describe AuthorizeInteractionsController do
|
|||
end
|
||||
|
||||
it 'shows error when account not found' do
|
||||
service = double
|
||||
service = instance_double(ResolveAccountService)
|
||||
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('user@hostname').and_return(nil)
|
||||
|
@ -94,7 +94,7 @@ describe AuthorizeInteractionsController do
|
|||
|
||||
it 'follows account when found' do
|
||||
target_account = Fabricate(:account)
|
||||
service = double
|
||||
service = instance_double(ResolveAccountService)
|
||||
|
||||
allow(ResolveAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('user@hostname').and_return(target_account)
|
||||
|
|
|
@ -14,7 +14,8 @@ RSpec.describe Disputes::AppealsController do
|
|||
let(:strike) { Fabricate(:account_warning, target_account: current_user.account) }
|
||||
|
||||
before do
|
||||
allow(AdminMailer).to receive(:new_appeal).and_return(double('email', deliver_later: nil))
|
||||
allow(AdminMailer).to receive(:new_appeal)
|
||||
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
|
||||
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue