0
0
Fork 0

Fix RSpec/StubbedMock cop (#25552)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Matt Jankowski 2023-07-12 04:20:10 -04:00 committed by GitHub
parent 2e1391fdd2
commit 6c5a2233a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 31 deletions

View file

@ -88,10 +88,11 @@ describe Api::BaseController do
Mastodon::NotPermittedError => 403,
}.each do |error, code|
it "Handles error class of #{error}" do
expect(FakeService).to receive(:new).and_raise(error)
allow(FakeService).to receive(:new).and_raise(error)
get 'error'
expect(response).to have_http_status(code)
expect(FakeService).to have_received(:new)
end
end
end

View file

@ -16,7 +16,7 @@ RSpec.describe Api::V1::MediaController do
describe 'with paperclip errors' do
context 'when imagemagick cant identify the file type' do
it 'returns http 422' do
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Errors::NotIdentifiedByImageMagickError)
allow_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Errors::NotIdentifiedByImageMagickError)
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
expect(response).to have_http_status(422)
@ -25,7 +25,7 @@ RSpec.describe Api::V1::MediaController do
context 'when there is a generic error' do
it 'returns http 422' do
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Error)
allow_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Error)
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
expect(response).to have_http_status(500)