Fix RSpec/ExpectInHook cop (#25100)
parent
b6b4ea4ca5
commit
778e4a7bf7
|
@ -393,12 +393,6 @@ RSpec/ExpectChange:
|
||||||
- 'spec/services/unsuspend_account_service_spec.rb'
|
- 'spec/services/unsuspend_account_service_spec.rb'
|
||||||
- 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb'
|
- 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb'
|
||||||
|
|
||||||
RSpec/ExpectInHook:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/controllers/api/v1/media_controller_spec.rb'
|
|
||||||
- 'spec/controllers/settings/applications_controller_spec.rb'
|
|
||||||
- 'spec/lib/status_filter_spec.rb'
|
|
||||||
|
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
# Configuration parameters: EnforcedStyle.
|
# Configuration parameters: EnforcedStyle.
|
||||||
# SupportedStyles: implicit, each, example
|
# SupportedStyles: implicit, each, example
|
||||||
|
|
|
@ -15,23 +15,19 @@ RSpec.describe Api::V1::MediaController do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
describe 'with paperclip errors' do
|
describe 'with paperclip errors' do
|
||||||
context 'when imagemagick cant identify the file type' 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)
|
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') }
|
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http 422' do
|
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when there is a generic error' do
|
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)
|
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') }
|
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns http 422' do
|
|
||||||
expect(response).to have_http_status(500)
|
expect(response).to have_http_status(500)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -182,12 +182,10 @@ describe Settings::ApplicationsController do
|
||||||
describe 'regenerate' do
|
describe 'regenerate' do
|
||||||
let(:token) { user.token_for_app(app) }
|
let(:token) { user.token_for_app(app) }
|
||||||
|
|
||||||
before do
|
it 'creates new token' do
|
||||||
expect(token).to_not be_nil
|
expect(token).to_not be_nil
|
||||||
post :regenerate, params: { id: app.id }
|
post :regenerate, params: { id: app.id }
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates new token' do
|
|
||||||
expect(user.token_for_app(app)).to_not eql(token)
|
expect(user.token_for_app(app)).to_not eql(token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe StatusFilter do
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
|
|
||||||
context 'without an account' do
|
context 'without an account' do
|
||||||
subject { described_class.new(status, nil) }
|
subject(:filter) { described_class.new(status, nil) }
|
||||||
|
|
||||||
context 'when there are no connections' do
|
context 'when there are no connections' do
|
||||||
it { is_expected.to_not be_filtered }
|
it { is_expected.to_not be_filtered }
|
||||||
|
@ -22,16 +22,16 @@ describe StatusFilter do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when status policy does not allow show' do
|
context 'when status policy does not allow show' do
|
||||||
before do
|
it 'filters the status' do
|
||||||
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to be_filtered }
|
expect(filter).to be_filtered
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with real account' do
|
context 'with real account' do
|
||||||
subject { described_class.new(status, account) }
|
subject(:filter) { described_class.new(status, account) }
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
|
@ -73,11 +73,11 @@ describe StatusFilter do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when status policy does not allow show' do
|
context 'when status policy does not allow show' do
|
||||||
before do
|
it 'filters the status' do
|
||||||
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to be_filtered }
|
expect(filter).to be_filtered
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue