Fix RSpec/ExpectInHook cop (#25100)

This commit is contained in:
Matt Jankowski 2023-05-23 10:40:21 -04:00 committed by GitHub
parent b6b4ea4ca5
commit 778e4a7bf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 23 deletions

View file

@ -15,23 +15,19 @@ RSpec.describe Api::V1::MediaController do
describe 'POST #create' do
describe 'with paperclip errors' do
context 'when imagemagick cant identify the file type' do
before do
it 'returns http 422' do
expect_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') }
end
it 'returns http 422' do
expect(response).to have_http_status(422)
end
end
context 'when there is a generic error' do
before do
it 'returns http 422' do
expect_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') }
end
it 'returns http 422' do
expect(response).to have_http_status(500)
end
end

View file

@ -182,12 +182,10 @@ describe Settings::ApplicationsController do
describe 'regenerate' do
let(:token) { user.token_for_app(app) }
before do
it 'creates new token' do
expect(token).to_not be_nil
post :regenerate, params: { id: app.id }
end
it 'creates new token' do
expect(user.token_for_app(app)).to_not eql(token)
end
end