diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 64091816011..e55fd698f2b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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: diff --git a/spec/controllers/api/v1/streaming_controller_spec.rb b/spec/controllers/api/v1/streaming_controller_spec.rb index 7014ed9b2be..06639a13fdb 100644 --- a/spec/controllers/api/v1/streaming_controller_spec.rb +++ b/spec/controllers/api/v1/streaming_controller_spec.rb @@ -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 diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb index 20770a72114..6610f4d138e 100644 --- a/spec/controllers/well_known/webfinger_controller_spec.rb +++ b/spec/controllers/well_known/webfinger_controller_spec.rb @@ -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 diff --git a/spec/helpers/instance_helper_spec.rb b/spec/helpers/instance_helper_spec.rb index c2e26dbed37..cdbce565984 100644 --- a/spec/helpers/instance_helper_spec.rb +++ b/spec/helpers/instance_helper_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 92ce87e3696..faf7fabf1e0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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' diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 8d9677f6ced..c2ef3e3159c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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 diff --git a/spec/serializers/activitypub/note_serializer_spec.rb b/spec/serializers/activitypub/note_serializer_spec.rb index 31ee31f132f..311a4573d95 100644 --- a/spec/serializers/activitypub/note_serializer_spec.rb +++ b/spec/serializers/activitypub/note_serializer_spec.rb @@ -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 diff --git a/spec/serializers/activitypub/update_poll_serializer_spec.rb b/spec/serializers/activitypub/update_poll_serializer_spec.rb index 14c24c70cc7..9a13fdd5768 100644 --- a/spec/serializers/activitypub/update_poll_serializer_spec.rb +++ b/spec/serializers/activitypub/update_poll_serializer_spec.rb @@ -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 diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index 1904ac8dc91..e12bbc1a788 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -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'