0
0

Fix RSpec/HookArgument cop (#27747)

This commit is contained in:
Matt Jankowski 2023-11-07 04:10:36 -05:00 committed by GitHub
parent 1b28ab7263
commit b06284c572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 30 deletions

View File

@ -94,20 +94,6 @@ RSpec/AnyInstance:
RSpec/ExampleLength:
Max: 22
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Exclude:
- 'spec/controllers/api/v1/streaming_controller_spec.rb'
- 'spec/controllers/well_known/webfinger_controller_spec.rb'
- 'spec/helpers/instance_helper_spec.rb'
- 'spec/models/user_spec.rb'
- 'spec/rails_helper.rb'
- 'spec/serializers/activitypub/note_serializer_spec.rb'
- 'spec/serializers/activitypub/update_poll_serializer_spec.rb'
- 'spec/services/import_service_spec.rb'
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:

View File

@ -3,14 +3,14 @@
require 'rails_helper'
describe Api::V1::StreamingController do
around(:each) do |example|
around do |example|
before = Rails.configuration.x.streaming_api_base_url
Rails.configuration.x.streaming_api_base_url = Rails.configuration.x.web_domain
example.run
Rails.configuration.x.streaming_api_base_url = before
end
before(:each) do
before do
request.headers.merge! Host: Rails.configuration.x.web_domain
end
@ -24,7 +24,7 @@ describe Api::V1::StreamingController do
end
context 'with streaming api on different host' do
before(:each) do
before do
Rails.configuration.x.streaming_api_base_url = "wss://streaming-#{Rails.configuration.x.web_domain}"
@streaming_host = URI.parse(Rails.configuration.x.streaming_api_base_url).host
end

View File

@ -16,7 +16,7 @@ describe WellKnown::WebfingerController do
let(:alice) { Fabricate(:account, username: 'alice') }
let(:resource) { nil }
around(:each) do |example|
around do |example|
tmp = Rails.configuration.x.alternate_domains
Rails.configuration.x.alternate_domains = alternate_domains
example.run

View File

@ -18,7 +18,7 @@ describe InstanceHelper do
end
describe 'site_hostname' do
around(:each) do |example|
around do |example|
before = Rails.configuration.x.local_domain
example.run
Rails.configuration.x.local_domain = before

View File

@ -102,7 +102,7 @@ RSpec.describe User do
end
describe 'blacklist' do
around(:each) do |example|
around do |example|
old_blacklist = Rails.configuration.x.email_blacklist
Rails.configuration.x.email_domains_blacklist = 'mvrht.com'
@ -169,7 +169,7 @@ RSpec.describe User do
let(:user) { Fabricate(:user, confirmed_at: nil, unconfirmed_email: new_email) }
context 'when the user is already approved' do
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'approved'
@ -193,7 +193,7 @@ RSpec.describe User do
end
context 'when the user does not require explicit approval' do
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'open'
@ -213,7 +213,7 @@ RSpec.describe User do
end
context 'when the user requires explicit approval but is not approved' do
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'approved'
@ -237,7 +237,7 @@ RSpec.describe User do
describe '#approve!' do
subject { user.approve! }
around(:example) do |example|
around do |example|
registrations_mode = Setting.registrations_mode
Setting.registrations_mode = 'approved'
@ -338,7 +338,7 @@ RSpec.describe User do
end
describe 'whitelist' do
around(:each) do |example|
around do |example|
old_whitelist = Rails.configuration.x.email_domains_whitelist
Rails.configuration.x.email_domains_whitelist = 'mastodon.space'

View File

@ -142,13 +142,13 @@ RSpec.configure do |config|
search_data_manager.remove_indexes
end
config.before(:each) do |example|
config.before do |example|
unless example.metadata[:paperclip_processing]
allow_any_instance_of(Paperclip::Attachment).to receive(:post_process).and_return(true) # rubocop:disable RSpec/AnyInstance
end
end
config.after :each do
config.after do
Rails.cache.clear
redis.del(redis.keys)
end

View File

@ -14,7 +14,7 @@ describe ActivityPub::NoteSerializer do
let!(:reply_by_account_third) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
let!(:reply_by_account_visibility_direct) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
before(:each) do
before do
@serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: described_class, adapter: ActivityPub::Adapter)
end

View File

@ -9,7 +9,7 @@ describe ActivityPub::UpdatePollSerializer do
let(:poll) { Fabricate(:poll, account: account) }
let!(:status) { Fabricate(:status, account: account, poll: poll) }
before(:each) do
before do
@serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: described_class, adapter: ActivityPub::Adapter)
end

View File

@ -208,7 +208,7 @@ RSpec.describe ImportService, type: :service do
let!(:remote_status) { Fabricate(:status, uri: 'https://example.com/statuses/1312') }
let!(:direct_status) { Fabricate(:status, uri: 'https://example.com/statuses/direct', visibility: :direct) }
around(:each) do |example|
around do |example|
local_before = Rails.configuration.x.local_domain
web_before = Rails.configuration.x.web_domain
Rails.configuration.x.local_domain = 'local.com'