From 448be26b34c965fcae65eb4c5227b35d97120537 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 23 Jan 2023 13:05:30 +0100 Subject: Add missing `policy` attribute to `WebPushSubscriptionSerializer` (#23210) * Add missing `policy` attribute to `WebPushSubscriptionSerializer` Fixes #23145 * Add tests --- spec/controllers/api/v1/push/subscriptions_controller_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb index 534d02879..9487251e1 100644 --- a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb +++ b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb @@ -61,6 +61,10 @@ describe Api::V1::Push::SubscriptionsController do post :create, params: create_payload expect(Web::PushSubscription.where(endpoint: create_payload[:subscription][:endpoint]).count).to eq 1 end + + it 'returns the expected JSON' do + expect(body_as_json.with_indifferent_access).to include({ endpoint: create_payload[:subscription][:endpoint], alerts: {}, policy: 'all' }) + end end describe 'PUT #update' do @@ -78,6 +82,10 @@ describe Api::V1::Push::SubscriptionsController do expect(push_subscription.data['alerts'][type]).to eq(alerts_payload[:data][:alerts][type.to_sym].to_s) end end + + it 'returns the expected JSON' do + expect(body_as_json.with_indifferent_access).to include({ endpoint: create_payload[:subscription][:endpoint], alerts: alerts_payload[:data][:alerts], policy: alerts_payload[:data][:policy] }) + end end describe 'DELETE #destroy' do -- cgit From 45e2936c89870de7cd2fd0ce159e195745d8fddc Mon Sep 17 00:00:00 2001 From: Varun Sharma Date: Mon, 13 Feb 2023 20:34:26 +0530 Subject: Add tests to indicate inclusion of self replies in statuses endpoint (#23266) --- .../api/v1/accounts/statuses_controller_spec.rb | 37 ++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb index b962b3398..01d745fc0 100644 --- a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'rails_helper' describe Api::V1::Accounts::StatusesController do @@ -15,7 +16,12 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, limit: 1 } - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) + end + + it 'returns expected headers' do + get :index, params: { account_id: user.account.id, limit: 1 } + expect(response.headers['Link'].links.size).to eq(2) end @@ -23,19 +29,29 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, only_media: true } - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) end end context 'with exclude replies' do + let!(:older_statuses) { user.account.statuses.destroy_all } + let!(:status) { Fabricate(:status, account: user.account) } + let!(:status_self_reply) { Fabricate(:status, account: user.account, thread: status) } + before do - Fabricate(:status, account: user.account, thread: Fabricate(:status)) + Fabricate(:status, account: user.account, thread: Fabricate(:status)) # Reply to another user + get :index, params: { account_id: user.account.id, exclude_replies: true } end it 'returns http success' do - get :index, params: { account_id: user.account.id, exclude_replies: true } + expect(response).to have_http_status(:ok) + end + + it 'returns posts along with self replies' do + json = body_as_json + post_ids = json.map { |item| item[:id].to_i }.sort - expect(response).to have_http_status(200) + expect(post_ids).to eq [status.id, status_self_reply.id] end end @@ -47,7 +63,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, pinned: true } - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) end end @@ -55,12 +71,15 @@ describe Api::V1::Accounts::StatusesController do let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com') } let(:status) { Fabricate(:status, account: account) } let(:private_status) { Fabricate(:status, account: account, visibility: :private) } - let!(:pin) { Fabricate(:status_pin, account: account, status: status) } - let!(:private_pin) { Fabricate(:status_pin, account: account, status: private_status) } + + before do + Fabricate(:status_pin, account: account, status: status) + Fabricate(:status_pin, account: account, status: private_status) + end it 'returns http success' do get :index, params: { account_id: account.id, pinned: true } - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) end context 'when user does not follow account' do -- cgit From d6930b3847405dc9f8c1a54fb74d488a3c9a775e Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 13 Feb 2023 16:36:29 +0100 Subject: Add API parameter to safeguard unexpect mentions in new posts (#18350) --- app/controllers/api/v1/statuses_controller.rb | 8 +++++++ app/services/post_status_service.rb | 28 +++++++++++++++++++--- app/services/process_mentions_service.rb | 19 ++++++++------- .../controllers/api/v1/statuses_controller_spec.rb | 17 +++++++++++++ spec/services/post_status_service_spec.rb | 21 +++++++++++++++- spec/services/process_mentions_service_spec.rb | 13 ++++++++++ 6 files changed, 94 insertions(+), 12 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 9a8c0c161..fadd1b045 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -63,11 +63,18 @@ class Api::V1::StatusesController < Api::BaseController scheduled_at: status_params[:scheduled_at], application: doorkeeper_token.application, poll: status_params[:poll], + allowed_mentions: status_params[:allowed_mentions], idempotency: request.headers['Idempotency-Key'], with_rate_limit: true ) render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer + rescue PostStatusService::UnexpectedMentionsError => e + unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new( + e.accounts, + serializer: REST::AccountSerializer + ) + render json: { error: e.message, unexpected_accounts: unexpected_accounts }, status: 422 end def update @@ -128,6 +135,7 @@ class Api::V1::StatusesController < Api::BaseController :visibility, :language, :scheduled_at, + allowed_mentions: [], media_ids: [], media_attributes: [ :id, diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index bd3b69632..258af8827 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -6,6 +6,15 @@ class PostStatusService < BaseService MIN_SCHEDULE_OFFSET = 5.minutes.freeze + class UnexpectedMentionsError < StandardError + attr_reader :accounts + + def initialize(message, accounts) + super(message) + @accounts = accounts + end + end + # Post a text status update, fetch and notify remote users mentioned # @param [Account] account Account from which to post # @param [Hash] options @@ -21,6 +30,7 @@ class PostStatusService < BaseService # @option [Doorkeeper::Application] :application # @option [String] :idempotency Optional idempotency key # @option [Boolean] :with_rate_limit + # @option [Enumerable] :allowed_mentions Optional array of expected mentioned account IDs, raises `UnexpectedMentionsError` if unexpected accounts end up in mentions # @return [Status] def call(account, options = {}) @account = account @@ -63,14 +73,27 @@ class PostStatusService < BaseService end def process_status! + @status = @account.statuses.new(status_attributes) + process_mentions_service.call(@status, save_records: false) + safeguard_mentions!(@status) + # The following transaction block is needed to wrap the UPDATEs to # the media attachments when the status is created - ApplicationRecord.transaction do - @status = @account.statuses.create!(status_attributes) + @status.save! end end + def safeguard_mentions!(status) + return if @options[:allowed_mentions].nil? + expected_account_ids = @options[:allowed_mentions].map(&:to_i) + + unexpected_accounts = status.mentions.map(&:account).to_a.reject { |mentioned_account| expected_account_ids.include?(mentioned_account.id) } + return if unexpected_accounts.empty? + + raise UnexpectedMentionsError.new('Post would be sent to unexpected accounts', unexpected_accounts) + end + def schedule_status! status_for_validation = @account.statuses.build(status_attributes) @@ -93,7 +116,6 @@ class PostStatusService < BaseService def postprocess_status! process_hashtags_service.call(@status) - process_mentions_service.call(@status) Trends.tags.register(@status) LinkCrawlWorker.perform_async(@status.id) DistributionWorker.perform_async(@status.id) diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index b117db8c2..93a96667e 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -3,12 +3,13 @@ class ProcessMentionsService < BaseService include Payloadable - # Scan status for mentions and fetch remote mentioned users, create - # local mention pointers, send Salmon notifications to mentioned - # remote users + # Scan status for mentions and fetch remote mentioned users, + # and create local mention pointers # @param [Status] status - def call(status) + # @param [Boolean] save_records Whether to save records in database + def call(status, save_records: true) @status = status + @save_records = save_records return unless @status.local? @@ -55,14 +56,15 @@ class ProcessMentionsService < BaseService next match if mention_undeliverable?(mentioned_account) || mentioned_account&.suspended? mention = @previous_mentions.find { |x| x.account_id == mentioned_account.id } - mention ||= mentioned_account.mentions.new(status: @status) + mention ||= @current_mentions.find { |x| x.account_id == mentioned_account.id } + mention ||= @status.mentions.new(account: mentioned_account) @current_mentions << mention "@#{mentioned_account.acct}" end - @status.save! + @status.save! if @save_records end def assign_mentions! @@ -73,11 +75,12 @@ class ProcessMentionsService < BaseService mentioned_account_ids = @current_mentions.map(&:account_id) blocked_account_ids = Set.new(@status.account.block_relationships.where(target_account_id: mentioned_account_ids).pluck(:target_account_id)) - @current_mentions.select! { |mention| !(blocked_account_ids.include?(mention.account_id) || blocked_domains.include?(mention.account.domain)) } + dropped_mentions, @current_mentions = @current_mentions.partition { |mention| blocked_account_ids.include?(mention.account_id) || blocked_domains.include?(mention.account.domain) } + dropped_mentions.each(&:destroy) end @current_mentions.each do |mention| - mention.save if mention.new_record? + mention.save if mention.new_record? && @save_records end # If previous mentions are no longer contained in the text, convert them diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index 24810a5d2..bd8b8013a 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -133,6 +133,23 @@ RSpec.describe Api::V1::StatusesController, type: :controller do end end + context 'with a safeguard' do + let!(:alice) { Fabricate(:account, username: 'alice') } + let!(:bob) { Fabricate(:account, username: 'bob') } + + before do + post :create, params: { status: '@alice hm, @bob is really annoying lately', allowed_mentions: [alice.id] } + end + + it 'returns http unprocessable entity' do + expect(response).to have_http_status(422) + end + + it 'returns serialized extra accounts in body' do + expect(body_as_json[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to eq [{ id: bob.id.to_s, acct: bob.acct }] + end + end + context 'with missing parameters' do before do post :create, params: {} diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index d21270c79..28f20e9c7 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -138,7 +138,26 @@ RSpec.describe PostStatusService, type: :service do status = subject.call(account, text: "test status update") expect(ProcessMentionsService).to have_received(:new) - expect(mention_service).to have_received(:call).with(status) + expect(mention_service).to have_received(:call).with(status, save_records: false) + end + + it 'safeguards mentions' do + account = Fabricate(:account) + mentioned_account = Fabricate(:account, username: 'alice') + unexpected_mentioned_account = Fabricate(:account, username: 'bob') + + expect do + subject.call(account, text: '@alice hm, @bob is really annoying lately', allowed_mentions: [mentioned_account.id]) + end.to raise_error(an_instance_of(PostStatusService::UnexpectedMentionsError).and having_attributes(accounts: [unexpected_mentioned_account])) + end + + it 'processes duplicate mentions correctly' do + account = Fabricate(:account) + mentioned_account = Fabricate(:account, username: 'alice') + + expect do + subject.call(account, text: '@alice @alice @alice hey @alice') + end.not_to raise_error end it 'processes hashtags' do diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index 5b9d17a4c..0dd62c807 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -47,6 +47,19 @@ RSpec.describe ProcessMentionsService, type: :service do end end + context 'mentioning a user several times when not saving records' do + let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } + let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct} @#{remote_user.acct} @#{remote_user.acct}", visibility: :public) } + + before do + subject.call(status, save_records: false) + end + + it 'creates exactly one mention' do + expect(status.mentions.size).to eq 1 + end + end + context 'with an IDN domain' do let!(:remote_user) { Fabricate(:account, username: 'sneak', protocol: :activitypub, domain: 'xn--hresiar-mxa.ch', inbox_url: 'http://example.com/inbox') } let!(:status) { Fabricate(:status, account: account, text: "Hello @sneak@hæresiar.ch") } -- cgit From 68b1071f8634de1c15877215df73a7c006aa6222 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 07:45:27 -0500 Subject: Autofix Rubocop RSpec/BeNil (#23653) --- .rubocop_todo.yml | 19 ------------------- spec/controllers/accounts_controller_spec.rb | 2 +- .../activitypub/collections_controller_spec.rb | 2 +- .../activitypub/outboxes_controller_spec.rb | 2 +- .../activitypub/replies_controller_spec.rb | 2 +- spec/controllers/api/v1/apps_controller_spec.rb | 2 +- spec/controllers/api/v1/statuses_controller_spec.rb | 2 +- spec/controllers/instance_actors_controller_spec.rb | 2 +- spec/controllers/statuses_controller_spec.rb | 2 +- spec/models/account_statuses_cleanup_policy_spec.rb | 20 ++++++++++---------- spec/models/concerns/account_interactions_spec.rb | 2 +- spec/models/session_activation_spec.rb | 4 ++-- spec/models/user_spec.rb | 2 +- 13 files changed, 22 insertions(+), 41 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 34143a679..a990e9d18 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -914,25 +914,6 @@ RSpec/BeEq: - 'spec/workers/feed_insert_worker_spec.rb' - 'spec/workers/regeneration_worker_spec.rb' -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: be, be_nil -RSpec/BeNil: - Exclude: - - 'spec/controllers/accounts_controller_spec.rb' - - 'spec/controllers/activitypub/collections_controller_spec.rb' - - 'spec/controllers/activitypub/outboxes_controller_spec.rb' - - 'spec/controllers/activitypub/replies_controller_spec.rb' - - 'spec/controllers/api/v1/apps_controller_spec.rb' - - 'spec/controllers/api/v1/statuses_controller_spec.rb' - - 'spec/controllers/instance_actors_controller_spec.rb' - - 'spec/controllers/statuses_controller_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - - 'spec/models/session_activation_spec.rb' - - 'spec/models/user_spec.rb' - # Offense count: 1 RSpec/BeforeAfterAll: Exclude: diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index defa8b2d3..db588156c 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -8,7 +8,7 @@ RSpec.describe AccountsController, type: :controller do shared_examples 'cacheable response' do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index f78d9abbf..4e35938db 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do shared_examples 'cacheable response' do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index 74bf46a5e..d8d42b7ae 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -6,7 +6,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do shared_examples 'cacheable response' do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do diff --git a/spec/controllers/activitypub/replies_controller_spec.rb b/spec/controllers/activitypub/replies_controller_spec.rb index aee1a8b1a..394d4baab 100644 --- a/spec/controllers/activitypub/replies_controller_spec.rb +++ b/spec/controllers/activitypub/replies_controller_spec.rb @@ -11,7 +11,7 @@ RSpec.describe ActivityPub::RepliesController, type: :controller do shared_examples 'cacheable response' do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do diff --git a/spec/controllers/api/v1/apps_controller_spec.rb b/spec/controllers/api/v1/apps_controller_spec.rb index 70cd62d48..9ac7880a4 100644 --- a/spec/controllers/api/v1/apps_controller_spec.rb +++ b/spec/controllers/api/v1/apps_controller_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do end it 'creates an OAuth app' do - expect(Doorkeeper::Application.find_by(name: client_name)).to_not be nil + expect(Doorkeeper::Application.find_by(name: client_name)).to_not be_nil end it 'returns client ID and client secret' do diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index bd8b8013a..e4e6e172a 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -195,7 +195,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do end it 'removes the status' do - expect(Status.find_by(id: status.id)).to be nil + expect(Status.find_by(id: status.id)).to be_nil end end diff --git a/spec/controllers/instance_actors_controller_spec.rb b/spec/controllers/instance_actors_controller_spec.rb index f64a7d2ca..833539a76 100644 --- a/spec/controllers/instance_actors_controller_spec.rb +++ b/spec/controllers/instance_actors_controller_spec.rb @@ -20,7 +20,7 @@ RSpec.describe InstanceActorsController, type: :controller do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb index 6ed5d4bbb..c8b503d68 100644 --- a/spec/controllers/statuses_controller_spec.rb +++ b/spec/controllers/statuses_controller_spec.rb @@ -8,7 +8,7 @@ describe StatusesController do shared_examples 'cacheable response' do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index b01321a20..684a1aa41 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -35,61 +35,61 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do it 'invalidates last_inspected when widened because of keep_direct' do account_statuses_cleanup_policy.keep_direct = false account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of keep_pinned' do account_statuses_cleanup_policy.keep_pinned = false account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of keep_polls' do account_statuses_cleanup_policy.keep_polls = false account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of keep_media' do account_statuses_cleanup_policy.keep_media = false account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of keep_self_fav' do account_statuses_cleanup_policy.keep_self_fav = false account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of keep_self_bookmark' do account_statuses_cleanup_policy.keep_self_bookmark = false account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of higher min_favs' do account_statuses_cleanup_policy.min_favs = 5 account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of disabled min_favs' do account_statuses_cleanup_policy.min_favs = nil account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of higher min_reblogs' do account_statuses_cleanup_policy.min_reblogs = 5 account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end it 'invalidates last_inspected when widened because of disable min_reblogs' do account_statuses_cleanup_policy.min_reblogs = nil account_statuses_cleanup_policy.save - expect(account_statuses_cleanup_policy.last_inspected).to be nil + expect(account_statuses_cleanup_policy.last_inspected).to be_nil end end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 1d1898ab0..5cb4a83f7 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -317,7 +317,7 @@ describe AccountInteractions do context 'not muting the conversation' do it 'returns nil' do - is_expected.to be nil + is_expected.to be_nil end end end diff --git a/spec/models/session_activation_spec.rb b/spec/models/session_activation_spec.rb index 8db06c622..5c3d285cb 100644 --- a/spec/models/session_activation_spec.rb +++ b/spec/models/session_activation_spec.rb @@ -44,7 +44,7 @@ RSpec.describe SessionActivation, type: :model do let(:id) { nil } it 'returns nil' do - is_expected.to be nil + is_expected.to be_nil end end @@ -89,7 +89,7 @@ RSpec.describe SessionActivation, type: :model do let(:id) { nil } it 'returns nil' do - expect(described_class.deactivate(id)).to be nil + expect(described_class.deactivate(id)).to be_nil end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4b3d6101f..1f2ab77dc 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -285,7 +285,7 @@ RSpec.describe User, type: :model do it 'saves nil for otp_secret' do user = Fabricate.build(:user, otp_secret: 'oldotpcode') user.disable_two_factor! - expect(user.reload.otp_secret).to be nil + expect(user.reload.otp_secret).to be_nil end it 'saves cleared otp_backup_codes' do -- cgit From 669f6d2c0af969268c76e389ed626bce0cc9f998 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 16:56:20 -0500 Subject: Run rubocop formatting except line length (#23632) --- .rubocop_todo.yml | 277 +-------------------- app/lib/activitypub/activity/create.rb | 4 +- app/models/concerns/expireable.rb | 2 +- app/services/activitypub/fetch_replies_service.rb | 2 +- .../20161006213403_rails_settings_migration.rb | 10 +- ...uses_for_api_v1_accounts_account_id_statuses.rb | 8 +- .../20190306145741_add_lock_version_to_polls.rb | 1 - ...20190807135426_add_comments_to_domain_blocks.rb | 1 - ...200312162302_add_status_ids_to_announcements.rb | 1 - ...00510181721_remove_duplicated_indexes_pghero.rb | 1 - db/migrate/20200628133322_create_account_notes.rb | 1 - ...340_create_account_statuses_cleanup_policies.rb | 1 - ...0729171123_fix_custom_filter_keywords_id_seq.rb | 2 +- lib/paperclip/attachment_extensions.rb | 10 +- lib/tasks/mastodon.rake | 4 +- spec/config/initializers/rack_attack_spec.rb | 10 +- .../controllers/admin/dashboard_controller_spec.rb | 8 +- .../api/v1/accounts/credentials_controller_spec.rb | 2 +- spec/controllers/api/v1/reports_controller_spec.rb | 2 +- .../favourited_by_accounts_controller_spec.rb | 2 +- .../reblogged_by_accounts_controller_spec.rb | 2 +- .../api/v2/filters/statuses_controller_spec.rb | 4 +- spec/controllers/auth/sessions_controller_spec.rb | 6 +- .../authorize_interactions_controller_spec.rb | 1 - .../settings/applications_controller_spec.rb | 2 +- .../confirmations_controller_spec.rb | 1 - .../webauthn_credentials_controller_spec.rb | 2 +- .../well_known/host_meta_controller_spec.rb | 12 +- .../custom_filter_keyword_fabricator.rb | 2 +- spec/fabricators/ip_block_fabricator.rb | 2 +- spec/fabricators/poll_vote_fabricator.rb | 2 +- spec/fabricators/status_edit_fabricator.rb | 2 +- spec/fabricators/system_key_fabricator.rb | 1 - spec/lib/activitypub/activity/create_spec.rb | 1 - spec/lib/extractor_spec.rb | 8 +- spec/lib/fast_ip_map_spec.rb | 2 +- spec/lib/link_details_extractor_spec.rb | 124 ++++----- spec/models/account/field_spec.rb | 4 +- spec/models/account_alias_spec.rb | 1 - .../models/account_statuses_cleanup_policy_spec.rb | 40 ++- spec/models/concerns/account_interactions_spec.rb | 2 +- spec/models/device_spec.rb | 1 - spec/models/encrypted_message_spec.rb | 1 - spec/models/export_spec.rb | 2 +- spec/models/login_activity_spec.rb | 1 - spec/models/one_time_key_spec.rb | 1 - spec/models/system_key_spec.rb | 1 - spec/models/trends/statuses_spec.rb | 2 +- spec/models/user_role_spec.rb | 2 +- spec/routing/api_routing_spec.rb | 72 +++--- spec/routing/well_known_routes_spec.rb | 8 +- spec/serializers/rest/account_serializer_spec.rb | 2 +- .../account_statuses_cleanup_service_spec.rb | 4 +- .../fetch_remote_status_service_spec.rb | 2 +- .../activitypub/process_account_service_spec.rb | 4 +- .../activitypub/process_collection_service_spec.rb | 12 +- .../process_status_update_service_spec.rb | 42 ++-- spec/services/bootstrap_timeline_service_spec.rb | 1 - spec/services/fetch_oembed_service_spec.rb | 1 - spec/services/import_service_spec.rb | 4 +- spec/services/remove_from_follwers_service_spec.rb | 2 +- spec/services/remove_status_service_spec.rb | 68 ++--- spec/services/resolve_account_service_spec.rb | 2 +- spec/services/resolve_url_service_spec.rb | 2 +- spec/services/update_status_service_spec.rb | 2 +- spec/support/stories/profile_stories.rb | 4 +- spec/validators/note_length_validator_spec.rb | 4 +- .../unreserved_username_validator_spec.rb | 6 +- .../activitypub/distribution_worker_spec.rb | 2 +- .../activitypub/move_distribution_worker_spec.rb | 8 +- .../accounts_statuses_cleanup_scheduler_spec.rb | 2 +- 71 files changed, 269 insertions(+), 566 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e3a42da5b..e24ce7e32 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit` -# on 2023-02-16 04:55:24 UTC using RuboCop version 1.45.1. +# on 2023-02-16 05:53:07 UTC using RuboCop version 1.45.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,53 +14,6 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingParenthesisIndentation: - Exclude: - - 'spec/controllers/auth/sessions_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Exclude: - - 'db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'lib/paperclip/attachment_extensions.rb' - - 'spec/routing/api_routing_spec.rb' - - 'spec/routing/well_known_routes_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ElseAlignment: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - # Offense count: 81 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: @@ -183,73 +136,6 @@ Layout/EmptyLineAfterMagicComment: - 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' - 'spec/models/tag_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Exclude: - - 'spec/controllers/authorize_interactions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'spec/fabricators/system_key_fabricator.rb' - - 'spec/models/account_alias_spec.rb' - - 'spec/models/device_spec.rb' - - 'spec/models/encrypted_message_spec.rb' - - 'spec/models/login_activity_spec.rb' - - 'spec/models/one_time_key_spec.rb' - - 'spec/models/system_key_spec.rb' - - 'spec/services/bootstrap_timeline_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/config/initializers/rack_attack_spec.rb' - - 'spec/controllers/api/v2/filters/statuses_controller_spec.rb' - - 'spec/fabricators/custom_filter_keyword_fabricator.rb' - - 'spec/fabricators/poll_vote_fabricator.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/import_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/services/resolve_url_service_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - - 'spec/validators/unreserved_username_validator_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'spec/services/remove_status_service_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/FirstArrayElementIndentation: - Exclude: - - 'spec/controllers/admin/dashboard_controller_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - # Offense count: 113 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -276,49 +162,6 @@ Layout/HashAlignment: - 'spec/models/admin/account_action_spec.rb' - 'spec/models/concerns/account_interactions_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/HeredocIndentation: - Exclude: - - 'spec/controllers/well_known/host_meta_controller_spec.rb' - - 'spec/lib/link_details_extractor_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, indented_internal_methods -Layout/IndentationConsistency: - Exclude: - - 'spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/services/import_service_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/services/account_statuses_cleanup_service_spec.rb' - - 'spec/services/import_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Exclude: - - 'lib/paperclip/attachment_extensions.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: space, no_space -Layout/LineContinuationSpacing: - Exclude: - - 'spec/support/stories/profile_stories.rb' - # Offense count: 577 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. @@ -326,124 +169,6 @@ Layout/LineContinuationSpacing: Layout/LineLength: Enabled: false -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. -# SupportedStylesForExponentOperator: space, no_space -Layout/SpaceAroundOperators: - Exclude: - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'spec/controllers/api/v1/reports_controller_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/fabricators/custom_filter_keyword_fabricator.rb' - - 'spec/fabricators/poll_vote_fabricator.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/lib/extractor_spec.rb' - - 'spec/models/export_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'spec/lib/fast_ip_map_spec.rb' - - 'spec/models/user_role_spec.rb' - - 'spec/serializers/rest/account_serializer_spec.rb' - - 'spec/workers/activitypub/distribution_worker_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/lib/activitypub/activity/create.rb' - - 'app/services/activitypub/fetch_replies_service.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/update_status_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Exclude: - - 'spec/validators/unreserved_username_validator_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'spec/controllers/auth/sessions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'db/migrate/20190306145741_add_lock_version_to_polls.rb' - - 'db/migrate/20190807135426_add_comments_to_domain_blocks.rb' - - 'db/migrate/20200312162302_add_status_ids_to_announcements.rb' - - 'db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb' - - 'db/migrate/20200628133322_create_account_notes.rb' - - 'db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb' - - 'spec/fabricators/ip_block_fabricator.rb' - - 'spec/fabricators/status_edit_fabricator.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/models/concerns/expireable.rb' - - 'db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb' - - 'lib/tasks/mastodon.rake' - - 'spec/models/account/field_spec.rb' - - 'spec/services/remove_from_follwers_service_spec.rb' - # Offense count: 14 # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 487b65223..f82112c02 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -327,7 +327,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity def resolve_thread(status) return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri) - ThreadResolveWorker.perform_async(status.id, in_reply_to_uri, { 'request_id' => @options[:request_id]}) + ThreadResolveWorker.perform_async(status.id, in_reply_to_uri, { 'request_id' => @options[:request_id] }) end def fetch_replies(status) @@ -338,7 +338,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return unless replies.nil? uri = value_or_id(collection) - ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id]}) unless uri.nil? + ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id] }) unless uri.nil? end def conversation_from_uri(uri) diff --git a/app/models/concerns/expireable.rb b/app/models/concerns/expireable.rb index 4d902abcb..c64fc7d80 100644 --- a/app/models/concerns/expireable.rb +++ b/app/models/concerns/expireable.rb @@ -17,7 +17,7 @@ module Expireable end def expires_in=(interval) - self.expires_at = interval.present? ? interval.to_i.seconds.from_now : nil + self.expires_at = interval.present? ? interval.to_i.seconds.from_now : nil @expires_in = interval end diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 18a27e851..4128df9ca 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -10,7 +10,7 @@ class ActivityPub::FetchRepliesService < BaseService @items = collection_items(collection_or_uri) return if @items.nil? - FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id}] } + FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id }] } @items end diff --git a/db/migrate/20161006213403_rails_settings_migration.rb b/db/migrate/20161006213403_rails_settings_migration.rb index 9d565cb5c..02932610c 100644 --- a/db/migrate/20161006213403_rails_settings_migration.rb +++ b/db/migrate/20161006213403_rails_settings_migration.rb @@ -1,8 +1,8 @@ MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5 - ActiveRecord::Migration[5.0] -else - ActiveRecord::Migration[4.2] -end + ActiveRecord::Migration[5.0] + else + ActiveRecord::Migration[4.2] + end class RailsSettingsMigration < MIGRATION_BASE_CLASS def self.up @@ -12,7 +12,7 @@ class RailsSettingsMigration < MIGRATION_BASE_CLASS t.references :target, null: false, polymorphic: true, index: { name: 'index_settings_on_target_type_and_target_id' } t.timestamps null: true end - add_index :settings, [ :target_type, :target_id, :var ], unique: true + add_index :settings, [:target_type, :target_id, :var], unique: true end def self.down diff --git a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb index b29e62803..a3f883fcb 100644 --- a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -4,9 +4,9 @@ class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Mi disable_ddl_transaction! def change - # These changes ware reverted by migration 20180514140000. - # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently - # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently - # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 + # These changes ware reverted by migration 20180514140000. + # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently + # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently + # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 end end diff --git a/db/migrate/20190306145741_add_lock_version_to_polls.rb b/db/migrate/20190306145741_add_lock_version_to_polls.rb index 5bb8cd3b4..c9fa471ad 100644 --- a/db/migrate/20190306145741_add_lock_version_to_polls.rb +++ b/db/migrate/20190306145741_add_lock_version_to_polls.rb @@ -21,4 +21,3 @@ class AddLockVersionToPolls < ActiveRecord::Migration[5.2] remove_column :polls, :lock_version end end - diff --git a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb index b660a71ad..79b9f0212 100644 --- a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb +++ b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb @@ -4,4 +4,3 @@ class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2] add_column :domain_blocks, :public_comment, :text end end - diff --git a/db/migrate/20200312162302_add_status_ids_to_announcements.rb b/db/migrate/20200312162302_add_status_ids_to_announcements.rb index 42aa6513d..704d3773e 100644 --- a/db/migrate/20200312162302_add_status_ids_to_announcements.rb +++ b/db/migrate/20200312162302_add_status_ids_to_announcements.rb @@ -3,4 +3,3 @@ class AddStatusIdsToAnnouncements < ActiveRecord::Migration[5.2] add_column :announcements, :status_ids, :bigint, array: true end end - diff --git a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb index 1d6ba1fe9..59bb1b9e2 100644 --- a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb +++ b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb @@ -19,4 +19,3 @@ class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2] add_index :markers, :user_id, name: :index_markers_on_user_id unless index_exists?(:markers, :user_id, name: :index_markers_on_user_id) end end - diff --git a/db/migrate/20200628133322_create_account_notes.rb b/db/migrate/20200628133322_create_account_notes.rb index 664727e60..022e0ff3a 100644 --- a/db/migrate/20200628133322_create_account_notes.rb +++ b/db/migrate/20200628133322_create_account_notes.rb @@ -10,4 +10,3 @@ class CreateAccountNotes < ActiveRecord::Migration[5.2] end end end - diff --git a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb index 28cfb6ef5..db168676a 100644 --- a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb +++ b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb @@ -17,4 +17,3 @@ class CreateAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1] end end end - diff --git a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb index 7ed34a3ef..eb437c86c 100644 --- a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb +++ b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb @@ -5,7 +5,7 @@ class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1] def up # 20220613110711 manually inserts items with set `id` in the database, but - # we also need to bump the sequence number, otherwise + # we also need to bump the sequence number, otherwise safety_assured do execute <<-SQL.squish BEGIN; diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb index d66a17623..7f82138aa 100644 --- a/lib/paperclip/attachment_extensions.rb +++ b/lib/paperclip/attachment_extensions.rb @@ -8,7 +8,7 @@ module Paperclip # monkey-patch to avoid unlinking too avoid unlinking source file too early # see https://github.com/kreeti/kt-paperclip/issues/64 - def post_process_style(name, style) #:nodoc: + def post_process_style(name, style) # :nodoc: raise "Style #{name} has no processors defined." if style.processors.blank? intermediate_files = [] @@ -16,16 +16,16 @@ module Paperclip # if we're processing the original, close + unlink the source tempfile intermediate_files << original if name == :original - @queued_for_write[name] = style.processors. - inject(original) do |file, processor| + @queued_for_write[name] = style.processors + .inject(original) do |file, processor| file = Paperclip.processor(processor).make(file, style.processor_options, self) intermediate_files << file unless file == original file end unadapted_file = @queued_for_write[name] - @queued_for_write[name] = Paperclip.io_adapters. - for(@queued_for_write[name], @options[:adapter_options]) + @queued_for_write[name] = Paperclip.io_adapters + .for(@queued_for_write[name], @options[:adapter_options]) unadapted_file.close if unadapted_file.respond_to?(:close) @queued_for_write[name] rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 1184e5273..477daa01b 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -286,13 +286,13 @@ namespace :mastodon do q.required true q.modify :strip end - + linksharing_access_key = prompt.ask('Storj Linksharing access key (uplink share --register --public --readonly=true --disallow-lists --not-after=none sj://bucket):') do |q| q.required true q.modify :strip end env['S3_ALIAS_HOST'] = "link.storjshare.io/raw/#{linksharing_access_key}/#{env['S3_BUCKET']}" - + when 'Google Cloud Storage' env['S3_ENABLED'] = 'true' env['S3_PROTOCOL'] = 'https' diff --git a/spec/config/initializers/rack_attack_spec.rb b/spec/config/initializers/rack_attack_spec.rb index 581021cb9..03695f5fd 100644 --- a/spec/config/initializers/rack_attack_spec.rb +++ b/spec/config/initializers/rack_attack_spec.rb @@ -35,12 +35,12 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/auth' } + let(:path) { '/auth' } it_behaves_like 'throttled endpoint' end context 'for path with format' do - let(:path) { '/auth.html' } + let(:path) { '/auth.html' } it_behaves_like 'throttled endpoint' end end @@ -50,7 +50,7 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/api/v1/accounts' } + let(:path) { '/api/v1/accounts' } it_behaves_like 'throttled endpoint' end @@ -70,12 +70,12 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/auth/sign_in' } + let(:path) { '/auth/sign_in' } it_behaves_like 'throttled endpoint' end context 'for path with format' do - let(:path) { '/auth/sign_in.html' } + let(:path) { '/auth/sign_in.html' } it_behaves_like 'throttled endpoint' end end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 6231a09a2..ab3738fcd 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -8,10 +8,10 @@ describe Admin::DashboardController, type: :controller do describe 'GET #index' do before do allow(Admin::SystemCheck).to receive(:perform).and_return([ - Admin::SystemCheck::Message.new(:database_schema_check), - Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), - Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), - ]) + Admin::SystemCheck::Message.new(:database_schema_check), + Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), + Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), + ]) sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index b2557d957..89cc8acad 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -70,7 +70,7 @@ describe Api::V1::Accounts::CredentialsController do it 'returns http success' do expect(response).to have_http_status(200) end - end + end describe 'with invalid data' do before do diff --git a/spec/controllers/api/v1/reports_controller_spec.rb b/spec/controllers/api/v1/reports_controller_spec.rb index dbc64e704..78a72b95b 100644 --- a/spec/controllers/api/v1/reports_controller_spec.rb +++ b/spec/controllers/api/v1/reports_controller_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do let(:target_account) { status.account } let(:category) { nil } let(:forward) { nil } - let(:rule_ids){ nil } + let(:rule_ids) { nil } before do allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil)) diff --git a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb index 7cc77f430..4dcaba6bd 100644 --- a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control it 'returns accounts who favorited the status' do get :index, params: { status_id: status.id, limit: 2 } expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) + expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) end it 'does not return blocked users' do diff --git a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb index 8d4a6f91c..dc36d4ca0 100644 --- a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll it 'returns accounts who reblogged the status' do get :index, params: { status_id: status.id, limit: 2 } expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) + expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) end it 'does not return blocked users' do diff --git a/spec/controllers/api/v2/filters/statuses_controller_spec.rb b/spec/controllers/api/v2/filters/statuses_controller_spec.rb index 9740c1eb3..969b2ea73 100644 --- a/spec/controllers/api/v2/filters/statuses_controller_spec.rb +++ b/spec/controllers/api/v2/filters/statuses_controller_spec.rb @@ -64,7 +64,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do end describe 'GET #show' do - let(:scopes) { 'read:filters' } + let(:scopes) { 'read:filters' } let!(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } before do @@ -90,7 +90,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do end describe 'DELETE #destroy' do - let(:scopes) { 'write:filters' } + let(:scopes) { 'write:filters' } let(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } before do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index d3db7aa1a..64433ddf4 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -339,11 +339,11 @@ RSpec.describe Auth::SessionsController, type: :controller do external_id: public_key_credential.id, public_key: public_key_credential.public_key, sign_count: '1000' - ) + ) user.webauthn_credentials.take end - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } @@ -400,7 +400,7 @@ RSpec.describe Auth::SessionsController, type: :controller do describe 'GET #webauthn_options' do context 'with WebAuthn and OTP enabled as second factor' do - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } diff --git a/spec/controllers/authorize_interactions_controller_spec.rb b/spec/controllers/authorize_interactions_controller_spec.rb index 44f52df69..e52103941 100644 --- a/spec/controllers/authorize_interactions_controller_spec.rb +++ b/spec/controllers/authorize_interactions_controller_spec.rb @@ -99,7 +99,6 @@ describe AuthorizeInteractionsController do allow(ResolveAccountService).to receive(:new).and_return(service) allow(service).to receive(:call).with('user@hostname').and_return(target_account) - post :create, params: { acct: 'acct:user@hostname' } expect(account.following?(target_account)).to be true diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 1292e9ff8..9074574e4 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -73,7 +73,7 @@ describe Settings::ApplicationsController do name: 'My New App', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', website: 'http://google.com', - scopes: [ 'read', 'write', 'follow' ] + scopes: ['read', 'write', 'follow'] } } response diff --git a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb index 569c8322b..0b807b280 100644 --- a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb @@ -5,7 +5,6 @@ require 'rails_helper' describe Settings::TwoFactorAuthentication::ConfirmationsController do render_views - shared_examples 'renders :new' do it 'renders the new view' do subject diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb index fe53b4dfc..06989ffd2 100644 --- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb @@ -7,7 +7,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do render_views let(:user) { Fabricate(:user) } - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } def add_webauthn_credential(user) diff --git a/spec/controllers/well_known/host_meta_controller_spec.rb b/spec/controllers/well_known/host_meta_controller_spec.rb index c02aa0d59..654bad406 100644 --- a/spec/controllers/well_known/host_meta_controller_spec.rb +++ b/spec/controllers/well_known/host_meta_controller_spec.rb @@ -9,12 +9,12 @@ describe WellKnown::HostMetaController, type: :controller do expect(response).to have_http_status(200) expect(response.media_type).to eq 'application/xrd+xml' - expect(response.body).to eq < - - - -XML + expect(response.body).to eq <<~XML + + + + + XML end end end diff --git a/spec/fabricators/custom_filter_keyword_fabricator.rb b/spec/fabricators/custom_filter_keyword_fabricator.rb index 0f101dcd1..201566cbe 100644 --- a/spec/fabricators/custom_filter_keyword_fabricator.rb +++ b/spec/fabricators/custom_filter_keyword_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:custom_filter_keyword) do custom_filter - keyword 'discourse' + keyword 'discourse' end diff --git a/spec/fabricators/ip_block_fabricator.rb b/spec/fabricators/ip_block_fabricator.rb index 31dc336e6..1797f6877 100644 --- a/spec/fabricators/ip_block_fabricator.rb +++ b/spec/fabricators/ip_block_fabricator.rb @@ -3,4 +3,4 @@ Fabricator(:ip_block) do severity "" expires_at "2020-10-08 22:20:37" comment "MyText" -end \ No newline at end of file +end diff --git a/spec/fabricators/poll_vote_fabricator.rb b/spec/fabricators/poll_vote_fabricator.rb index 51f9b006e..c06e61f67 100644 --- a/spec/fabricators/poll_vote_fabricator.rb +++ b/spec/fabricators/poll_vote_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:poll_vote) do account poll - choice 0 + choice 0 end diff --git a/spec/fabricators/status_edit_fabricator.rb b/spec/fabricators/status_edit_fabricator.rb index 21b793747..3141759e5 100644 --- a/spec/fabricators/status_edit_fabricator.rb +++ b/spec/fabricators/status_edit_fabricator.rb @@ -4,4 +4,4 @@ Fabricator(:status_edit) do text "MyText" spoiler_text "MyText" media_attachments_changed false -end \ No newline at end of file +end diff --git a/spec/fabricators/system_key_fabricator.rb b/spec/fabricators/system_key_fabricator.rb index f808495e0..c744bb286 100644 --- a/spec/fabricators/system_key_fabricator.rb +++ b/spec/fabricators/system_key_fabricator.rb @@ -1,3 +1,2 @@ Fabricator(:system_key) do - end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 1a25395fa..cd0f2df6e 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -408,7 +408,6 @@ RSpec.describe ActivityPub::Activity::Create do end end - context 'with media attachments with long description' do let(:object_json) do { diff --git a/spec/lib/extractor_spec.rb b/spec/lib/extractor_spec.rb index dba4bd0bb..9c9f5ef04 100644 --- a/spec/lib/extractor_spec.rb +++ b/spec/lib/extractor_spec.rb @@ -20,7 +20,7 @@ describe Extractor do text = '@screen_name' extracted = Extractor.extract_mentions_or_lists_with_indices(text) expect(extracted).to eq [ - { screen_name: 'screen_name', indices: [ 0, 12 ] } + { screen_name: 'screen_name', indices: [0, 12] } ] end @@ -44,19 +44,19 @@ describe Extractor do it 'does not exclude normal hash text before ://' do text = '#hashtag://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'excludes http://' do text = '#hashtaghttp://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'excludes https://' do text = '#hashtaghttps://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'yields hashtags if a block is given' do diff --git a/spec/lib/fast_ip_map_spec.rb b/spec/lib/fast_ip_map_spec.rb index c66f64828..78b3ddb05 100644 --- a/spec/lib/fast_ip_map_spec.rb +++ b/spec/lib/fast_ip_map_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' describe FastIpMap do describe '#include?' do - subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')])} + subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')]) } it 'returns true for an exact match' do expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb index 7ea867c61..7eb15ced3 100644 --- a/spec/lib/link_details_extractor_spec.rb +++ b/spec/lib/link_details_extractor_spec.rb @@ -39,17 +39,17 @@ RSpec.describe LinkDetailsExtractor do let(:original_url) { 'https://example.com/page.html' } context 'and is wrapped in CDATA tags' do - let(:html) { <<-HTML } - - - - - - + let(:html) { <<~HTML } + + + + + + HTML describe '#title' do @@ -78,57 +78,57 @@ RSpec.describe LinkDetailsExtractor do end context 'but the first tag is invalid JSON' do - let(:html) { <<-HTML } - - - - - - - + let(:html) { <<~HTML } + + + + + + + HTML describe '#title' do diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index 0ac9769bc..40bbee025 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -97,7 +97,7 @@ RSpec.describe Account::Field, type: :model do expect(subject.verifiable?).to be false end end - + context 'for text which is blank' do let(:value) { '' } @@ -149,7 +149,7 @@ RSpec.describe Account::Field, type: :model do expect(subject.verifiable?).to be false end end - + context 'for text which is blank' do let(:value) { '' } diff --git a/spec/models/account_alias_spec.rb b/spec/models/account_alias_spec.rb index 27ec215aa..c48b804b2 100644 --- a/spec/models/account_alias_spec.rb +++ b/spec/models/account_alias_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe AccountAlias, type: :model do - end diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index 684a1aa41..f11684516 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -16,16 +16,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do context 'when widening a policy' do let!(:account_statuses_cleanup_policy) do Fabricate(:account_statuses_cleanup_policy, - account: account, - keep_direct: true, - keep_pinned: true, - keep_polls: true, - keep_media: true, - keep_self_fav: true, - keep_self_bookmark: true, - min_favs: 1, - min_reblogs: 1 - ) + account: account, + keep_direct: true, + keep_pinned: true, + keep_polls: true, + keep_media: true, + keep_self_fav: true, + keep_self_bookmark: true, + min_favs: 1, + min_reblogs: 1) end before do @@ -96,16 +95,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do context 'when narrowing a policy' do let!(:account_statuses_cleanup_policy) do Fabricate(:account_statuses_cleanup_policy, - account: account, - keep_direct: false, - keep_pinned: false, - keep_polls: false, - keep_media: false, - keep_self_fav: false, - keep_self_bookmark: false, - min_favs: nil, - min_reblogs: nil - ) + account: account, + keep_direct: false, + keep_pinned: false, + keep_polls: false, + keep_media: false, + keep_self_fav: false, + keep_self_bookmark: false, + min_favs: nil, + min_reblogs: nil) end it 'does not unnecessarily invalidate last_inspected' do @@ -232,7 +230,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#compute_cutoff_id' do - let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } + let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } subject { account_statuses_cleanup_policy.compute_cutoff_id } diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 5cb4a83f7..e628384d0 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -400,7 +400,7 @@ describe AccountInteractions do subject { account.domain_blocking?(domain) } context 'blocking the domain' do - it' returns true' do + it ' returns true' do account_domain_block = Fabricate(:account_domain_block, domain: domain) account.domain_blocks << account_domain_block is_expected.to be true diff --git a/spec/models/device_spec.rb b/spec/models/device_spec.rb index f56fbf978..307552e91 100644 --- a/spec/models/device_spec.rb +++ b/spec/models/device_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe Device, type: :model do - end diff --git a/spec/models/encrypted_message_spec.rb b/spec/models/encrypted_message_spec.rb index 1238d57b6..64f9c6912 100644 --- a/spec/models/encrypted_message_spec.rb +++ b/spec/models/encrypted_message_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe EncryptedMessage, type: :model do - end diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 135d7a36b..5202ae9e1 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Export do let(:account) { Fabricate(:account) } let(:target_accounts) do - [ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account)) + [{}, { username: 'one', domain: 'local.host' }].map(&method(:Fabricate).curry(2).call(:account)) end describe 'to_csv' do diff --git a/spec/models/login_activity_spec.rb b/spec/models/login_activity_spec.rb index ba2d207c9..12d8c4363 100644 --- a/spec/models/login_activity_spec.rb +++ b/spec/models/login_activity_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe LoginActivity, type: :model do - end diff --git a/spec/models/one_time_key_spec.rb b/spec/models/one_time_key_spec.rb index 34598334c..4b231c600 100644 --- a/spec/models/one_time_key_spec.rb +++ b/spec/models/one_time_key_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe OneTimeKey, type: :model do - end diff --git a/spec/models/system_key_spec.rb b/spec/models/system_key_spec.rb index a138bc131..86f07f964 100644 --- a/spec/models/system_key_spec.rb +++ b/spec/models/system_key_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe SystemKey, type: :model do - end diff --git a/spec/models/trends/statuses_spec.rb b/spec/models/trends/statuses_spec.rb index 5f338a65e..98a8c7264 100644 --- a/spec/models/trends/statuses_spec.rb +++ b/spec/models/trends/statuses_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Trends::Statuses do before do 13.times { reblog(status1, today) } 13.times { reblog(status2, today) } - 4.times { reblog(status3, today) } + 4.times { reblog(status3, today) } end context do diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 28019593e..abf7d0e27 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -58,7 +58,7 @@ RSpec.describe UserRole, type: :model do end describe '#permissions_as_keys=' do - let(:input) { } + let(:input) {} before do subject.permissions_as_keys = input diff --git a/spec/routing/api_routing_spec.rb b/spec/routing/api_routing_spec.rb index 2683ccb8d..a822fba4c 100644 --- a/spec/routing/api_routing_spec.rb +++ b/spec/routing/api_routing_spec.rb @@ -5,99 +5,99 @@ require 'rails_helper' describe 'API routes' do describe 'Credentials routes' do it 'routes to verify credentials' do - expect(get('/api/v1/accounts/verify_credentials')). - to route_to('api/v1/accounts/credentials#show') + expect(get('/api/v1/accounts/verify_credentials')) + .to route_to('api/v1/accounts/credentials#show') end it 'routes to update credentials' do - expect(patch('/api/v1/accounts/update_credentials')). - to route_to('api/v1/accounts/credentials#update') + expect(patch('/api/v1/accounts/update_credentials')) + .to route_to('api/v1/accounts/credentials#update') end end describe 'Account routes' do it 'routes to statuses' do - expect(get('/api/v1/accounts/user/statuses')). - to route_to('api/v1/accounts/statuses#index', account_id: 'user') + expect(get('/api/v1/accounts/user/statuses')) + .to route_to('api/v1/accounts/statuses#index', account_id: 'user') end it 'routes to followers' do - expect(get('/api/v1/accounts/user/followers')). - to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') + expect(get('/api/v1/accounts/user/followers')) + .to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') end it 'routes to following' do - expect(get('/api/v1/accounts/user/following')). - to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') + expect(get('/api/v1/accounts/user/following')) + .to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') end it 'routes to search' do - expect(get('/api/v1/accounts/search')). - to route_to('api/v1/accounts/search#show') + expect(get('/api/v1/accounts/search')) + .to route_to('api/v1/accounts/search#show') end it 'routes to relationships' do - expect(get('/api/v1/accounts/relationships')). - to route_to('api/v1/accounts/relationships#index') + expect(get('/api/v1/accounts/relationships')) + .to route_to('api/v1/accounts/relationships#index') end end describe 'Statuses routes' do it 'routes reblogged_by' do - expect(get('/api/v1/statuses/123/reblogged_by')). - to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') + expect(get('/api/v1/statuses/123/reblogged_by')) + .to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') end it 'routes favourited_by' do - expect(get('/api/v1/statuses/123/favourited_by')). - to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') + expect(get('/api/v1/statuses/123/favourited_by')) + .to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') end it 'routes reblog' do - expect(post('/api/v1/statuses/123/reblog')). - to route_to('api/v1/statuses/reblogs#create', status_id: '123') + expect(post('/api/v1/statuses/123/reblog')) + .to route_to('api/v1/statuses/reblogs#create', status_id: '123') end it 'routes unreblog' do - expect(post('/api/v1/statuses/123/unreblog')). - to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unreblog')) + .to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') end it 'routes favourite' do - expect(post('/api/v1/statuses/123/favourite')). - to route_to('api/v1/statuses/favourites#create', status_id: '123') + expect(post('/api/v1/statuses/123/favourite')) + .to route_to('api/v1/statuses/favourites#create', status_id: '123') end it 'routes unfavourite' do - expect(post('/api/v1/statuses/123/unfavourite')). - to route_to('api/v1/statuses/favourites#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unfavourite')) + .to route_to('api/v1/statuses/favourites#destroy', status_id: '123') end it 'routes mute' do - expect(post('/api/v1/statuses/123/mute')). - to route_to('api/v1/statuses/mutes#create', status_id: '123') + expect(post('/api/v1/statuses/123/mute')) + .to route_to('api/v1/statuses/mutes#create', status_id: '123') end it 'routes unmute' do - expect(post('/api/v1/statuses/123/unmute')). - to route_to('api/v1/statuses/mutes#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unmute')) + .to route_to('api/v1/statuses/mutes#destroy', status_id: '123') end end describe 'Timeline routes' do it 'routes to home timeline' do - expect(get('/api/v1/timelines/home')). - to route_to('api/v1/timelines/home#show') + expect(get('/api/v1/timelines/home')) + .to route_to('api/v1/timelines/home#show') end it 'routes to public timeline' do - expect(get('/api/v1/timelines/public')). - to route_to('api/v1/timelines/public#show') + expect(get('/api/v1/timelines/public')) + .to route_to('api/v1/timelines/public#show') end it 'routes to tag timeline' do - expect(get('/api/v1/timelines/tag/test')). - to route_to('api/v1/timelines/tag#show', id: 'test') + expect(get('/api/v1/timelines/tag/test')) + .to route_to('api/v1/timelines/tag#show', id: 'test') end end end diff --git a/spec/routing/well_known_routes_spec.rb b/spec/routing/well_known_routes_spec.rb index 2e25605c2..03a562843 100644 --- a/spec/routing/well_known_routes_spec.rb +++ b/spec/routing/well_known_routes_spec.rb @@ -2,14 +2,14 @@ require 'rails_helper' describe 'the host-meta route' do it 'routes to correct place with xml format' do - expect(get('/.well-known/host-meta')). - to route_to('well_known/host_meta#show', format: 'xml') + expect(get('/.well-known/host-meta')) + .to route_to('well_known/host_meta#show', format: 'xml') end end describe 'the webfinger route' do it 'routes to correct place with json format' do - expect(get('/.well-known/webfinger')). - to route_to('well_known/webfinger#show') + expect(get('/.well-known/webfinger')) + .to route_to('well_known/webfinger#show') end end diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index 5b08d5aca..3bca06b73 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' describe REST::AccountSerializer do let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } let(:user) { Fabricate(:user, role: role) } - let(:account) { user.account} + let(:account) { user.account } subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } diff --git a/spec/services/account_statuses_cleanup_service_spec.rb b/spec/services/account_statuses_cleanup_service_spec.rb index 257655c41..a30e14ab6 100644 --- a/spec/services/account_statuses_cleanup_service_spec.rb +++ b/spec/services/account_statuses_cleanup_service_spec.rb @@ -42,8 +42,8 @@ describe AccountStatusesCleanupService, type: :service do context 'when called repeatedly with a budget of 2' do it 'reports 2 then 1 deleted statuses' do - expect(subject.call(account_policy, 2)).to eq 2 - expect(subject.call(account_policy, 2)).to eq 1 + expect(subject.call(account_policy, 2)).to eq 2 + expect(subject.call(account_policy, 2)).to eq 1 end it 'actually deletes the statuses in the expected order' do diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index a81dcad81..d6145c9b8 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -298,7 +298,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do first: { type: 'CollectionPage', partOf: "https://foo.bar/@foo/#{i}/replies", - items: ["https://foo.bar/@foo/#{i+1}"], + items: ["https://foo.bar/@foo/#{i + 1}"], }, }, attributedTo: ActivityPub::TagManager.instance.uri_for(sender), diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 2b20d17b1..40caa6eb0 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -172,10 +172,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do { type: 'Mention', href: "https://foo.test/users/#{i + 1}", - name: "@user#{i + 1 }", + name: "@user#{i + 1}", } ], - to: [ 'as:Public', "https://foo.test/users/#{i + 1}" ] + to: ['as:Public', "https://foo.test/users/#{i + 1}"] }.with_indifferent_access featured_json = { '@context': ['https://www.w3.org/ns/activitystreams'], diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index a308cede7..cb60e1cb8 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -95,11 +95,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do context 'when receiving a fabricated status' do let!(:actor) do Fabricate(:account, - username: 'bob', - domain: 'example.com', - uri: 'https://example.com/users/bob', - public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", - private_key: nil) + username: 'bob', + domain: 'example.com', + uri: 'https://example.com/users/bob', + public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", + private_key: nil) end let(:payload) do @@ -107,7 +107,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do '@context': [ 'https://www.w3.org/ns/activitystreams', nil, - {'object': 'https://www.w3.org/ns/activitystreams#object'} + { 'object': 'https://www.w3.org/ns/activitystreams#object' } ], 'id': 'https://example.com/users/bob/fake-status/activity', 'type': 'Create', diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 750369d57..04292c507 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -104,20 +104,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end context 'when the status has not been explicitly edited and features a poll' do - let(:account) { Fabricate(:account, domain: 'example.com') } + let(:account) { Fabricate(:account, domain: 'example.com') } let!(:expiration) { 10.days.from_now.utc } let!(:status) do Fabricate(:status, - text: 'Hello world', - account: account, - poll_attributes: { - options: %w(Foo Bar), - account: account, - multiple: false, - hide_totals: false, - expires_at: expiration - } - ) + text: 'Hello world', + account: account, + poll_attributes: { + options: %w(Foo Bar), + account: account, + multiple: false, + hide_totals: false, + expires_at: expiration + }) end let(:payload) do @@ -156,20 +155,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end context 'when the status changes a poll despite being not explicitly marked as updated' do - let(:account) { Fabricate(:account, domain: 'example.com') } + let(:account) { Fabricate(:account, domain: 'example.com') } let!(:expiration) { 10.days.from_now.utc } let!(:status) do Fabricate(:status, - text: 'Hello world', - account: account, - poll_attributes: { - options: %w(Foo Bar), - account: account, - multiple: false, - hide_totals: false, - expires_at: expiration - } - ) + text: 'Hello world', + account: account, + poll_attributes: { + options: %w(Foo Bar), + account: account, + multiple: false, + hide_totals: false, + expires_at: expiration + }) end let(:payload) do diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb index 16f3e9962..149f6e6df 100644 --- a/spec/services/bootstrap_timeline_service_spec.rb +++ b/spec/services/bootstrap_timeline_service_spec.rb @@ -32,6 +32,5 @@ RSpec.describe BootstrapTimelineService, type: :service do expect(service).to_not have_received(:call) end end - end end diff --git a/spec/services/fetch_oembed_service_spec.rb b/spec/services/fetch_oembed_service_spec.rb index 88f0113ed..da2a8d0d1 100644 --- a/spec/services/fetch_oembed_service_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -151,7 +151,6 @@ describe FetchOEmbedService, type: :service do expect(subject.format).to eq :json end end - end context 'when endpoint is cached' do diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index e2d182920..217d0ee24 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -178,7 +178,7 @@ RSpec.describe ImportService, type: :service do context 'utf-8 encoded domains' do subject { ImportService.new } - let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } + let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } # Make sure to not actually go to the remote server before do @@ -189,7 +189,7 @@ RSpec.describe ImportService, type: :service do let(:import) { Import.create(account: account, type: 'following', data: csv) } it 'follows the listed account' do - expect(account.follow_requests.count).to eq 0 + expect(account.follow_requests.count).to eq 0 subject.call(import) expect(account.follow_requests.count).to eq 1 end diff --git a/spec/services/remove_from_follwers_service_spec.rb b/spec/services/remove_from_follwers_service_spec.rb index a83f6f49a..9b9c846cf 100644 --- a/spec/services/remove_from_follwers_service_spec.rb +++ b/spec/services/remove_from_follwers_service_spec.rb @@ -7,7 +7,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do describe 'local' do let(:sender) { Fabricate(:account, username: 'alice') } - + before do Follow.create(account: sender, target_account: bob) subject.call(bob, sender) diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index 482068d58..e253052f3 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -37,29 +37,29 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Delete activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Delete', - 'object' => { - 'type' => 'Tombstone', - 'id' => ActivityPub::TagManager.instance.uri_for(@status), - 'atomUri' => OStatus::TagManager.instance.uri_for(@status), - }, - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Delete', + 'object' => { + 'type' => 'Tombstone', + 'id' => ActivityPub::TagManager.instance.uri_for(@status), + 'atomUri' => OStatus::TagManager.instance.uri_for(@status), + }, + }) + )).to have_been_made.once end it 'sends Delete activity to rebloggers' do subject.call(@status) expect(a_request(:post, 'http://example2.com/inbox').with( - body: hash_including({ - 'type' => 'Delete', - 'object' => { - 'type' => 'Tombstone', - 'id' => ActivityPub::TagManager.instance.uri_for(@status), - 'atomUri' => OStatus::TagManager.instance.uri_for(@status), - }, - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Delete', + 'object' => { + 'type' => 'Tombstone', + 'id' => ActivityPub::TagManager.instance.uri_for(@status), + 'atomUri' => OStatus::TagManager.instance.uri_for(@status), + }, + }) + )).to have_been_made.once end it 'remove status from notifications' do @@ -78,14 +78,14 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Undo activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Undo', - 'object' => hash_including({ - 'type' => 'Announce', - 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), - }), - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Undo', + 'object' => hash_including({ + 'type' => 'Announce', + 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), + }), + }) + )).to have_been_made.once end end @@ -98,14 +98,14 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Undo activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Undo', - 'object' => hash_including({ - 'type' => 'Announce', - 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), - }), - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Undo', + 'object' => hash_including({ + 'type' => 'Announce', + 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), + }), + }) + )).to have_been_made.once end end end diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 654606bea..1df30ea57 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -190,7 +190,7 @@ RSpec.describe ResolveAccountService, type: :service do context 'with an already-known acct: URI changing ActivityPub id' do let!(:old_account) { Fabricate(:account, username: 'foo', domain: 'ap.example.com', uri: 'https://old.example.com/users/foo', last_webfingered_at: nil) } - let!(:status) { Fabricate(:status, account: old_account, text: 'foo') } + let!(:status) { Fabricate(:status, account: old_account, text: 'foo') } it 'returns new remote account' do account = subject.call('foo@ap.example.com') diff --git a/spec/services/resolve_url_service_spec.rb b/spec/services/resolve_url_service_spec.rb index b3e3defbf..3598311ee 100644 --- a/spec/services/resolve_url_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -133,7 +133,7 @@ describe ResolveURLService, type: :service do let!(:status) { Fabricate(:status, account: poster, visibility: :public) } let(:url) { 'https://link.to/foobar' } let(:status_url) { ActivityPub::TagManager.instance.url_for(status) } - let(:uri) { ActivityPub::TagManager.instance.uri_for(status) } + let(:uri) { ActivityPub::TagManager.instance.uri_for(status) } before do stub_request(:get, url).to_return(status: 302, headers: { 'Location' => status_url }) diff --git a/spec/services/update_status_service_spec.rb b/spec/services/update_status_service_spec.rb index 16e981d2b..a7364ca8b 100644 --- a/spec/services/update_status_service_spec.rb +++ b/spec/services/update_status_service_spec.rb @@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do context 'when poll changes' do let(:account) { Fabricate(:account) } - let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: {options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) } + let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: { options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) } let!(:poll) { status.poll } let!(:voter) { Fabricate(:account) } diff --git a/spec/support/stories/profile_stories.rb b/spec/support/stories/profile_stories.rb index 0c4a14d1c..de7ae17e6 100644 --- a/spec/support/stories/profile_stories.rb +++ b/spec/support/stories/profile_stories.rb @@ -20,8 +20,8 @@ module ProfileStories end def with_alice_as_local_user - @alice_bio = '@alice and @bob are fictional characters commonly used as'\ - 'placeholder names in #cryptology, as well as #science and'\ + @alice_bio = '@alice and @bob are fictional characters commonly used as' \ + 'placeholder names in #cryptology, as well as #science and' \ 'engineering 📖 literature. Not affiliated with @pepe.' @alice = Fabricate( diff --git a/spec/validators/note_length_validator_spec.rb b/spec/validators/note_length_validator_spec.rb index 6e9b4e132..390ac8d90 100644 --- a/spec/validators/note_length_validator_spec.rb +++ b/spec/validators/note_length_validator_spec.rb @@ -15,7 +15,7 @@ describe NoteLengthValidator do end it 'counts URLs as 23 characters flat' do - text = ('a' * 476) + " http://#{'b' * 30}.com/example" + text = ('a' * 476) + " http://#{'b' * 30}.com/example" account = double(note: text, errors: double(add: nil)) subject.validate_each(account, 'note', text) @@ -23,7 +23,7 @@ describe NoteLengthValidator do end it 'does not count non-autolinkable URLs as 23 characters flat' do - text = ('a' * 476) + "http://#{'b' * 30}.com/example" + text = ('a' * 476) + "http://#{'b' * 30}.com/example" account = double(note: text, errors: double(add: nil)) subject.validate_each(account, 'note', text) diff --git a/spec/validators/unreserved_username_validator_spec.rb b/spec/validators/unreserved_username_validator_spec.rb index 746b3866c..e2f051b08 100644 --- a/spec/validators/unreserved_username_validator_spec.rb +++ b/spec/validators/unreserved_username_validator_spec.rb @@ -11,10 +11,10 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:validator) { described_class.new } let(:account) { double(username: username, errors: errors) } - let(:errors ) { double(add: nil) } + let(:errors) { double(add: nil) } context '@username.blank?' do - let(:username) { nil } + let(:username) { nil } it 'not calls errors.add' do expect(errors).not_to have_received(:add).with(:username, any_args) @@ -22,7 +22,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do end context '!@username.blank?' do - let(:username) { 'f' } + let(:username) { 'f' } context 'reserved_username?' do let(:reserved_username) { true } diff --git a/spec/workers/activitypub/distribution_worker_spec.rb b/spec/workers/activitypub/distribution_worker_spec.rb index 3a5900d9b..7f63e197b 100644 --- a/spec/workers/activitypub/distribution_worker_spec.rb +++ b/spec/workers/activitypub/distribution_worker_spec.rb @@ -34,7 +34,7 @@ describe ActivityPub::DistributionWorker do end context 'with direct status' do - let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox')} + let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } before do status.update(visibility: :direct) diff --git a/spec/workers/activitypub/move_distribution_worker_spec.rb b/spec/workers/activitypub/move_distribution_worker_spec.rb index af8c44cc0..57941065a 100644 --- a/spec/workers/activitypub/move_distribution_worker_spec.rb +++ b/spec/workers/activitypub/move_distribution_worker_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe ActivityPub::MoveDistributionWorker do subject { described_class.new } - let(:migration) { Fabricate(:account_migration) } + let(:migration) { Fabricate(:account_migration) } let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') } let(:blocker) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example2.com') } @@ -15,9 +15,9 @@ describe ActivityPub::MoveDistributionWorker do it 'delivers to followers and known blockers' do expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [ - [kind_of(String), migration.account.id, 'http://example.com'], - [kind_of(String), migration.account.id, 'http://example2.com'] - ]) + [kind_of(String), migration.account.id, 'http://example.com'], + [kind_of(String), migration.account.id, 'http://example2.com'] + ]) subject.perform(migration.id) end end diff --git a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb index 8f20725c8..8faf04836 100644 --- a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb +++ b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb @@ -82,7 +82,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do describe '#get_budget' do context 'on a single thread' do - let(:process_set_stub) { [ { 'concurrency' => 1, 'queues' => ['push', 'default'] } ] } + let(:process_set_stub) { [{ 'concurrency' => 1, 'queues' => ['push', 'default'] }] } it 'returns a low value' do expect(subject.compute_budget).to be < 10 -- cgit From ac59d6f19f00f1503343cd587c4238dc0038127a Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 21:05:57 -0500 Subject: Enable Rubocop Style/NumericLiterals (#23647) --- .rubocop.yml | 4 ++++ .rubocop_todo.yml | 10 ---------- db/migrate/20180812173710_copy_status_stats.rb | 2 +- db/migrate/20181116173541_copy_account_stats.rb | 2 +- lib/mastodon/maintenance_cli.rb | 20 ++++++++++---------- spec/controllers/api/v1/markers_controller_spec.rb | 4 ++-- 6 files changed, 18 insertions(+), 24 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop.yml b/.rubocop.yml index 5278ee38c..eb3fcba43 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -101,6 +101,10 @@ Style/Copyright: Style/HashSyntax: EnforcedStyle: ruby19_no_mixed_keys +Style/NumericLiterals: + AllowedPatterns: + - \d{4}_\d{2}_\d{2}_\d{6} # For DB migration date version number readability + Style/PercentLiteralDelimiters: PreferredDelimiters: '%i': '()' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e24ce7e32..12e4f14ec 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -3149,16 +3149,6 @@ Style/MutableConstant: - 'lib/mastodon/snowflake.rb' - 'spec/controllers/api/base_controller_spec.rb' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinDigits, Strict, AllowedNumbers, AllowedPatterns. -Style/NumericLiterals: - Exclude: - - 'db/migrate/20180812173710_copy_status_stats.rb' - - 'db/migrate/20181116173541_copy_account_stats.rb' - - 'lib/mastodon/maintenance_cli.rb' - - 'spec/controllers/api/v1/markers_controller_spec.rb' - # Offense count: 10 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? diff --git a/db/migrate/20180812173710_copy_status_stats.rb b/db/migrate/20180812173710_copy_status_stats.rb index ff10c18d9..9b2971beb 100644 --- a/db/migrate/20180812173710_copy_status_stats.rb +++ b/db/migrate/20180812173710_copy_status_stats.rb @@ -19,7 +19,7 @@ class CopyStatusStats < ActiveRecord::Migration[5.2] def supports_upsert? version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i - version >= 90500 + version >= 90_500 end def up_fast diff --git a/db/migrate/20181116173541_copy_account_stats.rb b/db/migrate/20181116173541_copy_account_stats.rb index 8e27eb11b..20dc85195 100644 --- a/db/migrate/20181116173541_copy_account_stats.rb +++ b/db/migrate/20181116173541_copy_account_stats.rb @@ -19,7 +19,7 @@ class CopyAccountStats < ActiveRecord::Migration[5.2] def supports_upsert? version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i - version >= 90500 + version >= 90_500 end def up_fast diff --git a/lib/mastodon/maintenance_cli.rb b/lib/mastodon/maintenance_cli.rb index 85937da81..a86a4f2f6 100644 --- a/lib/mastodon/maintenance_cli.rb +++ b/lib/mastodon/maintenance_cli.rb @@ -13,8 +13,8 @@ module Mastodon true end - MIN_SUPPORTED_VERSION = 2019_10_01_213028 # rubocop:disable Style/NumericLiterals - MAX_SUPPORTED_VERSION = 2022_11_04_133904 # rubocop:disable Style/NumericLiterals + MIN_SUPPORTED_VERSION = 2019_10_01_213028 + MAX_SUPPORTED_VERSION = 2022_11_04_133904 # Stubs to enjoy ActiveRecord queries while not depending on a particular # version of the code/database @@ -209,7 +209,7 @@ module Mastodon end @prompt.say 'Restoring index_accounts_on_username_and_domain_lower…' - if ActiveRecord::Migrator.current_version < 20200620164023 # rubocop:disable Style/NumericLiterals + if ActiveRecord::Migrator.current_version < 2020_06_20_164023 ActiveRecord::Base.connection.add_index :accounts, 'lower (username), lower(domain)', name: 'index_accounts_on_username_and_domain_lower', unique: true else ActiveRecord::Base.connection.add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true @@ -252,7 +252,7 @@ module Mastodon end end - if ActiveRecord::Migrator.current_version < 20220118183010 # rubocop:disable Style/NumericLiterals + if ActiveRecord::Migrator.current_version < 2022_01_18_183010 ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE remember_token IS NOT NULL GROUP BY remember_token HAVING count(*) > 1").each do |row| users = User.where(id: row['ids'].split(',')).sort_by(&:updated_at).reverse.drop(1) @prompt.warn "Unsetting remember token for those accounts: #{users.map(&:account).map(&:acct).join(', ')}" @@ -275,9 +275,9 @@ module Mastodon @prompt.say 'Restoring users indexes…' ActiveRecord::Base.connection.add_index :users, ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true ActiveRecord::Base.connection.add_index :users, ['email'], name: 'index_users_on_email', unique: true - ActiveRecord::Base.connection.add_index :users, ['remember_token'], name: 'index_users_on_remember_token', unique: true if ActiveRecord::Migrator.current_version < 20220118183010 + ActiveRecord::Base.connection.add_index :users, ['remember_token'], name: 'index_users_on_remember_token', unique: true if ActiveRecord::Migrator.current_version < 2022_01_18_183010 - if ActiveRecord::Migrator.current_version < 20220310060641 # rubocop:disable Style/NumericLiterals + if ActiveRecord::Migrator.current_version < 2022_03_10_060641 ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true else ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, where: 'reset_password_token IS NOT NULL', opclass: :text_pattern_ops @@ -340,7 +340,7 @@ module Mastodon end @prompt.say 'Restoring conversations indexes…' - if ActiveRecord::Migrator.current_version < 20220307083603 # rubocop:disable Style/NumericLiterals + if ActiveRecord::Migrator.current_version < 2022_03_07_083603 ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true else ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops @@ -457,7 +457,7 @@ module Mastodon end @prompt.say 'Restoring media_attachments indexes…' - if ActiveRecord::Migrator.current_version < 20220310060626 # rubocop:disable Style/NumericLiterals + if ActiveRecord::Migrator.current_version < 2022_03_10_060626 ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true else ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true, where: 'shortcode IS NOT NULL', opclass: :text_pattern_ops @@ -490,7 +490,7 @@ module Mastodon end @prompt.say 'Restoring statuses indexes…' - if ActiveRecord::Migrator.current_version < 20220310060706 # rubocop:disable Style/NumericLiterals + if ActiveRecord::Migrator.current_version < 2022_03_10_060706 ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true else ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops @@ -512,7 +512,7 @@ module Mastodon end @prompt.say 'Restoring tags indexes…' - if ActiveRecord::Migrator.current_version < 20210421121431 + if ActiveRecord::Migrator.current_version < 2021_04_21_121431 ActiveRecord::Base.connection.add_index :tags, 'lower((name)::text)', name: 'index_tags_on_name_lower', unique: true else ActiveRecord::Base.connection.execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' diff --git a/spec/controllers/api/v1/markers_controller_spec.rb b/spec/controllers/api/v1/markers_controller_spec.rb index ba0f3c322..64ec18e59 100644 --- a/spec/controllers/api/v1/markers_controller_spec.rb +++ b/spec/controllers/api/v1/markers_controller_spec.rb @@ -42,7 +42,7 @@ RSpec.describe Api::V1::MarkersController, type: :controller do it 'creates a marker' do expect(user.markers.first.timeline).to eq 'home' - expect(user.markers.first.last_read_id).to eq 69420 + expect(user.markers.first.last_read_id).to eq 69_420 end end @@ -58,7 +58,7 @@ RSpec.describe Api::V1::MarkersController, type: :controller do it 'updates a marker' do expect(user.markers.first.timeline).to eq 'home' - expect(user.markers.first.last_read_id).to eq 70120 + expect(user.markers.first.last_read_id).to eq 70_120 end end end -- cgit From 6d42820e5df4a2282af1194a98789b45027aabce Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 21:22:01 -0500 Subject: Autofix Rubocop Lint/AmbiguousOperator (#23680) --- .rubocop_todo.yml | 8 -------- spec/controllers/api/v1/suggestions_controller_spec.rb | 2 +- spec/lib/request_spec.rb | 8 ++++---- spec/models/user_role_spec.rb | 4 ++-- 4 files changed, 7 insertions(+), 15 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 12e4f14ec..ddfe5c36b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -183,14 +183,6 @@ Lint/AmbiguousBlockAssociation: - 'spec/services/unsuspend_account_service_spec.rb' - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperator: - Exclude: - - 'spec/controllers/api/v1/suggestions_controller_spec.rb' - - 'spec/lib/request_spec.rb' - - 'spec/models/user_role_spec.rb' - # Offense count: 17 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: diff --git a/spec/controllers/api/v1/suggestions_controller_spec.rb b/spec/controllers/api/v1/suggestions_controller_spec.rb index 17f10b04f..7805b6b4f 100644 --- a/spec/controllers/api/v1/suggestions_controller_spec.rb +++ b/spec/controllers/api/v1/suggestions_controller_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Api::V1::SuggestionsController, type: :controller do json = body_as_json expect(json.size).to be >= 1 - expect(json.map { |i| i[:id] }).to include *[bob, jeff].map { |i| i.id.to_s } + expect(json.map { |i| i[:id] }).to include(*[bob, jeff].map { |i| i.id.to_s }) end end end diff --git a/spec/lib/request_spec.rb b/spec/lib/request_spec.rb index 8539944e2..e555a8b5a 100644 --- a/spec/lib/request_spec.rb +++ b/spec/lib/request_spec.rb @@ -43,7 +43,7 @@ describe Request do before { stub_request(:get, 'http://example.com') } it 'executes a HTTP request' do - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control expect(a_request(:get, 'http://example.com')).to have_been_made.once end @@ -54,18 +54,18 @@ describe Request do allow(resolver).to receive(:timeouts=).and_return(nil) allow(Resolv::DNS).to receive(:open).and_yield(resolver) - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control expect(a_request(:get, 'http://example.com')).to have_been_made.once end it 'sets headers' do - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control expect(a_request(:get, 'http://example.com').with(headers: subject.headers)).to have_been_made end it 'closes underlying connection' do expect_any_instance_of(HTTP::Client).to receive(:close) - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control end it 'returns response which implements body_with_limit' do diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index abf7d0e27..7294d14fe 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -139,7 +139,7 @@ RSpec.describe UserRole, type: :model do end it 'has negative position' do - expect(subject.position).to eq -1 + expect(subject.position).to eq(-1) end end @@ -159,7 +159,7 @@ RSpec.describe UserRole, type: :model do end it 'has negative position' do - expect(subject.position).to eq -1 + expect(subject.position).to eq(-1) end end -- cgit From a7db0b41cdb2e7ab50e638ec546b2c5dd2d633c7 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 22:00:05 -0500 Subject: Autofix Rubocop Lint/ParenthesesAsGroupedExpression (#23682) --- .rubocop_todo.yml | 9 --------- spec/controllers/api/v1/admin/accounts_controller_spec.rb | 2 +- spec/controllers/api/v2/admin/accounts_controller_spec.rb | 2 +- spec/lib/activitypub/activity/flag_spec.rb | 2 +- spec/models/import_spec.rb | 6 +++--- 5 files changed, 6 insertions(+), 15 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 91d600497..5319d6ace 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -289,15 +289,6 @@ Lint/OrAssignmentToConstant: Exclude: - 'lib/sanitize_ext/sanitize_config.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Lint/ParenthesesAsGroupedExpression: - Exclude: - - 'spec/controllers/api/v1/admin/accounts_controller_spec.rb' - - 'spec/controllers/api/v2/admin/accounts_controller_spec.rb' - - 'spec/lib/activitypub/activity/flag_spec.rb' - - 'spec/models/import_spec.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. diff --git a/spec/controllers/api/v1/admin/accounts_controller_spec.rb b/spec/controllers/api/v1/admin/accounts_controller_spec.rb index 8d35b86cb..a4c509c60 100644 --- a/spec/controllers/api/v1/admin/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/admin/accounts_controller_spec.rb @@ -65,7 +65,7 @@ RSpec.describe Api::V1::Admin::AccountsController, type: :controller do it "returns the correct accounts (#{expected_results.inspect})" do json = body_as_json - expect(json.map { |a| a[:id].to_i }).to eq (expected_results.map { |symbol| send(symbol).id }) + expect(json.map { |a| a[:id].to_i }).to eq(expected_results.map { |symbol| send(symbol).id }) end end end diff --git a/spec/controllers/api/v2/admin/accounts_controller_spec.rb b/spec/controllers/api/v2/admin/accounts_controller_spec.rb index 2508a9e05..1477049a1 100644 --- a/spec/controllers/api/v2/admin/accounts_controller_spec.rb +++ b/spec/controllers/api/v2/admin/accounts_controller_spec.rb @@ -65,7 +65,7 @@ RSpec.describe Api::V2::Admin::AccountsController, type: :controller do it "returns the correct accounts (#{expected_results.inspect})" do json = body_as_json - expect(json.map { |a| a[:id].to_i }).to eq (expected_results.map { |symbol| send(symbol).id }) + expect(json.map { |a| a[:id].to_i }).to eq(expected_results.map { |symbol| send(symbol).id }) end end end diff --git a/spec/lib/activitypub/activity/flag_spec.rb b/spec/lib/activitypub/activity/flag_spec.rb index 2f2d13876..7890fd1e8 100644 --- a/spec/lib/activitypub/activity/flag_spec.rb +++ b/spec/lib/activitypub/activity/flag_spec.rb @@ -110,7 +110,7 @@ RSpec.describe ActivityPub::Activity::Flag do describe '#perform with a defined uri' do subject { described_class.new(json, sender) } - let (:flag_id) { 'http://example.com/reports/1' } + let(:flag_id) { 'http://example.com/reports/1' } before do subject.perform diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index a5eec1722..4280b3237 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' RSpec.describe Import, type: :model do - let (:account) { Fabricate(:account) } - let (:type) { 'following' } - let (:data) { attachment_fixture('imports.txt') } + let(:account) { Fabricate(:account) } + let(:type) { 'following' } + let(:data) { attachment_fixture('imports.txt') } describe 'validations' do it 'has a valid parameters' do -- cgit From 5069769cbe7295268e8b87ce34fa0a753bfbb233 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sat, 18 Feb 2023 09:33:41 -0500 Subject: Autofix Rubocop Style/TrailingCommaInHashLiteral (#23693) --- .rubocop_todo.yml | 28 ------------------ spec/controllers/admin/accounts_controller_spec.rb | 2 +- .../admin/domain_blocks_controller_spec.rb | 6 ++-- .../api/v1/accounts/credentials_controller_spec.rb | 2 +- .../api/v1/push/subscriptions_controller_spec.rb | 6 ++-- .../api/web/push_subscriptions_controller_spec.rb | 6 ++-- .../settings/applications_controller_spec.rb | 20 ++++++------- .../settings/imports_controller_spec.rb | 8 ++--- .../preferences/notifications_controller_spec.rb | 2 +- .../settings/preferences/other_controller_spec.rb | 2 +- spec/lib/activitypub/activity/announce_spec.rb | 2 +- spec/lib/activitypub/activity/create_spec.rb | 8 ++--- .../fetch_featured_collection_service_spec.rb | 2 +- .../fetch_featured_tags_collection_service_spec.rb | 2 +- .../fetch_remote_status_service_spec.rb | 2 +- .../activitypub/fetch_replies_service_spec.rb | 2 +- .../activitypub/process_account_service_spec.rb | 2 +- .../activitypub/process_collection_service_spec.rb | 34 +++++++++++----------- .../process_status_update_service_spec.rb | 8 ++--- .../synchronize_followers_service_spec.rb | 2 +- spec/services/fetch_resource_service_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 22 files changed, 61 insertions(+), 89 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f35336332..ca2b085c9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -3417,34 +3417,6 @@ Style/TrailingCommaInArrayLiteral: - 'spec/services/activitypub/process_collection_service_spec.rb' - 'spec/workers/activitypub/move_distribution_worker_spec.rb' -# Offense count: 61 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInHashLiteral: - Exclude: - - 'spec/controllers/admin/accounts_controller_spec.rb' - - 'spec/controllers/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/push/subscriptions_controller_spec.rb' - - 'spec/controllers/api/web/push_subscriptions_controller_spec.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/controllers/settings/imports_controller_spec.rb' - - 'spec/controllers/settings/preferences/notifications_controller_spec.rb' - - 'spec/controllers/settings/preferences/other_controller_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/services/activitypub/fetch_featured_collection_service_spec.rb' - - 'spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/services/activitypub/fetch_replies_service_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/activitypub/synchronize_followers_service_spec.rb' - - 'spec/services/fetch_resource_service_spec.rb' - - 'spec/spec_helper.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Style/UnpackFirst: diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 81d592ddd..48204b7b6 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Admin::AccountsController, type: :controller do username: 'username', display_name: 'display name', email: 'local-part@domain', - ip: '0.0.0.42' + ip: '0.0.0.42', } end diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index f432060d9..3b2fd6c5d 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -26,9 +26,9 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do domain_blocks_attributes: { '0' => { enabled: '1', domain: 'example.com', severity: 'silence' }, '1' => { enabled: '0', domain: 'mastodon.social', severity: 'suspend' }, - '2' => { enabled: '1', domain: 'mastodon.online', severity: 'suspend' } - } - } + '2' => { enabled: '1', domain: 'mastodon.online', severity: 'suspend' }, + }, + }, } expect(DomainBlockWorker).to have_received(:perform_async).exactly(2).times diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index 89cc8acad..d8aa00a07 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -35,7 +35,7 @@ describe Api::V1::Accounts::CredentialsController do source: { privacy: 'unlisted', sensitive: true, - } + }, } end diff --git a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb index 9487251e1..67f09da2d 100644 --- a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb +++ b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb @@ -20,7 +20,7 @@ describe Api::V1::Push::SubscriptionsController do p256dh: 'BEm_a0bdPDhf0SOsrnB2-ategf1hHoCnpXgQsFj5JCkcoMrMt2WHoPfEYOYPzOIs9mZE8ZUaD7VA5vouy0kEkr8=', auth: 'eH_C8rq2raXqlcBVDa1gLg==', }, - } + }, }.with_indifferent_access end @@ -37,8 +37,8 @@ describe Api::V1::Push::SubscriptionsController do mention: false, poll: true, status: false, - } - } + }, + }, }.with_indifferent_access end diff --git a/spec/controllers/api/web/push_subscriptions_controller_spec.rb b/spec/controllers/api/web/push_subscriptions_controller_spec.rb index bda4a7661..9f027ede9 100644 --- a/spec/controllers/api/web/push_subscriptions_controller_spec.rb +++ b/spec/controllers/api/web/push_subscriptions_controller_spec.rb @@ -15,7 +15,7 @@ describe Api::Web::PushSubscriptionsController do p256dh: 'BEm_a0bdPDhf0SOsrnB2-ategf1hHoCnpXgQsFj5JCkcoMrMt2WHoPfEYOYPzOIs9mZE8ZUaD7VA5vouy0kEkr8=', auth: 'eH_C8rq2raXqlcBVDa1gLg==', }, - } + }, } end @@ -32,8 +32,8 @@ describe Api::Web::PushSubscriptionsController do mention: false, poll: true, status: false, - } - } + }, + }, } end diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index b79a38ea1..75d3240f9 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -51,8 +51,8 @@ describe Settings::ApplicationsController do name: 'My New App', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', website: 'http://google.com', - scopes: 'read write follow' - } + scopes: 'read write follow', + }, } response end @@ -73,8 +73,8 @@ describe Settings::ApplicationsController do name: 'My New App', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', website: 'http://google.com', - scopes: ['read', 'write', 'follow'] - } + scopes: ['read', 'write', 'follow'], + }, } response end @@ -95,8 +95,8 @@ describe Settings::ApplicationsController do name: '', redirect_uri: '', website: '', - scopes: [] - } + scopes: [], + }, } end @@ -114,14 +114,14 @@ describe Settings::ApplicationsController do context 'success' do let(:opts) { { - website: 'https://foo.bar/' + website: 'https://foo.bar/', } } def call_update patch :update, params: { id: app.id, - doorkeeper_application: opts + doorkeeper_application: opts, } response end @@ -144,8 +144,8 @@ describe Settings::ApplicationsController do name: '', redirect_uri: '', website: '', - scopes: [] - } + scopes: [], + }, } end diff --git a/spec/controllers/settings/imports_controller_spec.rb b/spec/controllers/settings/imports_controller_spec.rb index b8caf5941..8070a35db 100644 --- a/spec/controllers/settings/imports_controller_spec.rb +++ b/spec/controllers/settings/imports_controller_spec.rb @@ -21,8 +21,8 @@ RSpec.describe Settings::ImportsController, type: :controller do post :create, params: { import: { type: 'following', - data: fixture_file_upload('imports.txt') - } + data: fixture_file_upload('imports.txt'), + }, } expect(response).to redirect_to(settings_import_path) @@ -34,8 +34,8 @@ RSpec.describe Settings::ImportsController, type: :controller do post :create, params: { import: { type: 'blocking', - data: fixture_file_upload('imports.txt') - } + data: fixture_file_upload('imports.txt'), + }, } expect(response).to redirect_to(settings_import_path) diff --git a/spec/controllers/settings/preferences/notifications_controller_spec.rb b/spec/controllers/settings/preferences/notifications_controller_spec.rb index 02180b383..a821052ed 100644 --- a/spec/controllers/settings/preferences/notifications_controller_spec.rb +++ b/spec/controllers/settings/preferences/notifications_controller_spec.rb @@ -25,7 +25,7 @@ describe Settings::Preferences::NotificationsController do user: { notification_emails: { follow: '1' }, interactions: { must_be_follower: '0' }, - } + }, } expect(response).to redirect_to(settings_preferences_notifications_path) diff --git a/spec/controllers/settings/preferences/other_controller_spec.rb b/spec/controllers/settings/preferences/other_controller_spec.rb index 960378a01..dd7f01847 100644 --- a/spec/controllers/settings/preferences/other_controller_spec.rb +++ b/spec/controllers/settings/preferences/other_controller_spec.rb @@ -34,7 +34,7 @@ describe Settings::Preferences::OtherController do user: { setting_boost_modal: '1', setting_delete_modal: '0', - } + }, } expect(response).to redirect_to(settings_preferences_other_path) diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index 1b3485384..461c3757b 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -85,7 +85,7 @@ RSpec.describe ActivityPub::Activity::Announce do type: 'OrderedCollection', id: 'http://example.com/followers', first: 'http://example.com/followers?page=true', - } + }, } end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 074aa54ca..132e0c31c 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -255,7 +255,7 @@ RSpec.describe ActivityPub::Activity::Create do type: 'OrderedCollection', id: 'http://example.com/followers', first: 'http://example.com/followers?page=true', - } + }, } end @@ -686,7 +686,7 @@ RSpec.describe ActivityPub::Activity::Create do replies: { type: 'Collection', totalItems: 3, - } + }, }, ], } @@ -716,7 +716,7 @@ RSpec.describe ActivityPub::Activity::Create do id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, type: 'Note', name: 'Yellow', - inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status) + inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status), } end @@ -741,7 +741,7 @@ RSpec.describe ActivityPub::Activity::Create do id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, type: 'Note', name: 'Yellow', - inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status) + inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status), } end diff --git a/spec/services/activitypub/fetch_featured_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_collection_service_spec.rb index e6336dc1b..23d90a9a2 100644 --- a/spec/services/activitypub/fetch_featured_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_collection_service_spec.rb @@ -109,7 +109,7 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do type: 'CollectionPage', partOf: actor.featured_collection_url, items: items, - } + }, }.with_indifferent_access end diff --git a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb index 6ca22c9fc..692866bce 100644 --- a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb @@ -81,7 +81,7 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service d type: 'CollectionPage', partOf: collection_url, items: items, - } + }, }.with_indifferent_access end diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index d6145c9b8..e02054672 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -115,7 +115,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do id: "https://foo.bar/@foo/1234", type: 'Event', name: "Let's change the world", - attributedTo: ActivityPub::TagManager.instance.uri_for(sender) + attributedTo: ActivityPub::TagManager.instance.uri_for(sender), } end diff --git a/spec/services/activitypub/fetch_replies_service_spec.rb b/spec/services/activitypub/fetch_replies_service_spec.rb index fe49b18c1..5741e0c3f 100644 --- a/spec/services/activitypub/fetch_replies_service_spec.rb +++ b/spec/services/activitypub/fetch_replies_service_spec.rb @@ -90,7 +90,7 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do type: 'CollectionPage', partOf: collection_uri, items: items, - } + }, }.with_indifferent_access end diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 40caa6eb0..8e6ed178e 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -175,7 +175,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do name: "@user#{i + 1}", } ], - to: ['as:Public', "https://foo.test/users/#{i + 1}"] + to: ['as:Public', "https://foo.test/users/#{i + 1}"], }.with_indifferent_access featured_json = { '@context': ['https://www.w3.org/ns/activitystreams'], diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index cb7deb626..0fa5321bc 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -123,15 +123,15 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do type: 'RsaSignature2017', creator: 'https://example.com/users/bob#main-key', created: '2022-03-09T21:57:25Z', - signatureValue: 'WculK0LelTQ0MvGwU9TPoq5pFzFfGYRDCJqjZ232/Udj4CHqDTGOSw5UTDLShqBOyycCkbZGrQwXG+dpyDpQLSe1UVPZ5TPQtc/9XtI57WlS2nMNpdvRuxGnnb2btPdesXZ7n3pCxo0zjaXrJMe0mqQh5QJO22mahb4bDwwmfTHgbD3nmkD+fBfGi+UV2qWwqr+jlV4L4JqNkh0gWljF5KTePLRRZCuWiQ/FAt7c67636cdIPf7fR+usjuZltTQyLZKEGuK8VUn2Gkfsx5qns7Vcjvlz1JqlAjyO8HPBbzTTHzUG2nUOIgC3PojCSWv6mNTmRGoLZzOscCAYQA6cKw==' + signatureValue: 'WculK0LelTQ0MvGwU9TPoq5pFzFfGYRDCJqjZ232/Udj4CHqDTGOSw5UTDLShqBOyycCkbZGrQwXG+dpyDpQLSe1UVPZ5TPQtc/9XtI57WlS2nMNpdvRuxGnnb2btPdesXZ7n3pCxo0zjaXrJMe0mqQh5QJO22mahb4bDwwmfTHgbD3nmkD+fBfGi+UV2qWwqr+jlV4L4JqNkh0gWljF5KTePLRRZCuWiQ/FAt7c67636cdIPf7fR+usjuZltTQyLZKEGuK8VUn2Gkfsx5qns7Vcjvlz1JqlAjyO8HPBbzTTHzUG2nUOIgC3PojCSWv6mNTmRGoLZzOscCAYQA6cKw==', }, '@id': 'https://example.com/users/bob/statuses/107928807471117876/activity', '@type': 'https://www.w3.org/ns/activitystreams#Create', 'https://www.w3.org/ns/activitystreams#actor': { - '@id': 'https://example.com/users/bob' + '@id': 'https://example.com/users/bob', }, 'https://www.w3.org/ns/activitystreams#cc': { - '@id': 'https://example.com/users/bob/followers' + '@id': 'https://example.com/users/bob/followers', }, object: { id: 'https://example.com/users/bob/fake-status', @@ -156,21 +156,21 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do 'http://ostatus.org#conversation': 'tag:example.com,2022-03-09:objectId=15:objectType=Conversation', 'https://www.w3.org/ns/activitystreams#attachment': [], 'https://www.w3.org/ns/activitystreams#attributedTo': { - '@id': 'https://example.com/users/bob' + '@id': 'https://example.com/users/bob', }, 'https://www.w3.org/ns/activitystreams#cc': { - '@id': 'https://example.com/users/bob/followers' + '@id': 'https://example.com/users/bob/followers', }, 'https://www.w3.org/ns/activitystreams#content': [ '

hello world

', { '@value': '

hello world

', - '@language': 'en' + '@language': 'en', } ], 'https://www.w3.org/ns/activitystreams#published': { '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', - '@value': '2022-03-09T21:55:07Z' + '@value': '2022-03-09T21:55:07Z', }, 'https://www.w3.org/ns/activitystreams#replies': { '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies', @@ -179,29 +179,29 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do '@type': 'https://www.w3.org/ns/activitystreams#CollectionPage', 'https://www.w3.org/ns/activitystreams#items': [], 'https://www.w3.org/ns/activitystreams#next': { - '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies?only_other_accounts=true&page=true' + '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies?only_other_accounts=true&page=true', }, 'https://www.w3.org/ns/activitystreams#partOf': { - '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies' - } - } + '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies', + }, + }, }, 'https://www.w3.org/ns/activitystreams#sensitive': false, 'https://www.w3.org/ns/activitystreams#tag': [], 'https://www.w3.org/ns/activitystreams#to': { - '@id': 'https://www.w3.org/ns/activitystreams#Public' + '@id': 'https://www.w3.org/ns/activitystreams#Public', }, 'https://www.w3.org/ns/activitystreams#url': { - '@id': 'https://example.com/@bob/107928807471117876' - } + '@id': 'https://example.com/@bob/107928807471117876', + }, }, 'https://www.w3.org/ns/activitystreams#published': { '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', - '@value': '2022-03-09T21:55:07Z' + '@value': '2022-03-09T21:55:07Z', }, 'https://www.w3.org/ns/activitystreams#to': { - '@id': 'https://www.w3.org/ns/activitystreams#Public' - } + '@id': 'https://www.w3.org/ns/activitystreams#Public', + }, } end diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 04292c507..5d15f6ffe 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -115,7 +115,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do account: account, multiple: false, hide_totals: false, - expires_at: expiration + expires_at: expiration, }) end @@ -166,7 +166,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do account: account, multiple: false, hide_totals: false, - expires_at: expiration + expires_at: expiration, }) end @@ -342,7 +342,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do updated: '2021-09-08T22:39:25Z', attachment: [ { type: 'Image', mediaType: 'image/png', url: 'https://example.com/foo.png' }, - ] + ], } end @@ -374,7 +374,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do updated: '2021-09-08T22:39:25Z', attachment: [ { type: 'Image', mediaType: 'image/png', url: 'https://example.com/foo.png', name: 'A picture' }, - ] + ], } end diff --git a/spec/services/activitypub/synchronize_followers_service_spec.rb b/spec/services/activitypub/synchronize_followers_service_spec.rb index 75dcf204b..5a37f0733 100644 --- a/spec/services/activitypub/synchronize_followers_service_spec.rb +++ b/spec/services/activitypub/synchronize_followers_service_spec.rb @@ -91,7 +91,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do type: 'CollectionPage', partOf: collection_uri, items: items, - } + }, }.with_indifferent_access end diff --git a/spec/services/fetch_resource_service_spec.rb b/spec/services/fetch_resource_service_spec.rb index 8cd4a3bfb..6f24e6418 100644 --- a/spec/services/fetch_resource_service_spec.rb +++ b/spec/services/fetch_resource_service_spec.rb @@ -91,7 +91,7 @@ RSpec.describe FetchResourceService, type: :service do end context 'when link header is present' do - let(:headers) { { 'Link' => '; rel="alternate"; type="application/activity+json"', } } + let(:headers) { { 'Link' => '; rel="alternate"; type="application/activity+json"' } } it { is_expected.to eq [1, { prefetched_body: json, id: true }] } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0414ba9ed..72c9ce8ae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -61,6 +61,6 @@ end def expect_push_bulk_to_match(klass, matcher) expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({ "class" => klass, - "args" => matcher + "args" => matcher, })) end -- cgit From 81ad6c2e39393ff20450385cb37dd9bf6e6651e5 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sat, 18 Feb 2023 17:38:14 -0500 Subject: Autofix Rubocop Style/StringLiterals (#23695) --- .rubocop_todo.yml | 82 ---------------------- app/lib/webfinger.rb | 4 +- db/migrate/20160305115639_add_devise_to_users.rb | 2 +- .../20161122163057_remove_unneeded_indexes.rb | 6 +- .../20170125145934_add_spoiler_text_to_statuses.rb | 2 +- ...1212195226_remove_duplicate_indexes_in_lists.rb | 4 +- ...uses_for_api_v1_accounts_account_id_statuses.rb | 4 +- db/migrate/20180617162849_remove_unused_indexes.rb | 6 +- ...80606_encrypted_message_ids_to_timestamp_ids.rb | 2 +- ...213645_media_attachment_ids_to_timestamp_ids.rb | 2 +- .../20210306164523_account_ids_to_timestamp_ids.rb | 2 +- lib/mastodon/emoji_cli.rb | 2 +- lib/rails/engine_extensions.rb | 2 +- lib/tasks/mastodon.rake | 2 +- .../admin/change_email_controller_spec.rb | 8 +-- .../api/v1/streaming_controller_spec.rb | 2 +- spec/controllers/application_controller_spec.rb | 4 +- .../auth/registrations_controller_spec.rb | 20 +++--- spec/controllers/auth/sessions_controller_spec.rb | 28 ++++---- .../authorized_applications_controller_spec.rb | 2 +- .../settings/imports_controller_spec.rb | 4 +- .../settings/profiles_controller_spec.rb | 4 +- .../webauthn_credentials_controller_spec.rb | 2 +- .../statuses_cleanup_controller_spec.rb | 4 +- .../well_known/nodeinfo_controller_spec.rb | 4 +- .../account_moderation_note_fabricator.rb | 2 +- spec/fabricators/account_note_fabricator.rb | 2 +- spec/fabricators/account_stat_fabricator.rb | 6 +- spec/fabricators/account_tag_stat_fabricator.rb | 2 +- .../account_warning_preset_fabricator.rb | 2 +- spec/fabricators/admin_action_log_fabricator.rb | 2 +- .../canonical_email_block_fabricator.rb | 2 +- .../fabricators/conversation_account_fabricator.rb | 2 +- .../custom_emoji_category_fabricator.rb | 2 +- spec/fabricators/domain_allow_fabricator.rb | 2 +- spec/fabricators/encrypted_message_fabricator.rb | 4 +- spec/fabricators/identity_fabricator.rb | 4 +- spec/fabricators/ip_block_fabricator.rb | 8 +-- spec/fabricators/list_fabricator.rb | 2 +- spec/fabricators/relay_fabricator.rb | 2 +- spec/fabricators/report_fabricator.rb | 2 +- spec/fabricators/report_note_fabricator.rb | 2 +- spec/fabricators/session_activation_fabricator.rb | 2 +- spec/fabricators/status_edit_fabricator.rb | 4 +- spec/fabricators/status_fabricator.rb | 2 +- spec/fabricators/status_stat_fabricator.rb | 6 +- spec/fabricators/user_fabricator.rb | 2 +- spec/fabricators/user_role_fabricator.rb | 4 +- spec/features/log_in_spec.rb | 4 +- spec/helpers/accounts_helper_spec.rb | 8 +-- spec/helpers/application_helper_spec.rb | 10 +-- spec/lib/feed_manager_spec.rb | 2 +- spec/mailers/notification_mailer_spec.rb | 44 ++++++------ spec/mailers/user_mailer_spec.rb | 2 +- spec/models/account_spec.rb | 58 +++++++-------- spec/models/media_attachment_spec.rb | 22 +++--- spec/models/web/push_subscription_spec.rb | 2 +- spec/models/webauthn_credentials_spec.rb | 4 +- spec/presenters/instance_presenter_spec.rb | 30 ++++---- spec/rails_helper.rb | 2 +- spec/requests/catch_all_route_request_spec.rb | 20 +++--- spec/requests/host_meta_request_spec.rb | 10 +-- spec/requests/localization_spec.rb | 6 +- spec/services/account_search_service_spec.rb | 2 +- .../fetch_remote_status_service_spec.rb | 40 +++++------ spec/services/delete_account_service_spec.rb | 12 ++-- spec/services/favourite_service_spec.rb | 4 +- spec/services/fetch_link_card_service_spec.rb | 8 +-- spec/services/fetch_oembed_service_spec.rb | 6 +- spec/services/fetch_remote_status_service_spec.rb | 2 +- spec/services/follow_service_spec.rb | 2 +- spec/services/import_service_spec.rb | 4 +- spec/services/post_status_service_spec.rb | 28 ++++---- spec/services/process_mentions_service_spec.rb | 8 +-- spec/services/resolve_account_service_spec.rb | 18 ++--- spec/spec_helper.rb | 6 +- 76 files changed, 277 insertions(+), 359 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1c22c440b..e99747819 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -3057,88 +3057,6 @@ Style/StringConcatenation: - 'spec/validators/disallowed_hashtags_validator_spec.rb' - 'spec/workers/web/push_notification_worker_spec.rb' -# Offense count: 297 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Exclude: - - 'app/lib/webfinger.rb' - - 'db/migrate/20160305115639_add_devise_to_users.rb' - - 'db/migrate/20161122163057_remove_unneeded_indexes.rb' - - 'db/migrate/20170125145934_add_spoiler_text_to_statuses.rb' - - 'db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb' - - 'db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb' - - 'db/migrate/20180617162849_remove_unused_indexes.rb' - - 'db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb' - - 'db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb' - - 'db/migrate/20210306164523_account_ids_to_timestamp_ids.rb' - - 'lib/mastodon/emoji_cli.rb' - - 'lib/rails/engine_extensions.rb' - - 'lib/tasks/mastodon.rake' - - 'spec/controllers/admin/change_email_controller_spec.rb' - - 'spec/controllers/api/v1/streaming_controller_spec.rb' - - 'spec/controllers/application_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/auth/sessions_controller_spec.rb' - - 'spec/controllers/oauth/authorized_applications_controller_spec.rb' - - 'spec/controllers/settings/imports_controller_spec.rb' - - 'spec/controllers/settings/profiles_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/controllers/statuses_cleanup_controller_spec.rb' - - 'spec/controllers/well_known/nodeinfo_controller_spec.rb' - - 'spec/fabricators/account_moderation_note_fabricator.rb' - - 'spec/fabricators/account_note_fabricator.rb' - - 'spec/fabricators/account_stat_fabricator.rb' - - 'spec/fabricators/account_tag_stat_fabricator.rb' - - 'spec/fabricators/account_warning_preset_fabricator.rb' - - 'spec/fabricators/admin_action_log_fabricator.rb' - - 'spec/fabricators/canonical_email_block_fabricator.rb' - - 'spec/fabricators/conversation_account_fabricator.rb' - - 'spec/fabricators/custom_emoji_category_fabricator.rb' - - 'spec/fabricators/domain_allow_fabricator.rb' - - 'spec/fabricators/encrypted_message_fabricator.rb' - - 'spec/fabricators/identity_fabricator.rb' - - 'spec/fabricators/ip_block_fabricator.rb' - - 'spec/fabricators/list_fabricator.rb' - - 'spec/fabricators/relay_fabricator.rb' - - 'spec/fabricators/report_fabricator.rb' - - 'spec/fabricators/report_note_fabricator.rb' - - 'spec/fabricators/session_activation_fabricator.rb' - - 'spec/fabricators/status_edit_fabricator.rb' - - 'spec/fabricators/status_fabricator.rb' - - 'spec/fabricators/status_stat_fabricator.rb' - - 'spec/fabricators/user_fabricator.rb' - - 'spec/fabricators/user_role_fabricator.rb' - - 'spec/features/log_in_spec.rb' - - 'spec/helpers/accounts_helper_spec.rb' - - 'spec/helpers/application_helper_spec.rb' - - 'spec/lib/feed_manager_spec.rb' - - 'spec/mailers/notification_mailer_spec.rb' - - 'spec/mailers/user_mailer_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/web/push_subscription_spec.rb' - - 'spec/models/webauthn_credentials_spec.rb' - - 'spec/presenters/instance_presenter_spec.rb' - - 'spec/rails_helper.rb' - - 'spec/requests/catch_all_route_request_spec.rb' - - 'spec/requests/host_meta_request_spec.rb' - - 'spec/requests/localization_spec.rb' - - 'spec/services/account_search_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/services/delete_account_service_spec.rb' - - 'spec/services/favourite_service_spec.rb' - - 'spec/services/fetch_link_card_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - - 'spec/services/fetch_remote_status_service_spec.rb' - - 'spec/services/follow_service_spec.rb' - - 'spec/services/import_service_spec.rb' - - 'spec/services/post_status_service_spec.rb' - - 'spec/services/process_mentions_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/spec_helper.rb' - # Offense count: 272 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize. diff --git a/app/lib/webfinger.rb b/app/lib/webfinger.rb index 7c0c10c33..42ddef47b 100644 --- a/app/lib/webfinger.rb +++ b/app/lib/webfinger.rb @@ -99,7 +99,7 @@ class Webfinger end def standard_url - if @domain.end_with? ".onion" + if @domain.end_with? '.onion' "http://#{@domain}/.well-known/webfinger?resource=#{@uri}" else "https://#{@domain}/.well-known/webfinger?resource=#{@uri}" @@ -107,7 +107,7 @@ class Webfinger end def host_meta_url - if @domain.end_with? ".onion" + if @domain.end_with? '.onion' "http://#{@domain}/.well-known/host-meta" else "https://#{@domain}/.well-known/host-meta" diff --git a/db/migrate/20160305115639_add_devise_to_users.rb b/db/migrate/20160305115639_add_devise_to_users.rb index 0e12e6053..fa1e521b2 100644 --- a/db/migrate/20160305115639_add_devise_to_users.rb +++ b/db/migrate/20160305115639_add_devise_to_users.rb @@ -2,7 +2,7 @@ class AddDeviseToUsers < ActiveRecord::Migration[4.2] def self.up change_table(:users) do |t| ## Database authenticatable - t.string :encrypted_password, null: false, default: "" + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token diff --git a/db/migrate/20161122163057_remove_unneeded_indexes.rb b/db/migrate/20161122163057_remove_unneeded_indexes.rb index 3832b878d..12cc9c5b2 100644 --- a/db/migrate/20161122163057_remove_unneeded_indexes.rb +++ b/db/migrate/20161122163057_remove_unneeded_indexes.rb @@ -1,7 +1,7 @@ class RemoveUnneededIndexes < ActiveRecord::Migration[5.0] def change - remove_index :notifications, name: "index_notifications_on_account_id" - remove_index :settings, name: "index_settings_on_target_type_and_target_id" - remove_index :statuses_tags, name: "index_statuses_tags_on_tag_id" + remove_index :notifications, name: 'index_notifications_on_account_id' + remove_index :settings, name: 'index_settings_on_target_type_and_target_id' + remove_index :statuses_tags, name: 'index_statuses_tags_on_tag_id' end end diff --git a/db/migrate/20170125145934_add_spoiler_text_to_statuses.rb b/db/migrate/20170125145934_add_spoiler_text_to_statuses.rb index 2c43210ba..39cd41c00 100644 --- a/db/migrate/20170125145934_add_spoiler_text_to_statuses.rb +++ b/db/migrate/20170125145934_add_spoiler_text_to_statuses.rb @@ -1,5 +1,5 @@ class AddSpoilerTextToStatuses < ActiveRecord::Migration[5.0] def change - add_column :statuses, :spoiler_text, :text, default: "", null: false + add_column :statuses, :spoiler_text, :text, default: '', null: false end end diff --git a/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb b/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb index 03f2591a8..ba67eee86 100644 --- a/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb +++ b/db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb @@ -1,6 +1,6 @@ class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.1] def change - remove_index :list_accounts, name: "index_list_accounts_on_account_id" - remove_index :list_accounts, name: "index_list_accounts_on_list_id" + remove_index :list_accounts, name: 'index_list_accounts_on_account_id' + remove_index :list_accounts, name: 'index_list_accounts_on_list_id' end end diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb index ccd2ec7ea..e23880bf5 100644 --- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -5,11 +5,11 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor def change safety_assured do - add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, "index_statuses_20180106") + add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, 'index_statuses_20180106') end # These index may not exists (see migration 20180514130000) remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)') - remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ["account_id", "id"], where: "(visibility = 3)") + remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ['account_id', 'id'], where: '(visibility = 3)') end end diff --git a/db/migrate/20180617162849_remove_unused_indexes.rb b/db/migrate/20180617162849_remove_unused_indexes.rb index 61add6385..9cd6b9164 100644 --- a/db/migrate/20180617162849_remove_unused_indexes.rb +++ b/db/migrate/20180617162849_remove_unused_indexes.rb @@ -1,7 +1,7 @@ class RemoveUnusedIndexes < ActiveRecord::Migration[5.2] def change - remove_index :statuses, name: "index_statuses_on_conversation_id" - remove_index :users, name: "index_users_on_filtered_languages" - remove_index :backups, name: "index_backups_on_user_id" + remove_index :statuses, name: 'index_statuses_on_conversation_id' + remove_index :users, name: 'index_users_on_filtered_languages' + remove_index :backups, name: 'index_backups_on_user_id' end end diff --git a/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb b/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb index 24d43a0bf..c5c80b795 100644 --- a/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb +++ b/db/migrate/20200521180606_encrypted_message_ids_to_timestamp_ids.rb @@ -6,7 +6,7 @@ class EncryptedMessageIdsToTimestampIds < ActiveRecord::Migration[5.2] end def down - execute("LOCK encrypted_messages") + execute('LOCK encrypted_messages') execute("SELECT setval('encrypted_messages_id_seq', (SELECT MAX(id) FROM encrypted_messages))") execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT nextval('encrypted_messages_id_seq')") end diff --git a/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb b/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb index 5c6865b92..ccd65bf53 100644 --- a/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb +++ b/db/migrate/20200622213645_media_attachment_ids_to_timestamp_ids.rb @@ -10,7 +10,7 @@ class MediaAttachmentIdsToTimestampIds < ActiveRecord::Migration[5.1] end def down - execute("LOCK media_attachments") + execute('LOCK media_attachments') execute("SELECT setval('media_attachments_id_seq', (SELECT MAX(id) FROM media_attachments))") execute("ALTER TABLE media_attachments ALTER COLUMN id SET DEFAULT nextval('media_attachments_id_seq')") end diff --git a/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb b/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb index 39cd4cdea..40c582842 100644 --- a/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb +++ b/db/migrate/20210306164523_account_ids_to_timestamp_ids.rb @@ -10,7 +10,7 @@ class AccountIdsToTimestampIds < ActiveRecord::Migration[5.1] end def down - execute("LOCK accounts") + execute('LOCK accounts') execute("SELECT setval('accounts_id_seq', (SELECT MAX(id) FROM accounts))") execute("ALTER TABLE accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq')") end diff --git a/lib/mastodon/emoji_cli.rb b/lib/mastodon/emoji_cli.rb index a3e947909..feb77107f 100644 --- a/lib/mastodon/emoji_cli.rb +++ b/lib/mastodon/emoji_cli.rb @@ -49,7 +49,7 @@ module Mastodon next if filename.start_with?('._') shortcode = [options[:prefix], filename, options[:suffix]].compact.join - custom_emoji = CustomEmoji.local.find_by("LOWER(shortcode) = ?", shortcode.downcase) + custom_emoji = CustomEmoji.local.find_by('LOWER(shortcode) = ?', shortcode.downcase) if custom_emoji && !options[:overwrite] skipped += 1 diff --git a/lib/rails/engine_extensions.rb b/lib/rails/engine_extensions.rb index 4e3767db9..1f5c2cd6c 100644 --- a/lib/rails/engine_extensions.rb +++ b/lib/rails/engine_extensions.rb @@ -3,7 +3,7 @@ module Rails # Rewrite task loading code to filter digitalocean.rake task def run_tasks_blocks(app) Railtie.instance_method(:run_tasks_blocks).bind_call(self, app) - paths["lib/tasks"].existent.reject { |ext| ext.end_with?('digitalocean.rake') }.sort.each { |ext| load(ext) } + paths['lib/tasks'].existent.reject { |ext| ext.end_with?('digitalocean.rake') }.sort.each { |ext| load(ext) } end end end diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 477daa01b..179a730bc 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -264,7 +264,7 @@ namespace :mastodon do env['S3_ENDPOINT'] = prompt.ask('Storj DCS endpoint URL:') do |q| q.required true - q.default "https://gateway.storjshare.io" + q.default 'https://gateway.storjshare.io' q.modify :strip end diff --git a/spec/controllers/admin/change_email_controller_spec.rb b/spec/controllers/admin/change_email_controller_spec.rb index cf8a27d39..0814f327d 100644 --- a/spec/controllers/admin/change_email_controller_spec.rb +++ b/spec/controllers/admin/change_email_controller_spec.rb @@ -9,8 +9,8 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do sign_in admin end - describe "GET #show" do - it "returns http success" do + describe 'GET #show' do + it 'returns http success' do user = Fabricate(:user) get :show, params: { account_id: user.account.id } @@ -19,12 +19,12 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do end end - describe "GET #update" do + describe 'GET #update' do before do allow(UserMailer).to receive(:confirmation_instructions).and_return(double('email', deliver_later: nil)) end - it "returns http success" do + it 'returns http success' do user = Fabricate(:user) previous_email = user.email diff --git a/spec/controllers/api/v1/streaming_controller_spec.rb b/spec/controllers/api/v1/streaming_controller_spec.rb index 4ab409a54..9dbca0178 100644 --- a/spec/controllers/api/v1/streaming_controller_spec.rb +++ b/spec/controllers/api/v1/streaming_controller_spec.rb @@ -38,7 +38,7 @@ describe Api::V1::StreamingController do [:scheme, :path, :query, :fragment].each do |part| expect(redirect_to_uri.send(part)).to eq(request_uri.send(part)), "redirect target #{part}" end - expect(redirect_to_uri.host).to eq(@streaming_host), "redirect target host" + expect(redirect_to_uri.host).to eq(@streaming_host), 'redirect target host' end end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 1b002e01c..f14c451de 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -27,7 +27,7 @@ describe ApplicationController, type: :controller do expect(response).to have_http_status(code) end - it "renders template for http" do + it 'renders template for http' do is_expected.to render_template("errors/#{code}", layout: 'error') end end @@ -146,7 +146,7 @@ describe ApplicationController, type: :controller do end it 'does not store location for user if it is devise controller' do - @request.env["devise.mapping"] = Devise.mappings[:user] + @request.env['devise.mapping'] = Devise.mappings[:user] get 'create' expect(controller.stored_location_for(:user)).to be_nil end diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 38c003b53..7298bde00 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do describe 'GET #edit' do it 'returns http success' do - request.env["devise.mapping"] = Devise.mappings[:user] + request.env['devise.mapping'] = Devise.mappings[:user] sign_in(Fabricate(:user)) get :edit expect(response).to have_http_status(200) @@ -41,7 +41,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do describe 'GET #update' do it 'returns http success' do - request.env["devise.mapping"] = Devise.mappings[:user] + request.env['devise.mapping'] = Devise.mappings[:user] sign_in(Fabricate(:user), scope: :user) post :update expect(response).to have_http_status(200) @@ -49,7 +49,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do context 'when suspended' do it 'returns http forbidden' do - request.env["devise.mapping"] = Devise.mappings[:user] + request.env['devise.mapping'] = Devise.mappings[:user] sign_in(Fabricate(:user, account_attributes: { username: 'test', suspended_at: Time.now.utc }), scope: :user) post :update expect(response).to have_http_status(403) @@ -59,7 +59,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do describe 'GET #new' do before do - request.env["devise.mapping"] = Devise.mappings[:user] + request.env['devise.mapping'] = Devise.mappings[:user] end context do @@ -92,7 +92,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do I18n.locale = current_locale end - before { request.env["devise.mapping"] = Devise.mappings[:user] } + before { request.env['devise.mapping'] = Devise.mappings[:user] } context do around do |example| @@ -103,7 +103,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do subject do Setting.registrations_mode = 'open' - request.headers["Accept-Language"] = accept_language + request.headers['Accept-Language'] = accept_language post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } } end @@ -129,7 +129,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do subject do Setting.registrations_mode = 'open' - request.headers["Accept-Language"] = accept_language + request.headers['Accept-Language'] = accept_language post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } } end @@ -149,7 +149,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do subject do Setting.registrations_mode = 'approved' - request.headers["Accept-Language"] = accept_language + request.headers['Accept-Language'] = accept_language post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } } end @@ -176,7 +176,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do subject do Setting.registrations_mode = 'approved' - request.headers["Accept-Language"] = accept_language + request.headers['Accept-Language'] = accept_language invite = Fabricate(:invite, max_uses: nil, expires_at: 1.hour.ago) post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end @@ -208,7 +208,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do inviter = Fabricate(:user, confirmed_at: 2.days.ago) Setting.registrations_mode = 'approved' Setting.require_invite_text = true - request.headers["Accept-Language"] = accept_language + request.headers['Accept-Language'] = accept_language invite = Fabricate(:invite, user: inviter, max_uses: nil, expires_at: 1.hour.from_now) post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index 8f898ad1f..eb03dff50 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -54,7 +54,7 @@ RSpec.describe Auth::SessionsController, type: :controller do context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do context 'using a valid password' do before do - post :create, params: { user: { email: "pam_user1", password: '123456' } } + post :create, params: { user: { email: 'pam_user1', password: '123456' } } end it 'redirects to home' do @@ -68,7 +68,7 @@ RSpec.describe Auth::SessionsController, type: :controller do context 'using an invalid password' do before do - post :create, params: { user: { email: "pam_user1", password: 'WRONGPW' } } + post :create, params: { user: { email: 'pam_user1', password: 'WRONGPW' } } end it 'shows a login error' do @@ -194,7 +194,7 @@ RSpec.describe Auth::SessionsController, type: :controller do post :create, params: { user: { email: user.email, password: user.password } } end - context "in single user mode" do + context 'in single user mode' do let(:single_user_mode) { true } it 'redirects to home' do @@ -202,7 +202,7 @@ RSpec.describe Auth::SessionsController, type: :controller do end end - context "in non-single user mode" do + context 'in non-single user mode' do let(:single_user_mode) { false } it "redirects back to the user's page" do @@ -230,8 +230,8 @@ RSpec.describe Auth::SessionsController, type: :controller do end it 'renders two factor authentication page' do - expect(controller).to render_template("two_factor") - expect(controller).to render_template(partial: "_otp_authentication_form") + expect(controller).to render_template('two_factor') + expect(controller).to render_template(partial: '_otp_authentication_form') end end @@ -246,8 +246,8 @@ RSpec.describe Auth::SessionsController, type: :controller do end it 'renders two factor authentication page' do - expect(controller).to render_template("two_factor") - expect(controller).to render_template(partial: "_otp_authentication_form") + expect(controller).to render_template('two_factor') + expect(controller).to render_template(partial: '_otp_authentication_form') end end @@ -257,8 +257,8 @@ RSpec.describe Auth::SessionsController, type: :controller do end it 'renders two factor authentication page' do - expect(controller).to render_template("two_factor") - expect(controller).to render_template(partial: "_otp_authentication_form") + expect(controller).to render_template('two_factor') + expect(controller).to render_template(partial: '_otp_authentication_form') end end @@ -359,8 +359,8 @@ RSpec.describe Auth::SessionsController, type: :controller do end it 'renders webauthn authentication page' do - expect(controller).to render_template("two_factor") - expect(controller).to render_template(partial: "_webauthn_form") + expect(controller).to render_template('two_factor') + expect(controller).to render_template(partial: '_webauthn_form') end end @@ -370,8 +370,8 @@ RSpec.describe Auth::SessionsController, type: :controller do end it 'renders webauthn authentication page' do - expect(controller).to render_template("two_factor") - expect(controller).to render_template(partial: "_webauthn_form") + expect(controller).to render_template('two_factor') + expect(controller).to render_template(partial: '_webauthn_form') end end diff --git a/spec/controllers/oauth/authorized_applications_controller_spec.rb b/spec/controllers/oauth/authorized_applications_controller_spec.rb index 901e538e9..885bfa35b 100644 --- a/spec/controllers/oauth/authorized_applications_controller_spec.rb +++ b/spec/controllers/oauth/authorized_applications_controller_spec.rb @@ -13,7 +13,7 @@ describe Oauth::AuthorizedApplicationsController do shared_examples 'stores location for user' do it 'stores location for user' do subject - expect(controller.stored_location_for(:user)).to eq "/oauth/authorized_applications" + expect(controller.stored_location_for(:user)).to eq '/oauth/authorized_applications' end end diff --git a/spec/controllers/settings/imports_controller_spec.rb b/spec/controllers/settings/imports_controller_spec.rb index 8070a35db..e50504cc5 100644 --- a/spec/controllers/settings/imports_controller_spec.rb +++ b/spec/controllers/settings/imports_controller_spec.rb @@ -7,8 +7,8 @@ RSpec.describe Settings::ImportsController, type: :controller do sign_in Fabricate(:user), scope: :user end - describe "GET #show" do - it "returns http success" do + describe 'GET #show' do + it 'returns http success' do get :show expect(response).to have_http_status(200) end diff --git a/spec/controllers/settings/profiles_controller_spec.rb b/spec/controllers/settings/profiles_controller_spec.rb index ee3aec815..fbbca8bb9 100644 --- a/spec/controllers/settings/profiles_controller_spec.rb +++ b/spec/controllers/settings/profiles_controller_spec.rb @@ -10,8 +10,8 @@ RSpec.describe Settings::ProfilesController, type: :controller do sign_in user, scope: :user end - describe "GET #show" do - it "returns http success" do + describe 'GET #show' do + it 'returns http success' do get :show expect(response).to have_http_status(200) end diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb index 06989ffd2..c3156c4e9 100644 --- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb @@ -137,7 +137,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do expect { get :options }.to_not change { user.webauthn_id } end - it "includes existing credentials in list of excluded credentials" do + it 'includes existing credentials in list of excluded credentials' do get :options excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].map { |credential| credential['id'] } diff --git a/spec/controllers/statuses_cleanup_controller_spec.rb b/spec/controllers/statuses_cleanup_controller_spec.rb index 924709260..347fe4027 100644 --- a/spec/controllers/statuses_cleanup_controller_spec.rb +++ b/spec/controllers/statuses_cleanup_controller_spec.rb @@ -8,8 +8,8 @@ RSpec.describe StatusesCleanupController, type: :controller do sign_in @user, scope: :user end - describe "GET #show" do - it "returns http success" do + describe 'GET #show' do + it 'returns http success' do get :show expect(response).to have_http_status(200) end diff --git a/spec/controllers/well_known/nodeinfo_controller_spec.rb b/spec/controllers/well_known/nodeinfo_controller_spec.rb index 36e85f20d..964a14706 100644 --- a/spec/controllers/well_known/nodeinfo_controller_spec.rb +++ b/spec/controllers/well_known/nodeinfo_controller_spec.rb @@ -27,8 +27,8 @@ describe WellKnown::NodeInfoController, type: :controller do json = body_as_json - expect({ "foo" => 0 }).not_to match_json_schema("nodeinfo_2.0") - expect(json).to match_json_schema("nodeinfo_2.0") + expect({ 'foo' => 0 }).not_to match_json_schema('nodeinfo_2.0') + expect(json).to match_json_schema('nodeinfo_2.0') expect(json[:version]).to eq '2.0' expect(json[:usage]).to be_a Hash expect(json[:software]).to be_a Hash diff --git a/spec/fabricators/account_moderation_note_fabricator.rb b/spec/fabricators/account_moderation_note_fabricator.rb index 9277af165..343a41fb1 100644 --- a/spec/fabricators/account_moderation_note_fabricator.rb +++ b/spec/fabricators/account_moderation_note_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:account_moderation_note) do - content "MyText" + content 'MyText' account nil end diff --git a/spec/fabricators/account_note_fabricator.rb b/spec/fabricators/account_note_fabricator.rb index 1b061745a..285703b38 100644 --- a/spec/fabricators/account_note_fabricator.rb +++ b/spec/fabricators/account_note_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:account_note) do account target_account { Fabricate(:account) } - comment "User note text" + comment 'User note text' end diff --git a/spec/fabricators/account_stat_fabricator.rb b/spec/fabricators/account_stat_fabricator.rb index 2b06b4790..b1b47ffef 100644 --- a/spec/fabricators/account_stat_fabricator.rb +++ b/spec/fabricators/account_stat_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:account_stat) do account nil - statuses_count "" - following_count "" - followers_count "" + statuses_count '' + following_count '' + followers_count '' end diff --git a/spec/fabricators/account_tag_stat_fabricator.rb b/spec/fabricators/account_tag_stat_fabricator.rb index 9edb550be..7a4de07f6 100644 --- a/spec/fabricators/account_tag_stat_fabricator.rb +++ b/spec/fabricators/account_tag_stat_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:account_tag_stat) do - accounts_count "" + accounts_count '' end diff --git a/spec/fabricators/account_warning_preset_fabricator.rb b/spec/fabricators/account_warning_preset_fabricator.rb index 6c0b87e7c..7e7c03cb8 100644 --- a/spec/fabricators/account_warning_preset_fabricator.rb +++ b/spec/fabricators/account_warning_preset_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:account_warning_preset) do - text "MyText" + text 'MyText' end diff --git a/spec/fabricators/admin_action_log_fabricator.rb b/spec/fabricators/admin_action_log_fabricator.rb index 2f44e953d..474bef1bc 100644 --- a/spec/fabricators/admin_action_log_fabricator.rb +++ b/spec/fabricators/admin_action_log_fabricator.rb @@ -1,5 +1,5 @@ Fabricator('Admin::ActionLog') do account nil - action "MyString" + action 'MyString' target nil end diff --git a/spec/fabricators/canonical_email_block_fabricator.rb b/spec/fabricators/canonical_email_block_fabricator.rb index a0b6e0d22..61afde3de 100644 --- a/spec/fabricators/canonical_email_block_fabricator.rb +++ b/spec/fabricators/canonical_email_block_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:canonical_email_block) do - email "test@example.com" + email 'test@example.com' reference_account { Fabricate(:account) } end diff --git a/spec/fabricators/conversation_account_fabricator.rb b/spec/fabricators/conversation_account_fabricator.rb index f57ffd535..0fe7a494e 100644 --- a/spec/fabricators/conversation_account_fabricator.rb +++ b/spec/fabricators/conversation_account_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:conversation_account) do account nil conversation nil - participant_account_ids "" + participant_account_ids '' last_status nil end diff --git a/spec/fabricators/custom_emoji_category_fabricator.rb b/spec/fabricators/custom_emoji_category_fabricator.rb index f593b95ed..119c343cf 100644 --- a/spec/fabricators/custom_emoji_category_fabricator.rb +++ b/spec/fabricators/custom_emoji_category_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:custom_emoji_category) do - name "MyString" + name 'MyString' end diff --git a/spec/fabricators/domain_allow_fabricator.rb b/spec/fabricators/domain_allow_fabricator.rb index 6226b1e20..6f62ce3b8 100644 --- a/spec/fabricators/domain_allow_fabricator.rb +++ b/spec/fabricators/domain_allow_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:domain_allow) do - domain "MyString" + domain 'MyString' end diff --git a/spec/fabricators/encrypted_message_fabricator.rb b/spec/fabricators/encrypted_message_fabricator.rb index e65f66302..4de0d7add 100644 --- a/spec/fabricators/encrypted_message_fabricator.rb +++ b/spec/fabricators/encrypted_message_fabricator.rb @@ -3,6 +3,6 @@ Fabricator(:encrypted_message) do from_account from_device_id { Faker::Number.number(digits: 5) } type 0 - body "" - message_franking "" + body '' + message_franking '' end diff --git a/spec/fabricators/identity_fabricator.rb b/spec/fabricators/identity_fabricator.rb index bc832df9f..fcfb15518 100644 --- a/spec/fabricators/identity_fabricator.rb +++ b/spec/fabricators/identity_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:identity) do user nil - provider "MyString" - uid "MyString" + provider 'MyString' + uid 'MyString' end diff --git a/spec/fabricators/ip_block_fabricator.rb b/spec/fabricators/ip_block_fabricator.rb index 1797f6877..5bd018f9c 100644 --- a/spec/fabricators/ip_block_fabricator.rb +++ b/spec/fabricators/ip_block_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:ip_block) do - ip "" - severity "" - expires_at "2020-10-08 22:20:37" - comment "MyText" + ip '' + severity '' + expires_at '2020-10-08 22:20:37' + comment 'MyText' end diff --git a/spec/fabricators/list_fabricator.rb b/spec/fabricators/list_fabricator.rb index c3db690fa..4ad29a386 100644 --- a/spec/fabricators/list_fabricator.rb +++ b/spec/fabricators/list_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:list) do account - title "MyString" + title 'MyString' end diff --git a/spec/fabricators/relay_fabricator.rb b/spec/fabricators/relay_fabricator.rb index 488913f77..d6255866c 100644 --- a/spec/fabricators/relay_fabricator.rb +++ b/spec/fabricators/relay_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:relay) do - inbox_url "https://example.com/inbox" + inbox_url 'https://example.com/inbox' state :idle end diff --git a/spec/fabricators/report_fabricator.rb b/spec/fabricators/report_fabricator.rb index 2c7101e09..3011c49c6 100644 --- a/spec/fabricators/report_fabricator.rb +++ b/spec/fabricators/report_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:report) do account target_account { Fabricate(:account) } - comment "You nasty" + comment 'You nasty' action_taken_at nil end diff --git a/spec/fabricators/report_note_fabricator.rb b/spec/fabricators/report_note_fabricator.rb index e139efffb..33f384074 100644 --- a/spec/fabricators/report_note_fabricator.rb +++ b/spec/fabricators/report_note_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:report_note) do report account { Fabricate(:account) } - content "Test Content" + content 'Test Content' end diff --git a/spec/fabricators/session_activation_fabricator.rb b/spec/fabricators/session_activation_fabricator.rb index 526faaec2..a7fc3b017 100644 --- a/spec/fabricators/session_activation_fabricator.rb +++ b/spec/fabricators/session_activation_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:session_activation) do user - session_id "MyString" + session_id 'MyString' end diff --git a/spec/fabricators/status_edit_fabricator.rb b/spec/fabricators/status_edit_fabricator.rb index 3141759e5..0e5796b23 100644 --- a/spec/fabricators/status_edit_fabricator.rb +++ b/spec/fabricators/status_edit_fabricator.rb @@ -1,7 +1,7 @@ Fabricator(:status_edit) do status nil account nil - text "MyText" - spoiler_text "MyText" + text 'MyText' + spoiler_text 'MyText' media_attachments_changed false end diff --git a/spec/fabricators/status_fabricator.rb b/spec/fabricators/status_fabricator.rb index 04bbbcf4b..8a0a8aa55 100644 --- a/spec/fabricators/status_fabricator.rb +++ b/spec/fabricators/status_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:status) do account - text "Lorem ipsum dolor sit amet" + text 'Lorem ipsum dolor sit amet' after_build do |status| status.uri = Faker::Internet.device_token if !status.account.local? && status.uri.nil? diff --git a/spec/fabricators/status_stat_fabricator.rb b/spec/fabricators/status_stat_fabricator.rb index 9c67fd404..feba9fbca 100644 --- a/spec/fabricators/status_stat_fabricator.rb +++ b/spec/fabricators/status_stat_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:status_stat) do status_id nil - replies_count "" - reblogs_count "" - favourites_count "" + replies_count '' + reblogs_count '' + favourites_count '' end diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index 10ad2c53a..93ce07a74 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -1,7 +1,7 @@ Fabricator(:user) do account { Fabricate.build(:account, user: nil) } email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } } - password "123456789" + password '123456789' confirmed_at { Time.zone.now } agreement true end diff --git a/spec/fabricators/user_role_fabricator.rb b/spec/fabricators/user_role_fabricator.rb index ed0a7dc1f..592b4edca 100644 --- a/spec/fabricators/user_role_fabricator.rb +++ b/spec/fabricators/user_role_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:user_role) do - name "MyString" - color "" + name 'MyString' + color '' permissions 0 end diff --git a/spec/features/log_in_spec.rb b/spec/features/log_in_spec.rb index 329cdf34c..5ae738ee2 100644 --- a/spec/features/log_in_spec.rb +++ b/spec/features/log_in_spec.rb @@ -7,8 +7,8 @@ describe 'Log in' do subject { page } - let(:email) { "test@example.com" } - let(:password) { "password" } + let(:email) { 'test@example.com' } + let(:password) { 'password' } let(:confirmed_at) { Time.zone.now } before do diff --git a/spec/helpers/accounts_helper_spec.rb b/spec/helpers/accounts_helper_spec.rb index 2b35b23b7..1f412a39f 100644 --- a/spec/helpers/accounts_helper_spec.rb +++ b/spec/helpers/accounts_helper_spec.rb @@ -13,15 +13,15 @@ RSpec.describe AccountsHelper, type: :helper do describe '#display_name' do it 'uses the display name when it exists' do - account = Account.new(display_name: "Display", username: "Username") + account = Account.new(display_name: 'Display', username: 'Username') - expect(helper.display_name(account)).to eq "Display" + expect(helper.display_name(account)).to eq 'Display' end it 'uses the username when display name is nil' do - account = Account.new(display_name: nil, username: "Username") + account = Account.new(display_name: nil, username: 'Username') - expect(helper.display_name(account)).to eq "Username" + expect(helper.display_name(account)).to eq 'Username' end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 1dbd985bf..b335a5e45 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -5,8 +5,8 @@ describe ApplicationHelper do it 'returns active when on the current page' do allow(helper).to receive(:current_page?).and_return(true) - result = helper.active_nav_class("/test") - expect(result).to eq "active" + result = helper.active_nav_class('/test') + expect(result).to eq 'active' end it 'returns active when on a current page' do @@ -14,14 +14,14 @@ describe ApplicationHelper do allow(helper).to receive(:current_page?).with('/test').and_return(true) result = helper.active_nav_class('/foo', '/test') - expect(result).to eq "active" + expect(result).to eq 'active' end it 'returns empty string when not on current page' do allow(helper).to receive(:current_page?).and_return(false) - result = helper.active_nav_class("/test") - expect(result).to eq "" + result = helper.active_nav_class('/test') + expect(result).to eq '' end end diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index eb55c3983..7195cec06 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -416,7 +416,7 @@ RSpec.describe FeedManager do FeedManager.instance.merge_into_home(account, reblog.account) - expect(redis.zscore("feed:home:0", reblog.id)).to eq nil + expect(redis.zscore('feed:home:0', reblog.id)).to eq nil end end diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 29bdc349b..6746871a3 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -1,4 +1,4 @@ -require "rails_helper" +require 'rails_helper' RSpec.describe NotificationMailer, type: :mailer do let(:receiver) { Fabricate(:user) } @@ -19,69 +19,69 @@ RSpec.describe NotificationMailer, type: :mailer do end end - describe "mention" do + describe 'mention' do let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) } let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) } include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob' - it "renders the headers" do - expect(mail.subject).to eq("You were mentioned by bob") + it 'renders the headers' do + expect(mail.subject).to eq('You were mentioned by bob') expect(mail.to).to eq([receiver.email]) end - it "renders the body" do - expect(mail.body.encoded).to match("You were mentioned by bob") + it 'renders the body' do + expect(mail.body.encoded).to match('You were mentioned by bob') expect(mail.body.encoded).to include 'The body of the foreign status' end end - describe "follow" do + describe 'follow' do let(:follow) { sender.follow!(receiver.account) } let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) } include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob' - it "renders the headers" do - expect(mail.subject).to eq("bob is now following you") + it 'renders the headers' do + expect(mail.subject).to eq('bob is now following you') expect(mail.to).to eq([receiver.email]) end - it "renders the body" do - expect(mail.body.encoded).to match("bob is now following you") + it 'renders the body' do + expect(mail.body.encoded).to match('bob is now following you') end end - describe "favourite" do + describe 'favourite' do let(:favourite) { Favourite.create!(account: sender, status: own_status) } let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) } include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob' - it "renders the headers" do - expect(mail.subject).to eq("bob favourited your post") + it 'renders the headers' do + expect(mail.subject).to eq('bob favourited your post') expect(mail.to).to eq([receiver.email]) end - it "renders the body" do - expect(mail.body.encoded).to match("Your post was favourited by bob") + it 'renders the body' do + expect(mail.body.encoded).to match('Your post was favourited by bob') expect(mail.body.encoded).to include 'The body of the own status' end end - describe "reblog" do + describe 'reblog' do let(:reblog) { Status.create!(account: sender, reblog: own_status) } let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) } include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob' - it "renders the headers" do - expect(mail.subject).to eq("bob boosted your post") + it 'renders the headers' do + expect(mail.subject).to eq('bob boosted your post') expect(mail.to).to eq([receiver.email]) end - it "renders the body" do - expect(mail.body.encoded).to match("Your post was boosted by bob") + it 'renders the body' do + expect(mail.body.encoded).to match('Your post was boosted by bob') expect(mail.body.encoded).to include 'The body of the own status' end end @@ -98,7 +98,7 @@ RSpec.describe NotificationMailer, type: :mailer do end it 'renders the body' do - expect(mail.body.encoded).to match("bob has requested to follow you") + expect(mail.body.encoded).to match('bob has requested to follow you') end end end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 2ed33c1e4..9c22f60f1 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -90,7 +90,7 @@ describe UserMailer, type: :mailer do it 'renders warning notification' do receiver.update!(locale: nil) - expect(mail.body.encoded).to include I18n.t("user_mailer.warning.title.suspend", acct: receiver.account.acct) + expect(mail.body.encoded).to include I18n.t('user_mailer.warning.title.suspend', acct: receiver.account.acct) expect(mail.body.encoded).to include strike.text end end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 694432a1e..763835618 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -345,9 +345,9 @@ RSpec.describe Account, type: :model do before do _missing = Fabricate( :account, - display_name: "Missing", - username: "missing", - domain: "missing.com" + display_name: 'Missing', + username: 'missing', + domain: 'missing.com' ) end @@ -405,58 +405,58 @@ RSpec.describe Account, type: :model do it 'finds accounts with matching display_name' do match = Fabricate( :account, - display_name: "Display Name", - username: "username", - domain: "example.com" + display_name: 'Display Name', + username: 'username', + domain: 'example.com' ) - results = Account.search_for("display") + results = Account.search_for('display') expect(results).to eq [match] end it 'finds accounts with matching username' do match = Fabricate( :account, - display_name: "Display Name", - username: "username", - domain: "example.com" + display_name: 'Display Name', + username: 'username', + domain: 'example.com' ) - results = Account.search_for("username") + results = Account.search_for('username') expect(results).to eq [match] end it 'finds accounts with matching domain' do match = Fabricate( :account, - display_name: "Display Name", - username: "username", - domain: "example.com" + display_name: 'Display Name', + username: 'username', + domain: 'example.com' ) - results = Account.search_for("example") + results = Account.search_for('example') expect(results).to eq [match] end it 'limits by 10 by default' do - 11.times.each { Fabricate(:account, display_name: "Display Name") } - results = Account.search_for("display") + 11.times.each { Fabricate(:account, display_name: 'Display Name') } + results = Account.search_for('display') expect(results.size).to eq 10 end it 'accepts arbitrary limits' do - 2.times.each { Fabricate(:account, display_name: "Display Name") } - results = Account.search_for("display", limit: 1) + 2.times.each { Fabricate(:account, display_name: 'Display Name') } + results = Account.search_for('display', limit: 1) expect(results.size).to eq 1 end it 'ranks multiple matches higher' do matches = [ - { username: "username", display_name: "username" }, - { display_name: "Display Name", username: "username", domain: "example.com" }, + { username: 'username', display_name: 'username' }, + { display_name: 'Display Name', username: 'username', domain: 'example.com' }, ].map(&method(:Fabricate).curry(2).call(:account)) - results = Account.search_for("username") + results = Account.search_for('username') expect(results).to eq matches end end @@ -582,23 +582,23 @@ RSpec.describe Account, type: :model do end it 'limits by 10 by default' do - 11.times { Fabricate(:account, display_name: "Display Name") } - results = Account.advanced_search_for("display", account) + 11.times { Fabricate(:account, display_name: 'Display Name') } + results = Account.advanced_search_for('display', account) expect(results.size).to eq 10 end it 'accepts arbitrary limits' do - 2.times { Fabricate(:account, display_name: "Display Name") } - results = Account.advanced_search_for("display", account, limit: 1) + 2.times { Fabricate(:account, display_name: 'Display Name') } + results = Account.advanced_search_for('display', account, limit: 1) expect(results.size).to eq 1 end it 'ranks followed accounts higher' do - match = Fabricate(:account, username: "Matching") - followed_match = Fabricate(:account, username: "Matcher") + match = Fabricate(:account, username: 'Matching') + followed_match = Fabricate(:account, username: 'Matcher') Fabricate(:follow, account: account, target_account: followed_match) - results = Account.advanced_search_for("match", account) + results = Account.advanced_search_for('match', account) expect(results).to eq [followed_match, match] expect(results.first.rank).to be > results.last.rank end diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 29fd313ae..d1a94d41a 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -94,8 +94,8 @@ RSpec.describe MediaAttachment, type: :model do end it 'sets meta' do - expect(media.file.meta["original"]["width"]).to eq 128 - expect(media.file.meta["original"]["height"]).to eq 128 + expect(media.file.meta['original']['width']).to eq 128 + expect(media.file.meta['original']['height']).to eq 128 end end @@ -118,9 +118,9 @@ RSpec.describe MediaAttachment, type: :model do end it 'sets meta' do - expect(media.file.meta["original"]["width"]).to eq fixture[:width] - expect(media.file.meta["original"]["height"]).to eq fixture[:height] - expect(media.file.meta["original"]["aspect"]).to eq fixture[:aspect] + expect(media.file.meta['original']['width']).to eq fixture[:width] + expect(media.file.meta['original']['height']).to eq fixture[:height] + expect(media.file.meta['original']['aspect']).to eq fixture[:aspect] end end end @@ -154,12 +154,12 @@ RSpec.describe MediaAttachment, type: :model do let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) } it 'sets meta for different style' do - expect(media.file.meta["original"]["width"]).to eq 600 - expect(media.file.meta["original"]["height"]).to eq 400 - expect(media.file.meta["original"]["aspect"]).to eq 1.5 - expect(media.file.meta["small"]["width"]).to eq 588 - expect(media.file.meta["small"]["height"]).to eq 392 - expect(media.file.meta["small"]["aspect"]).to eq 1.5 + expect(media.file.meta['original']['width']).to eq 600 + expect(media.file.meta['original']['height']).to eq 400 + expect(media.file.meta['original']['aspect']).to eq 1.5 + expect(media.file.meta['small']['width']).to eq 588 + expect(media.file.meta['small']['height']).to eq 392 + expect(media.file.meta['small']['aspect']).to eq 1.5 end it 'gives the file a random name' do diff --git a/spec/models/web/push_subscription_spec.rb b/spec/models/web/push_subscription_spec.rb index bd5719593..eeadbb71c 100644 --- a/spec/models/web/push_subscription_spec.rb +++ b/spec/models/web/push_subscription_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Web::PushSubscription, type: :model do context "when notification is a #{type}" do let(:notification_type) { type } - it "returns boolean corresponding to alert setting" do + it 'returns boolean corresponding to alert setting' do expect(subject.pushable?(notification)).to eq data[:alerts][type] end end diff --git a/spec/models/webauthn_credentials_spec.rb b/spec/models/webauthn_credentials_spec.rb index a63ae6cd2..e070a6b60 100644 --- a/spec/models/webauthn_credentials_spec.rb +++ b/spec/models/webauthn_credentials_spec.rb @@ -35,8 +35,8 @@ RSpec.describe WebauthnCredential, type: :model do end it 'is invalid if already exist a webauthn credential with the same external id' do - existing_webauthn_credential = Fabricate(:webauthn_credential, external_id: "_Typ0ygudDnk9YUVWLQayw") - new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: "_Typ0ygudDnk9YUVWLQayw") + existing_webauthn_credential = Fabricate(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw') + new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw') new_webauthn_credential.valid? diff --git a/spec/presenters/instance_presenter_spec.rb b/spec/presenters/instance_presenter_spec.rb index 659c2cc2f..a451b5cba 100644 --- a/spec/presenters/instance_presenter_spec.rb +++ b/spec/presenters/instance_presenter_spec.rb @@ -10,9 +10,9 @@ describe InstancePresenter do Setting.site_short_description = site_description end - it "delegates site_description to Setting" do - Setting.site_short_description = "Site desc" - expect(instance_presenter.description).to eq "Site desc" + it 'delegates site_description to Setting' do + Setting.site_short_description = 'Site desc' + expect(instance_presenter.description).to eq 'Site desc' end end @@ -23,9 +23,9 @@ describe InstancePresenter do Setting.site_extended_description = site_extended_description end - it "delegates site_extended_description to Setting" do - Setting.site_extended_description = "Extended desc" - expect(instance_presenter.extended_description).to eq "Extended desc" + it 'delegates site_extended_description to Setting' do + Setting.site_extended_description = 'Extended desc' + expect(instance_presenter.extended_description).to eq 'Extended desc' end end @@ -36,9 +36,9 @@ describe InstancePresenter do Setting.site_contact_email = site_contact_email end - it "delegates contact_email to Setting" do - Setting.site_contact_email = "admin@example.com" - expect(instance_presenter.contact.email).to eq "admin@example.com" + it 'delegates contact_email to Setting' do + Setting.site_contact_email = 'admin@example.com' + expect(instance_presenter.contact.email).to eq 'admin@example.com' end end @@ -49,15 +49,15 @@ describe InstancePresenter do Setting.site_contact_username = site_contact_username end - it "returns the account for the site contact username" do - Setting.site_contact_username = "aaa" - account = Fabricate(:account, username: "aaa") + it 'returns the account for the site contact username' do + Setting.site_contact_username = 'aaa' + account = Fabricate(:account, username: 'aaa') expect(instance_presenter.contact.account).to eq(account) end end describe '#user_count' do - it "returns the number of site users" do + it 'returns the number of site users' do Rails.cache.write 'user_count', 123 expect(instance_presenter.user_count).to eq(123) @@ -65,7 +65,7 @@ describe InstancePresenter do end describe '#status_count' do - it "returns the number of local statuses" do + it 'returns the number of local statuses' do Rails.cache.write 'local_status_count', 234 expect(instance_presenter.status_count).to eq(234) @@ -73,7 +73,7 @@ describe InstancePresenter do end describe '#domain_count' do - it "returns the number of known domains" do + it 'returns the number of known domains' do Rails.cache.write 'distinct_domain_count', 345 expect(instance_presenter.domain_count).to eq(345) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 20e48b9a3..9a14fc3b1 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,7 +1,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../config/environment', __dir__) -abort("The Rails environment is running in production mode!") if Rails.env.production? +abort('The Rails environment is running in production mode!') if Rails.env.production? require 'spec_helper' require 'rspec/rails' diff --git a/spec/requests/catch_all_route_request_spec.rb b/spec/requests/catch_all_route_request_spec.rb index f965f5522..fb18965d8 100644 --- a/spec/requests/catch_all_route_request_spec.rb +++ b/spec/requests/catch_all_route_request_spec.rb @@ -1,21 +1,21 @@ -require "rails_helper" +require 'rails_helper' -describe "The catch all route" do - describe "with a simple value" do - it "returns a 404 page as html" do - get "/test" +describe 'The catch all route' do + describe 'with a simple value' do + it 'returns a 404 page as html' do + get '/test' expect(response.status).to eq 404 - expect(response.media_type).to eq "text/html" + expect(response.media_type).to eq 'text/html' end end - describe "with an implied format" do - it "returns a 404 page as html" do - get "/test.test" + describe 'with an implied format' do + it 'returns a 404 page as html' do + get '/test.test' expect(response.status).to eq 404 - expect(response.media_type).to eq "text/html" + expect(response.media_type).to eq 'text/html' end end end diff --git a/spec/requests/host_meta_request_spec.rb b/spec/requests/host_meta_request_spec.rb index 0ca641461..60153ba8c 100644 --- a/spec/requests/host_meta_request_spec.rb +++ b/spec/requests/host_meta_request_spec.rb @@ -1,12 +1,12 @@ -require "rails_helper" +require 'rails_helper' -describe "The host_meta route" do - describe "requested without accepts headers" do - it "returns an xml response" do +describe 'The host_meta route' do + describe 'requested without accepts headers' do + it 'returns an xml response' do get host_meta_url expect(response).to have_http_status(200) - expect(response.media_type).to eq "application/xrd+xml" + expect(response.media_type).to eq 'application/xrd+xml' end end end diff --git a/spec/requests/localization_spec.rb b/spec/requests/localization_spec.rb index 0bc2786ac..39eeee5f0 100644 --- a/spec/requests/localization_spec.rb +++ b/spec/requests/localization_spec.rb @@ -10,7 +10,7 @@ describe 'Localization' do it 'uses a specific region when provided' do headers = { 'Accept-Language' => 'zh-HK' } - get "/auth/sign_in", headers: headers + get '/auth/sign_in', headers: headers expect(response.body).to include( I18n.t('auth.login', locale: 'zh-HK') @@ -20,7 +20,7 @@ describe 'Localization' do it 'falls back to a locale when region missing' do headers = { 'Accept-Language' => 'es-FAKE' } - get "/auth/sign_in", headers: headers + get '/auth/sign_in', headers: headers expect(response.body).to include( I18n.t('auth.login', locale: 'es') @@ -30,7 +30,7 @@ describe 'Localization' do it 'falls back to english when locale is missing' do headers = { 'Accept-Language' => '12-FAKE' } - get "/auth/sign_in", headers: headers + get '/auth/sign_in', headers: headers expect(response.body).to include( I18n.t('auth.login', locale: 'en') diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index 81cbc175e..d3b5baad6 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -76,7 +76,7 @@ describe AccountSearchService, type: :service do expect(results).to eq [partial] end - it "does not return suspended remote accounts" do + it 'does not return suspended remote accounts' do remote = Fabricate(:account, username: 'a', domain: 'remote', display_name: 'e', suspended: true) results = subject.call('a@example.com', nil, limit: 2) diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index e02054672..4f3503ac2 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -11,7 +11,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:note) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234", + id: 'https://foo.bar/@foo/1234', type: 'Note', content: 'Lorem ipsum', attributedTo: ActivityPub::TagManager.instance.uri_for(sender), @@ -46,7 +46,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234", + id: 'https://foo.bar/@foo/1234', type: 'Video', name: 'Nyan Cat 10 hours remix', attributedTo: ActivityPub::TagManager.instance.uri_for(sender), @@ -54,13 +54,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do { type: 'Link', mimeType: 'application/x-bittorrent', - href: "https://foo.bar/12345.torrent", + href: 'https://foo.bar/12345.torrent', }, { type: 'Link', mimeType: 'text/html', - href: "https://foo.bar/watch?v=12345", + href: 'https://foo.bar/watch?v=12345', }, ], } @@ -70,8 +70,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do status = sender.statuses.first expect(status).to_not be_nil - expect(status.url).to eq "https://foo.bar/watch?v=12345" - expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345" + expect(status.url).to eq 'https://foo.bar/watch?v=12345' + expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345' end end @@ -79,7 +79,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234", + id: 'https://foo.bar/@foo/1234', type: 'Audio', name: 'Nyan Cat 10 hours remix', attributedTo: ActivityPub::TagManager.instance.uri_for(sender), @@ -87,13 +87,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do { type: 'Link', mimeType: 'application/x-bittorrent', - href: "https://foo.bar/12345.torrent", + href: 'https://foo.bar/12345.torrent', }, { type: 'Link', mimeType: 'text/html', - href: "https://foo.bar/watch?v=12345", + href: 'https://foo.bar/watch?v=12345', }, ], } @@ -103,8 +103,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do status = sender.statuses.first expect(status).to_not be_nil - expect(status.url).to eq "https://foo.bar/watch?v=12345" - expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345" + expect(status.url).to eq 'https://foo.bar/watch?v=12345' + expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345' end end @@ -112,7 +112,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234", + id: 'https://foo.bar/@foo/1234', type: 'Event', name: "Let's change the world", attributedTo: ActivityPub::TagManager.instance.uri_for(sender), @@ -123,7 +123,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do status = sender.statuses.first expect(status).to_not be_nil - expect(status.url).to eq "https://foo.bar/@foo/1234" + expect(status.url).to eq 'https://foo.bar/@foo/1234' expect(strip_tags(status.text)).to eq "Let's change the worldhttps://foo.bar/@foo/1234" end end @@ -132,7 +132,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:note) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://real.address/@foo/1234", + id: 'https://real.address/@foo/1234', type: 'Note', content: 'Lorem ipsum', attributedTo: ActivityPub::TagManager.instance.uri_for(sender), @@ -154,7 +154,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234/create", + id: 'https://foo.bar/@foo/1234/create', type: 'Create', actor: ActivityPub::TagManager.instance.uri_for(sender), object: note, @@ -174,11 +174,11 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234/create", + id: 'https://foo.bar/@foo/1234/create', type: 'Create', actor: ActivityPub::TagManager.instance.uri_for(sender), object: { - id: "https://real.address/@foo/1234", + id: 'https://real.address/@foo/1234', type: 'Note', content: 'Lorem ipsum', attributedTo: ActivityPub::TagManager.instance.uri_for(sender), @@ -208,7 +208,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1234/create", + id: 'https://foo.bar/@foo/1234/create', type: 'Create', actor: ActivityPub::TagManager.instance.uri_for(sender), object: note.merge(updated: '2021-09-08T22:39:25Z'), @@ -233,7 +233,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1", + id: 'https://foo.bar/@foo/1', type: 'Note', content: 'Lorem ipsum', inReplyTo: 'https://foo.bar/@foo/2', @@ -269,7 +269,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do let(:object) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://foo.bar/@foo/1", + id: 'https://foo.bar/@foo/1', type: 'Note', content: 'Lorem ipsum', replies: { diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index 1fbe4d07c..cc4b168fc 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -59,8 +59,8 @@ RSpec.describe DeleteAccountService, type: :service do describe '#call on local account' do before do - stub_request(:post, "https://alice.com/inbox").to_return(status: 201) - stub_request(:post, "https://bob.com/inbox").to_return(status: 201) + stub_request(:post, 'https://alice.com/inbox').to_return(status: 201) + stub_request(:post, 'https://bob.com/inbox').to_return(status: 201) end let!(:remote_alice) { Fabricate(:account, inbox_url: 'https://alice.com/inbox', protocol: :activitypub) } @@ -72,16 +72,16 @@ RSpec.describe DeleteAccountService, type: :service do it 'sends a delete actor activity to all known inboxes' do subject - expect(a_request(:post, "https://alice.com/inbox")).to have_been_made.once - expect(a_request(:post, "https://bob.com/inbox")).to have_been_made.once + expect(a_request(:post, 'https://alice.com/inbox')).to have_been_made.once + expect(a_request(:post, 'https://bob.com/inbox')).to have_been_made.once end end end describe '#call on remote account' do before do - stub_request(:post, "https://alice.com/inbox").to_return(status: 201) - stub_request(:post, "https://bob.com/inbox").to_return(status: 201) + stub_request(:post, 'https://alice.com/inbox').to_return(status: 201) + stub_request(:post, 'https://bob.com/inbox').to_return(status: 201) end include_examples 'common behavior' do diff --git a/spec/services/favourite_service_spec.rb b/spec/services/favourite_service_spec.rb index 9781f0d78..8703c2af8 100644 --- a/spec/services/favourite_service_spec.rb +++ b/spec/services/favourite_service_spec.rb @@ -23,7 +23,7 @@ RSpec.describe FavouriteService, type: :service do let(:status) { Fabricate(:status, account: bob) } before do - stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {}) + stub_request(:post, 'http://example.com/inbox').to_return(status: 200, body: '', headers: {}) subject.call(sender, status) end @@ -32,7 +32,7 @@ RSpec.describe FavouriteService, type: :service do end it 'sends a like activity' do - expect(a_request(:post, "http://example.com/inbox")).to have_been_made.once + expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once end end end diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb index 4914c2753..458473c39 100644 --- a/spec/services/fetch_link_card_service_spec.rb +++ b/spec/services/fetch_link_card_service_spec.rb @@ -30,7 +30,7 @@ RSpec.describe FetchLinkCardService, type: :service do it 'works with SJIS' do expect(a_request(:get, 'http://example.com/sjis')).to have_been_made.at_least_once - expect(status.preview_cards.first.title).to eq("SJISのページ") + expect(status.preview_cards.first.title).to eq('SJISのページ') end end @@ -39,7 +39,7 @@ RSpec.describe FetchLinkCardService, type: :service do it 'works with SJIS even with wrong charset header' do expect(a_request(:get, 'http://example.com/sjis_with_wrong_charset')).to have_been_made.at_least_once - expect(status.preview_cards.first.title).to eq("SJISのページ") + expect(status.preview_cards.first.title).to eq('SJISのページ') end end @@ -48,7 +48,7 @@ RSpec.describe FetchLinkCardService, type: :service do it 'works with koi8-r' do expect(a_request(:get, 'http://example.com/koi8-r')).to have_been_made.at_least_once - expect(status.preview_cards.first.title).to eq("Московя начинаетъ только въ XVI ст. привлекать внимане иностранцевъ.") + expect(status.preview_cards.first.title).to eq('Московя начинаетъ только въ XVI ст. привлекать внимане иностранцевъ.') end end @@ -66,7 +66,7 @@ RSpec.describe FetchLinkCardService, type: :service do it 'works with Japanese path string' do expect(a_request(:get, 'http://example.com/日本語')).to have_been_made.at_least_once - expect(status.preview_cards.first.title).to eq("SJISのページ") + expect(status.preview_cards.first.title).to eq('SJISのページ') end end diff --git a/spec/services/fetch_oembed_service_spec.rb b/spec/services/fetch_oembed_service_spec.rb index dcd0f80de..cf46f2d39 100644 --- a/spec/services/fetch_oembed_service_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -6,9 +6,9 @@ describe FetchOEmbedService, type: :service do subject { described_class.new } before do - stub_request(:get, "https://host.test/provider.json").to_return(status: 404) - stub_request(:get, "https://host.test/provider.xml").to_return(status: 404) - stub_request(:get, "https://host.test/empty_provider.json").to_return(status: 200) + stub_request(:get, 'https://host.test/provider.json').to_return(status: 404) + stub_request(:get, 'https://host.test/provider.xml').to_return(status: 404) + stub_request(:get, 'https://host.test/empty_provider.json').to_return(status: 200) end describe 'discover_provider' do diff --git a/spec/services/fetch_remote_status_service_spec.rb b/spec/services/fetch_remote_status_service_spec.rb index 4f6ad6496..02c62f8d6 100644 --- a/spec/services/fetch_remote_status_service_spec.rb +++ b/spec/services/fetch_remote_status_service_spec.rb @@ -7,7 +7,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do let(:note) do { '@context': 'https://www.w3.org/ns/activitystreams', - id: "https://example.org/@foo/1234", + id: 'https://example.org/@foo/1234', type: 'Note', content: 'Lorem ipsum', attributedTo: ActivityPub::TagManager.instance.uri_for(account), diff --git a/spec/services/follow_service_spec.rb b/spec/services/follow_service_spec.rb index 412c04d76..59073c27f 100644 --- a/spec/services/follow_service_spec.rb +++ b/spec/services/follow_service_spec.rb @@ -140,7 +140,7 @@ RSpec.describe FollowService, type: :service do let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') } before do - stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {}) + stub_request(:post, 'http://example.com/inbox').to_return(status: 200, body: '', headers: {}) subject.call(sender, bob) end diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index 399a43036..a12148833 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -8,7 +8,7 @@ RSpec.describe ImportService, type: :service do let!(:eve) { Fabricate(:account, username: 'eve', domain: 'example.com', locked: false, protocol: :activitypub, inbox_url: 'https://example.com/inbox') } before do - stub_request(:post, "https://example.com/inbox").to_return(status: 200) + stub_request(:post, 'https://example.com/inbox').to_return(status: 200) end context 'import old-style list of muted users' do @@ -186,7 +186,7 @@ RSpec.describe ImportService, type: :service do # Make sure to not actually go to the remote server before do - stub_request(:post, "https://թութ.հայ/inbox").to_return(status: 200) + stub_request(:post, 'https://թութ.հայ/inbox').to_return(status: 200) end let(:csv) { attachment_fixture('utf8-followers.txt') } diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 7bb7dfb1f..0b72253a5 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -5,7 +5,7 @@ RSpec.describe PostStatusService, type: :service do it 'creates a new status' do account = Fabricate(:account) - text = "test status update" + text = 'test status update' status = subject.call(account, text: text) @@ -16,7 +16,7 @@ RSpec.describe PostStatusService, type: :service do it 'creates a new response status' do in_reply_to_status = Fabricate(:status) account = Fabricate(:account) - text = "test status update" + text = 'test status update' status = subject.call(account, text: text, thread: in_reply_to_status) @@ -58,7 +58,7 @@ RSpec.describe PostStatusService, type: :service do boosted_status = Fabricate(:status) in_reply_to_status = Fabricate(:status, reblog: boosted_status) account = Fabricate(:account) - text = "test status update" + text = 'test status update' status = subject.call(account, text: text, thread: in_reply_to_status) @@ -75,7 +75,7 @@ RSpec.describe PostStatusService, type: :service do end it 'creates a status with spoiler text' do - spoiler_text = "spoiler text" + spoiler_text = 'spoiler text' status = create_status_with_options(spoiler_text: spoiler_text) @@ -101,14 +101,14 @@ RSpec.describe PostStatusService, type: :service do status = create_status_with_options(visibility: :private) expect(status).to be_persisted - expect(status.visibility).to eq "private" + expect(status.visibility).to eq 'private' end it 'creates a status with limited visibility for silenced users' do status = subject.call(Fabricate(:account, silenced: true), text: 'test', visibility: :public) expect(status).to be_persisted - expect(status.visibility).to eq "unlisted" + expect(status.visibility).to eq 'unlisted' end it 'creates a status for the given application' do @@ -135,7 +135,7 @@ RSpec.describe PostStatusService, type: :service do allow(ProcessMentionsService).to receive(:new).and_return(mention_service) account = Fabricate(:account) - status = subject.call(account, text: "test status update") + status = subject.call(account, text: 'test status update') expect(ProcessMentionsService).to have_received(:new) expect(mention_service).to have_received(:call).with(status, save_records: false) @@ -166,7 +166,7 @@ RSpec.describe PostStatusService, type: :service do allow(ProcessHashtagsService).to receive(:new).and_return(hashtags_service) account = Fabricate(:account) - status = subject.call(account, text: "test status update") + status = subject.call(account, text: 'test status update') expect(ProcessHashtagsService).to have_received(:new) expect(hashtags_service).to have_received(:call).with(status) @@ -178,7 +178,7 @@ RSpec.describe PostStatusService, type: :service do account = Fabricate(:account) - status = subject.call(account, text: "test status update") + status = subject.call(account, text: 'test status update') expect(DistributionWorker).to have_received(:perform_async).with(status.id) expect(ActivityPub::DistributionWorker).to have_received(:perform_async).with(status.id) @@ -188,7 +188,7 @@ RSpec.describe PostStatusService, type: :service do allow(LinkCrawlWorker).to receive(:perform_async) account = Fabricate(:account) - status = subject.call(account, text: "test status update") + status = subject.call(account, text: 'test status update') expect(LinkCrawlWorker).to have_received(:perform_async).with(status.id) end @@ -199,7 +199,7 @@ RSpec.describe PostStatusService, type: :service do status = subject.call( account, - text: "test status update", + text: 'test status update', media_ids: [media.id] ) @@ -212,7 +212,7 @@ RSpec.describe PostStatusService, type: :service do status = subject.call( account, - text: "test status update", + text: 'test status update', media_ids: [media.id] ) @@ -225,7 +225,7 @@ RSpec.describe PostStatusService, type: :service do expect do subject.call( account, - text: "test status update", + text: 'test status update', media_ids: [ Fabricate(:media_attachment, account: account), Fabricate(:media_attachment, account: account), @@ -250,7 +250,7 @@ RSpec.describe PostStatusService, type: :service do expect do subject.call( account, - text: "test status update", + text: 'test status update', media_ids: [ video, image, diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index 0dd62c807..6a16928e0 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -62,7 +62,7 @@ RSpec.describe ProcessMentionsService, type: :service do context 'with an IDN domain' do let!(:remote_user) { Fabricate(:account, username: 'sneak', protocol: :activitypub, domain: 'xn--hresiar-mxa.ch', inbox_url: 'http://example.com/inbox') } - let!(:status) { Fabricate(:status, account: account, text: "Hello @sneak@hæresiar.ch") } + let!(:status) { Fabricate(:status, account: account, text: 'Hello @sneak@hæresiar.ch') } before do subject.call(status) @@ -75,7 +75,7 @@ RSpec.describe ProcessMentionsService, type: :service do context 'with an IDN TLD' do let!(:remote_user) { Fabricate(:account, username: 'foo', protocol: :activitypub, domain: 'xn--y9a3aq.xn--y9a3aq', inbox_url: 'http://example.com/inbox') } - let!(:status) { Fabricate(:status, account: account, text: "Hello @foo@հայ.հայ") } + let!(:status) { Fabricate(:status, account: account, text: 'Hello @foo@հայ.հայ') } before do subject.call(status) @@ -91,8 +91,8 @@ RSpec.describe ProcessMentionsService, type: :service do let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox', last_webfingered_at: nil) } before do - stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404) - stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:remote_user@example.com").to_return(status: 500) + stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(status: 404) + stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:remote_user@example.com').to_return(status: 500) subject.call(status) end diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 1df30ea57..192225229 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -4,11 +4,11 @@ RSpec.describe ResolveAccountService, type: :service do subject { described_class.new } before do - stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404) - stub_request(:get, "https://quitter.no/avatar/7477-300-20160211190340.png").to_return(request_fixture('avatar.txt')) - stub_request(:get, "https://ap.example.com/.well-known/webfinger?resource=acct:foo@ap.example.com").to_return(request_fixture('activitypub-webfinger.txt')) - stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor.txt')) - stub_request(:get, "https://ap.example.com/users/foo.atom").to_return(request_fixture('activitypub-feed.txt')) + stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(status: 404) + stub_request(:get, 'https://quitter.no/avatar/7477-300-20160211190340.png').to_return(request_fixture('avatar.txt')) + stub_request(:get, 'https://ap.example.com/.well-known/webfinger?resource=acct:foo@ap.example.com').to_return(request_fixture('activitypub-webfinger.txt')) + stub_request(:get, 'https://ap.example.com/users/foo').to_return(request_fixture('activitypub-actor.txt')) + stub_request(:get, 'https://ap.example.com/users/foo.atom').to_return(request_fixture('activitypub-feed.txt')) stub_request(:get, %r{https://ap.example.com/users/foo/\w+}).to_return(status: 404) stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:hoge@example.com').to_return(status: 410) end @@ -56,8 +56,8 @@ RSpec.describe ResolveAccountService, type: :service do context 'when there is an LRDD endpoint but no resolvable account' do before do - stub_request(:get, "https://quitter.no/.well-known/host-meta").to_return(request_fixture('.host-meta.txt')) - stub_request(:get, "https://quitter.no/.well-known/webfinger?resource=acct:catsrgr8@quitter.no").to_return(status: 404) + stub_request(:get, 'https://quitter.no/.well-known/host-meta').to_return(request_fixture('.host-meta.txt')) + stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:catsrgr8@quitter.no').to_return(status: 404) end it 'returns nil' do @@ -67,7 +67,7 @@ RSpec.describe ResolveAccountService, type: :service do context 'when there is no LRDD endpoint nor resolvable account' do before do - stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:catsrgr8@example.com").to_return(status: 404) + stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:catsrgr8@example.com').to_return(status: 404) end it 'returns nil' do @@ -153,7 +153,7 @@ RSpec.describe ResolveAccountService, type: :service do context 'with multiple types' do before do - stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor-individual.txt')) + stub_request(:get, 'https://ap.example.com/users/foo').to_return(request_fixture('activitypub-actor-individual.txt')) end it 'returns new remote account' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 72c9ce8ae..97b8d83c5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ end gc_counter = -1 RSpec.configure do |config| - config.example_status_persistence_file_path = "tmp/rspec/examples.txt" + config.example_status_persistence_file_path = 'tmp/rspec/examples.txt' config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end @@ -60,7 +60,7 @@ end def expect_push_bulk_to_match(klass, matcher) expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({ - "class" => klass, - "args" => matcher, + 'class' => klass, + 'args' => matcher, })) end -- cgit From 21bf32635687770bc0026d769a69f49b89f8a0a2 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 20:28:40 -0500 Subject: Autofix Rubocop Rails/Pluck (#23730) --- .rubocop_todo.yml | 11 ----------- app/lib/importer/base_importer.rb | 2 +- app/lib/link_details_extractor.rb | 8 ++++---- app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb | 2 +- spec/controllers/api/v1/notifications_controller_spec.rb | 12 ++++++------ spec/controllers/api/v1/suggestions_controller_spec.rb | 2 +- .../webauthn_credentials_controller_spec.rb | 2 +- 7 files changed, 14 insertions(+), 25 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1a524e6fd..954e42f9e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2435,17 +2435,6 @@ Rails/Output: Exclude: - 'lib/mastodon/ip_blocks_cli.rb' -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). -Rails/Pluck: - Exclude: - - 'app/lib/importer/base_importer.rb' - - 'app/lib/link_details_extractor.rb' - - 'app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb' - - 'spec/controllers/api/v1/notifications_controller_spec.rb' - - 'spec/controllers/api/v1/suggestions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - # Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. diff --git a/app/lib/importer/base_importer.rb b/app/lib/importer/base_importer.rb index ea522c600..0cd1d3422 100644 --- a/app/lib/importer/base_importer.rb +++ b/app/lib/importer/base_importer.rb @@ -45,7 +45,7 @@ class Importer::BaseImporter # Remove documents from the index that no longer exist in the database def clean_up! index.scroll_batches do |documents| - ids = documents.map { |doc| doc['_id'] } + ids = documents.pluck('_id') existence_map = index.adapter.target.where(id: ids).pluck(:id).each_with_object({}) { |id, map| map[id.to_s] = true } tmp = ids.reject { |id| existence_map[id] } diff --git a/app/lib/link_details_extractor.rb b/app/lib/link_details_extractor.rb index 74a7d0f3b..f8a0be636 100644 --- a/app/lib/link_details_extractor.rb +++ b/app/lib/link_details_extractor.rb @@ -188,7 +188,7 @@ class LinkDetailsExtractor end def language - valid_locale_or_nil(structured_data&.language || opengraph_tag('og:locale') || document.xpath('//html').map { |element| element['lang'] }.first) + valid_locale_or_nil(structured_data&.language || opengraph_tag('og:locale') || document.xpath('//html').pick('lang')) end def icon @@ -220,15 +220,15 @@ class LinkDetailsExtractor end def link_tag(name) - document.xpath("//link[@rel=\"#{name}\"]").map { |link| link['href'] }.first + document.xpath("//link[@rel=\"#{name}\"]").pick('href') end def opengraph_tag(name) - document.xpath("//meta[@property=\"#{name}\" or @name=\"#{name}\"]").map { |meta| meta['content'] }.first + document.xpath("//meta[@property=\"#{name}\" or @name=\"#{name}\"]").pick('content') end def meta_tag(name) - document.xpath("//meta[@name=\"#{name}\"]").map { |meta| meta['content'] }.first + document.xpath("//meta[@name=\"#{name}\"]").pick('content') end def structured_data diff --git a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb index bd92fe32c..cc5b6e137 100644 --- a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb +++ b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb @@ -67,7 +67,7 @@ class Scheduler::AccountsStatusesCleanupScheduler end def compute_budget - threads = Sidekiq::ProcessSet.new.select { |x| x['queues'].include?('push') }.map { |x| x['concurrency'] }.sum + threads = Sidekiq::ProcessSet.new.select { |x| x['queues'].include?('push') }.pluck('concurrency').sum [PER_THREAD_BUDGET * threads, MAX_BUDGET].min end diff --git a/spec/controllers/api/v1/notifications_controller_spec.rb b/spec/controllers/api/v1/notifications_controller_spec.rb index 46e177c0e..22ebfa3dd 100644 --- a/spec/controllers/api/v1/notifications_controller_spec.rb +++ b/spec/controllers/api/v1/notifications_controller_spec.rb @@ -70,19 +70,19 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do end it 'includes reblog' do - expect(body_as_json.map { |x| x[:type] }).to include 'reblog' + expect(body_as_json.pluck(:type)).to include 'reblog' end it 'includes mention' do - expect(body_as_json.map { |x| x[:type] }).to include 'mention' + expect(body_as_json.pluck(:type)).to include 'mention' end it 'includes favourite' do - expect(body_as_json.map { |x| x[:type] }).to include 'favourite' + expect(body_as_json.pluck(:type)).to include 'favourite' end it 'includes follow' do - expect(body_as_json.map { |x| x[:type] }).to include 'follow' + expect(body_as_json.pluck(:type)).to include 'follow' end end @@ -125,7 +125,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do it 'returns everything but excluded type' do expect(body_as_json.size).to_not eq 0 - expect(body_as_json.map { |x| x[:type] }.uniq).to_not include 'mention' + expect(body_as_json.pluck(:type).uniq).to_not include 'mention' end end @@ -139,7 +139,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do end it 'returns only requested type' do - expect(body_as_json.map { |x| x[:type] }.uniq).to eq ['mention'] + expect(body_as_json.pluck(:type).uniq).to eq ['mention'] end end end diff --git a/spec/controllers/api/v1/suggestions_controller_spec.rb b/spec/controllers/api/v1/suggestions_controller_spec.rb index 7805b6b4f..35ba155e7 100644 --- a/spec/controllers/api/v1/suggestions_controller_spec.rb +++ b/spec/controllers/api/v1/suggestions_controller_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Api::V1::SuggestionsController, type: :controller do json = body_as_json expect(json.size).to be >= 1 - expect(json.map { |i| i[:id] }).to include(*[bob, jeff].map { |i| i.id.to_s }) + expect(json.pluck(:id)).to include(*[bob, jeff].map { |i| i.id.to_s }) end end end diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb index c3156c4e9..f060c3a4b 100644 --- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb @@ -140,7 +140,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do it 'includes existing credentials in list of excluded credentials' do get :options - excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].map { |credential| credential['id'] } + excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].pluck('id') expect(excluded_credentials_ids).to match_array(user.webauthn_credentials.pluck(:external_id)) end end -- cgit From a2fdb388eb412f3f90ec48bc990c7c2c24b8c072 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 20:32:10 -0500 Subject: Autofix Rubocop RSpec/ReturnFromStub (#23724) --- .rubocop_todo.yml | 13 ------------- .../api/v1/accounts/credentials_controller_spec.rb | 2 +- spec/controllers/api/v1/apps/credentials_controller_spec.rb | 2 +- .../v1/statuses/favourited_by_accounts_controller_spec.rb | 2 +- .../v1/statuses/reblogged_by_accounts_controller_spec.rb | 2 +- spec/controllers/api/v1/statuses_controller_spec.rb | 2 +- spec/validators/blacklisted_email_validator_spec.rb | 2 +- 7 files changed, 6 insertions(+), 19 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 954e42f9e..73ebdbfd8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1923,19 +1923,6 @@ RSpec/RepeatedExampleGroupDescription: - 'spec/controllers/admin/reports/actions_controller_spec.rb' - 'spec/policies/report_note_policy_spec.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: and_return, block -RSpec/ReturnFromStub: - Exclude: - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/apps/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses_controller_spec.rb' - - 'spec/validators/blacklisted_email_validator_spec.rb' - # Offense count: 18 # This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredLet: diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index d8aa00a07..a56b9d8fa 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -86,7 +86,7 @@ describe Api::V1::Accounts::CredentialsController do context 'without an oauth token' do before do - allow(controller).to receive(:doorkeeper_token) { nil } + allow(controller).to receive(:doorkeeper_token).and_return(nil) end describe 'GET #show' do diff --git a/spec/controllers/api/v1/apps/credentials_controller_spec.rb b/spec/controllers/api/v1/apps/credentials_controller_spec.rb index 0f811d5f3..470093c3c 100644 --- a/spec/controllers/api/v1/apps/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/apps/credentials_controller_spec.rb @@ -30,7 +30,7 @@ describe Api::V1::Apps::CredentialsController do context 'without an oauth token' do before do - allow(controller).to receive(:doorkeeper_token) { nil } + allow(controller).to receive(:doorkeeper_token).and_return(nil) end describe 'GET #show' do diff --git a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb index 4dcaba6bd..c1c6f5f12 100644 --- a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb @@ -45,7 +45,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control context 'without an oauth token' do before do - allow(controller).to receive(:doorkeeper_token) { nil } + allow(controller).to receive(:doorkeeper_token).and_return(nil) end context 'with a private status' do diff --git a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb index dc36d4ca0..90187a585 100644 --- a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb @@ -45,7 +45,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll context 'without an oauth token' do before do - allow(controller).to receive(:doorkeeper_token) { nil } + allow(controller).to receive(:doorkeeper_token).and_return(nil) end context 'with a private status' do diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index e4e6e172a..e839c8494 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -219,7 +219,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do context 'without an oauth token' do before do - allow(controller).to receive(:doorkeeper_token) { nil } + allow(controller).to receive(:doorkeeper_token).and_return(nil) end context 'with a private status' do diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb index 351de0707..f9ee3b932 100644 --- a/spec/validators/blacklisted_email_validator_spec.rb +++ b/spec/validators/blacklisted_email_validator_spec.rb @@ -8,7 +8,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do let(:errors) { double(add: nil) } before do - allow(user).to receive(:valid_invitation?) { false } + allow(user).to receive(:valid_invitation?).and_return(false) allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email } end -- cgit From aef0051fd0723ff03175a8851497056ed07d1a83 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 21:16:40 -0500 Subject: Enable Rubocop HTTP status rules (#23717) --- .rubocop.yml | 6 + .rubocop_todo.yml | 171 --------------------- app/controllers/api/v1/accounts_controller.rb | 2 +- .../api/v1/emails/confirmations_controller.rb | 4 +- app/controllers/auth/sessions_controller.rb | 4 +- .../concerns/two_factor_authentication_concern.rb | 4 +- .../webauthn_credentials_controller.rb | 2 +- spec/controllers/admin/accounts_controller_spec.rb | 22 +-- spec/controllers/admin/base_controller_spec.rb | 2 +- .../controllers/admin/instances_controller_spec.rb | 2 +- spec/controllers/admin/roles_controller_spec.rb | 16 +- spec/controllers/admin/users/roles_controller.rb | 4 +- .../api/v1/accounts/credentials_controller_spec.rb | 6 +- .../api/v1/accounts/statuses_controller_spec.rb | 10 +- .../v1/announcements/reactions_controller_spec.rb | 4 +- .../api/v1/announcements_controller_spec.rb | 4 +- .../api/v1/apps/credentials_controller_spec.rb | 2 +- .../api/v1/bookmarks_controller_spec.rb | 6 +- .../api/v1/emails/confirmations_controller_spec.rb | 6 +- .../api/v1/favourites_controller_spec.rb | 6 +- spec/controllers/api/v1/media_controller_spec.rb | 6 +- .../api/v1/timelines/home_controller_spec.rb | 2 +- .../api/v1/timelines/list_controller_spec.rb | 4 +- spec/controllers/api/web/embeds_controller_spec.rb | 6 +- .../auth/registrations_controller_spec.rb | 2 +- spec/controllers/auth/sessions_controller_spec.rb | 2 +- .../concerns/export_controller_concern_spec.rb | 2 +- .../disputes/strikes_controller_spec.rb | 2 +- .../settings/applications_controller_spec.rb | 2 +- .../settings/sessions_controller_spec.rb | 2 +- spec/controllers/shares_controller_spec.rb | 2 +- spec/requests/catch_all_route_request_spec.rb | 4 +- 32 files changed, 77 insertions(+), 242 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop.yml b/.rubocop.yml index fc1969a64..512c8458f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -88,6 +88,9 @@ Metrics/ModuleLength: Metrics/PerceivedComplexity: Max: 16 # RuboCop default 8 +Rails/HttpStatus: + EnforcedStyle: numeric + Rails/Exit: Exclude: - 'lib/mastodon/*_cli.rb' @@ -97,6 +100,9 @@ Rails/Exit: RSpec/NotToNot: EnforcedStyle: to_not +RSpec/Rails/HttpStatus: + EnforcedStyle: numeric + Style/HashSyntax: EnforcedStyle: ruby19_no_mixed_keys diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 02f84e70f..521608de6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1427,148 +1427,6 @@ RSpec/PredicateMatcher: - 'spec/models/user_spec.rb' - 'spec/services/post_status_service_spec.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/Rails/HaveHttpStatus: - Exclude: - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/requests/catch_all_route_request_spec.rb' - -# Offense count: 432 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: numeric, symbolic -RSpec/Rails/HttpStatus: - Exclude: - - 'spec/controllers/about_controller_spec.rb' - - 'spec/controllers/accounts_controller_spec.rb' - - 'spec/controllers/activitypub/collections_controller_spec.rb' - - 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb' - - 'spec/controllers/activitypub/inboxes_controller_spec.rb' - - 'spec/controllers/activitypub/outboxes_controller_spec.rb' - - 'spec/controllers/activitypub/replies_controller_spec.rb' - - 'spec/controllers/admin/accounts_controller_spec.rb' - - 'spec/controllers/admin/action_logs_controller_spec.rb' - - 'spec/controllers/admin/change_email_controller_spec.rb' - - 'spec/controllers/admin/confirmations_controller_spec.rb' - - 'spec/controllers/admin/custom_emojis_controller_spec.rb' - - 'spec/controllers/admin/dashboard_controller_spec.rb' - - 'spec/controllers/admin/domain_allows_controller_spec.rb' - - 'spec/controllers/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/admin/email_domain_blocks_controller_spec.rb' - - 'spec/controllers/admin/export_domain_allows_controller_spec.rb' - - 'spec/controllers/admin/export_domain_blocks_controller_spec.rb' - - 'spec/controllers/admin/instances_controller_spec.rb' - - 'spec/controllers/admin/reports/actions_controller_spec.rb' - - 'spec/controllers/admin/reports_controller_spec.rb' - - 'spec/controllers/admin/settings/branding_controller_spec.rb' - - 'spec/controllers/admin/statuses_controller_spec.rb' - - 'spec/controllers/admin/tags_controller_spec.rb' - - 'spec/controllers/api/base_controller_spec.rb' - - 'spec/controllers/api/oembed_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/lists_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/notes_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/pins_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/relationships_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/search_controller_spec.rb' - - 'spec/controllers/api/v1/accounts_controller_spec.rb' - - 'spec/controllers/api/v1/admin/account_actions_controller_spec.rb' - - 'spec/controllers/api/v1/admin/accounts_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_allows_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/api/v1/admin/reports_controller_spec.rb' - - 'spec/controllers/api/v1/announcements/reactions_controller_spec.rb' - - 'spec/controllers/api/v1/announcements_controller_spec.rb' - - 'spec/controllers/api/v1/apps/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/apps_controller_spec.rb' - - 'spec/controllers/api/v1/blocks_controller_spec.rb' - - 'spec/controllers/api/v1/conversations_controller_spec.rb' - - 'spec/controllers/api/v1/custom_emojis_controller_spec.rb' - - 'spec/controllers/api/v1/domain_blocks_controller_spec.rb' - - 'spec/controllers/api/v1/endorsements_controller_spec.rb' - - 'spec/controllers/api/v1/filters_controller_spec.rb' - - 'spec/controllers/api/v1/follow_requests_controller_spec.rb' - - 'spec/controllers/api/v1/instances/activity_controller_spec.rb' - - 'spec/controllers/api/v1/instances/peers_controller_spec.rb' - - 'spec/controllers/api/v1/instances_controller_spec.rb' - - 'spec/controllers/api/v1/lists/accounts_controller_spec.rb' - - 'spec/controllers/api/v1/lists_controller_spec.rb' - - 'spec/controllers/api/v1/markers_controller_spec.rb' - - 'spec/controllers/api/v1/media_controller_spec.rb' - - 'spec/controllers/api/v1/mutes_controller_spec.rb' - - 'spec/controllers/api/v1/notifications_controller_spec.rb' - - 'spec/controllers/api/v1/polls/votes_controller_spec.rb' - - 'spec/controllers/api/v1/polls_controller_spec.rb' - - 'spec/controllers/api/v1/reports_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/bookmarks_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/favourites_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/histories_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/mutes_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/pins_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/reblogs_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/sources_controller_spec.rb' - - 'spec/controllers/api/v1/statuses_controller_spec.rb' - - 'spec/controllers/api/v1/streaming_controller_spec.rb' - - 'spec/controllers/api/v1/suggestions_controller_spec.rb' - - 'spec/controllers/api/v1/timelines/home_controller_spec.rb' - - 'spec/controllers/api/v1/timelines/list_controller_spec.rb' - - 'spec/controllers/api/v1/timelines/public_controller_spec.rb' - - 'spec/controllers/api/v1/timelines/tag_controller_spec.rb' - - 'spec/controllers/api/v1/trends/tags_controller_spec.rb' - - 'spec/controllers/api/v2/admin/accounts_controller_spec.rb' - - 'spec/controllers/api/v2/filters/keywords_controller_spec.rb' - - 'spec/controllers/api/v2/filters/statuses_controller_spec.rb' - - 'spec/controllers/api/v2/filters_controller_spec.rb' - - 'spec/controllers/api/v2/search_controller_spec.rb' - - 'spec/controllers/api/web/settings_controller_spec.rb' - - 'spec/controllers/application_controller_spec.rb' - - 'spec/controllers/auth/confirmations_controller_spec.rb' - - 'spec/controllers/auth/passwords_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/auth/sessions_controller_spec.rb' - - 'spec/controllers/authorize_interactions_controller_spec.rb' - - 'spec/controllers/concerns/account_controller_concern_spec.rb' - - 'spec/controllers/concerns/export_controller_concern_spec.rb' - - 'spec/controllers/concerns/signature_verification_spec.rb' - - 'spec/controllers/emojis_controller_spec.rb' - - 'spec/controllers/follower_accounts_controller_spec.rb' - - 'spec/controllers/following_accounts_controller_spec.rb' - - 'spec/controllers/instance_actors_controller_spec.rb' - - 'spec/controllers/intents_controller_spec.rb' - - 'spec/controllers/invites_controller_spec.rb' - - 'spec/controllers/manifests_controller_spec.rb' - - 'spec/controllers/media_controller_spec.rb' - - 'spec/controllers/media_proxy_controller_spec.rb' - - 'spec/controllers/oauth/authorizations_controller_spec.rb' - - 'spec/controllers/oauth/authorized_applications_controller_spec.rb' - - 'spec/controllers/relationships_controller_spec.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/controllers/settings/deletes_controller_spec.rb' - - 'spec/controllers/settings/exports_controller_spec.rb' - - 'spec/controllers/settings/imports_controller_spec.rb' - - 'spec/controllers/settings/migrations_controller_spec.rb' - - 'spec/controllers/settings/preferences/notifications_controller_spec.rb' - - 'spec/controllers/settings/preferences/other_controller_spec.rb' - - 'spec/controllers/settings/profiles_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/otp_authentication_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication_methods_controller_spec.rb' - - 'spec/controllers/statuses_cleanup_controller_spec.rb' - - 'spec/controllers/statuses_controller_spec.rb' - - 'spec/controllers/tags_controller_spec.rb' - - 'spec/controllers/well_known/host_meta_controller_spec.rb' - - 'spec/controllers/well_known/nodeinfo_controller_spec.rb' - - 'spec/controllers/well_known/webfinger_controller_spec.rb' - - 'spec/requests/host_meta_request_spec.rb' - - 'spec/requests/webfinger_request_spec.rb' - # Offense count: 180 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Inferences. @@ -2159,35 +2017,6 @@ Rails/HttpPositionalArguments: Exclude: - 'spec/config/initializers/rack_attack_spec.rb' -# Offense count: 49 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: numeric, symbolic -Rails/HttpStatus: - Exclude: - - 'app/controllers/activitypub/inboxes_controller.rb' - - 'app/controllers/api/base_controller.rb' - - 'app/controllers/api/v1/admin/domain_blocks_controller.rb' - - 'app/controllers/api/v1/instances/activity_controller.rb' - - 'app/controllers/api/v1/instances/domain_blocks_controller.rb' - - 'app/controllers/api/v1/instances/peers_controller.rb' - - 'app/controllers/api/v1/lists_controller.rb' - - 'app/controllers/api/v1/markers_controller.rb' - - 'app/controllers/api/v1/media_controller.rb' - - 'app/controllers/api/v1/statuses_controller.rb' - - 'app/controllers/api/v1/streaming_controller.rb' - - 'app/controllers/api/v2/media_controller.rb' - - 'app/controllers/api/v2/search_controller.rb' - - 'app/controllers/api/web/base_controller.rb' - - 'app/controllers/settings/pictures_controller.rb' - - 'app/controllers/well_known/webfinger_controller.rb' - - 'spec/controllers/api/base_controller_spec.rb' - - 'spec/controllers/application_controller_spec.rb' - - 'spec/controllers/concerns/account_controller_concern_spec.rb' - - 'spec/controllers/concerns/localized_spec.rb' - - 'spec/controllers/concerns/rate_limit_headers_spec.rb' - - 'spec/controllers/concerns/signature_verification_spec.rb' - # Offense count: 7 # Configuration parameters: Include. # Include: spec/**/*.rb, test/**/*.rb diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index be84720aa..7dff66efa 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -30,7 +30,7 @@ class Api::V1::AccountsController < Api::BaseController self.response_body = Oj.dump(response.body) self.status = response.status rescue ActiveRecord::RecordInvalid => e - render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: :unprocessable_entity + render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: 422 end def follow diff --git a/app/controllers/api/v1/emails/confirmations_controller.rb b/app/controllers/api/v1/emails/confirmations_controller.rb index 3faaea2fb..32fb8e39f 100644 --- a/app/controllers/api/v1/emails/confirmations_controller.rb +++ b/app/controllers/api/v1/emails/confirmations_controller.rb @@ -15,10 +15,10 @@ class Api::V1::Emails::ConfirmationsController < Api::BaseController private def require_user_owned_by_application! - render json: { error: 'This method is only available to the application the user originally signed-up with' }, status: :forbidden unless current_user && current_user.created_by_application_id == doorkeeper_token.application_id + render json: { error: 'This method is only available to the application the user originally signed-up with' }, status: 403 unless current_user && current_user.created_by_application_id == doorkeeper_token.application_id end def require_user_not_confirmed! - render json: { error: 'This method is only available while the e-mail is awaiting confirmation' }, status: :forbidden unless !current_user.confirmed? || current_user.unconfirmed_email.present? + render json: { error: 'This method is only available while the e-mail is awaiting confirmation' }, status: 403 unless !current_user.confirmed? || current_user.unconfirmed_email.present? end end diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 3ce742638..4f59fd501 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -52,9 +52,9 @@ class Auth::SessionsController < Devise::SessionsController session[:webauthn_challenge] = options_for_get.challenge - render json: options_for_get, status: :ok + render json: options_for_get, status: 200 else - render json: { error: t('webauthn_credentials.not_enabled') }, status: :unauthorized + render json: { error: t('webauthn_credentials.not_enabled') }, status: 401 end end diff --git a/app/controllers/concerns/two_factor_authentication_concern.rb b/app/controllers/concerns/two_factor_authentication_concern.rb index e69b67a79..94f3ce00f 100644 --- a/app/controllers/concerns/two_factor_authentication_concern.rb +++ b/app/controllers/concerns/two_factor_authentication_concern.rb @@ -57,10 +57,10 @@ module TwoFactorAuthenticationConcern if valid_webauthn_credential?(user, webauthn_credential) on_authentication_success(user, :webauthn) - render json: { redirect_path: after_sign_in_path_for(user) }, status: :ok + render json: { redirect_path: after_sign_in_path_for(user) }, status: 200 else on_authentication_failure(user, :webauthn, :invalid_credential) - render json: { error: t('webauthn_credentials.invalid_credential') }, status: :unprocessable_entity + render json: { error: t('webauthn_credentials.invalid_credential') }, status: 422 end end diff --git a/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb b/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb index a50d30f06..e43818c94 100644 --- a/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb +++ b/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb @@ -27,7 +27,7 @@ module Settings session[:webauthn_challenge] = options_for_create.challenge - render json: options_for_create, status: :ok + render json: options_for_create, status: 200 end def create diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 35d79740a..f5d68a8ad 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -83,7 +83,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:target_role) { UserRole.find_by(name: 'Admin') } it 'fails to memorialize account' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 expect(account.reload).to_not be_memorial end end @@ -105,7 +105,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:target_role) { UserRole.find_by(name: 'Admin') } it 'fails to memorialize account' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 expect(account.reload).to_not be_memorial end end @@ -114,7 +114,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:target_role) { UserRole.find_by(name: 'Moderator') } it 'fails to memorialize account' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 expect(account.reload).to_not be_memorial end end @@ -141,7 +141,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:role) { UserRole.everyone } it 'fails to enable account' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 expect(user.reload).to be_disabled end end @@ -167,7 +167,7 @@ RSpec.describe Admin::AccountsController, type: :controller do end it 'logs action' do - is_expected.to have_http_status :found + is_expected.to have_http_status 302 log_item = Admin::ActionLog.last @@ -182,7 +182,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:role) { UserRole.everyone } it 'fails to approve account' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 expect(user.reload).to_not be_approved end end @@ -207,7 +207,7 @@ RSpec.describe Admin::AccountsController, type: :controller do end it 'logs action' do - is_expected.to have_http_status :found + is_expected.to have_http_status 302 log_item = Admin::ActionLog.last @@ -222,7 +222,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:role) { UserRole.everyone } it 'fails to reject account' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 expect(user.reload).to_not be_approved end end @@ -250,7 +250,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:role) { UserRole.everyone } it 'fails to redownload' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 end end end @@ -273,7 +273,7 @@ RSpec.describe Admin::AccountsController, type: :controller do let(:role) { UserRole.everyone } it 'fails to remove avatar' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 end end end @@ -303,7 +303,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to remove avatar' do subject - expect(response).to have_http_status :forbidden + expect(response).to have_http_status 403 end end end diff --git a/spec/controllers/admin/base_controller_spec.rb b/spec/controllers/admin/base_controller_spec.rb index 44be91951..5fbf8777c 100644 --- a/spec/controllers/admin/base_controller_spec.rb +++ b/spec/controllers/admin/base_controller_spec.rb @@ -15,7 +15,7 @@ describe Admin::BaseController, type: :controller do sign_in(Fabricate(:user)) get :success - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end it 'renders admin layout as a moderator' do diff --git a/spec/controllers/admin/instances_controller_spec.rb b/spec/controllers/admin/instances_controller_spec.rb index 337f7a80c..a7e348b1c 100644 --- a/spec/controllers/admin/instances_controller_spec.rb +++ b/spec/controllers/admin/instances_controller_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Admin::InstancesController, type: :controller do let(:role) { nil } it 'fails to purge instance' do - is_expected.to have_http_status :forbidden + is_expected.to have_http_status 403 end end end diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb index 8ff891205..e2b1030d9 100644 --- a/spec/controllers/admin/roles_controller_spec.rb +++ b/spec/controllers/admin/roles_controller_spec.rb @@ -18,7 +18,7 @@ describe Admin::RolesController do context 'when user does not have permission to manage roles' do it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end @@ -38,7 +38,7 @@ describe Admin::RolesController do context 'when user does not have permission to manage roles' do it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end @@ -128,7 +128,7 @@ describe Admin::RolesController do context 'when user does not have permission to manage roles' do it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end @@ -145,7 +145,7 @@ describe Admin::RolesController do let(:role_position) { current_role.position + 1 } it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end end @@ -165,7 +165,7 @@ describe Admin::RolesController do context 'when user does not have permission to manage roles' do it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end it 'does not update the role' do @@ -203,7 +203,7 @@ describe Admin::RolesController do let(:role_position) { current_role.position + 1 } it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end it 'does not update the role' do @@ -224,7 +224,7 @@ describe Admin::RolesController do context 'when user does not have permission to manage roles' do it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end @@ -241,7 +241,7 @@ describe Admin::RolesController do let(:role_position) { current_role.position + 1 } it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end end diff --git a/spec/controllers/admin/users/roles_controller.rb b/spec/controllers/admin/users/roles_controller.rb index bd6a3fa67..9fa8aef41 100644 --- a/spec/controllers/admin/users/roles_controller.rb +++ b/spec/controllers/admin/users/roles_controller.rb @@ -26,7 +26,7 @@ describe Admin::Users::RolesController do let(:previous_role) { UserRole.create(name: 'Baz', permissions: UserRole::FLAGS[:administrator], position: 100) } it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end end @@ -74,7 +74,7 @@ describe Admin::Users::RolesController do end it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index a56b9d8fa..cf91aae38 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -78,7 +78,7 @@ describe Api::V1::Accounts::CredentialsController do end it 'returns http unprocessable entity' do - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(422) end end end @@ -92,14 +92,14 @@ describe Api::V1::Accounts::CredentialsController do describe 'GET #show' do it 'returns http unauthorized' do get :show - expect(response).to have_http_status(:unauthorized) + expect(response).to have_http_status(401) end end describe 'PATCH #update' do it 'returns http unauthorized' do patch :update, params: { note: 'Foo' } - expect(response).to have_http_status(:unauthorized) + expect(response).to have_http_status(401) end end end diff --git a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb index 01d745fc0..4630fac90 100644 --- a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb @@ -16,7 +16,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, limit: 1 } - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(200) end it 'returns expected headers' do @@ -29,7 +29,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, only_media: true } - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(200) end end @@ -44,7 +44,7 @@ describe Api::V1::Accounts::StatusesController do end it 'returns http success' do - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(200) end it 'returns posts along with self replies' do @@ -63,7 +63,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, pinned: true } - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(200) end end @@ -79,7 +79,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: account.id, pinned: true } - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(200) end context 'when user does not follow account' do diff --git a/spec/controllers/api/v1/announcements/reactions_controller_spec.rb b/spec/controllers/api/v1/announcements/reactions_controller_spec.rb index 72620e242..25c52aa1d 100644 --- a/spec/controllers/api/v1/announcements/reactions_controller_spec.rb +++ b/spec/controllers/api/v1/announcements/reactions_controller_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Api::V1::Announcements::ReactionsController, type: :controller do context 'without token' do it 'returns http unauthorized' do put :update, params: { announcement_id: announcement.id, id: '😂' } - expect(response).to have_http_status :unauthorized + expect(response).to have_http_status 401 end end @@ -43,7 +43,7 @@ RSpec.describe Api::V1::Announcements::ReactionsController, type: :controller do context 'without token' do it 'returns http unauthorized' do delete :destroy, params: { announcement_id: announcement.id, id: '😂' } - expect(response).to have_http_status :unauthorized + expect(response).to have_http_status 401 end end diff --git a/spec/controllers/api/v1/announcements_controller_spec.rb b/spec/controllers/api/v1/announcements_controller_spec.rb index 6ee46b60e..eaab2abd8 100644 --- a/spec/controllers/api/v1/announcements_controller_spec.rb +++ b/spec/controllers/api/v1/announcements_controller_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Api::V1::AnnouncementsController, type: :controller do context 'without token' do it 'returns http unprocessable entity' do get :index - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status 422 end end @@ -35,7 +35,7 @@ RSpec.describe Api::V1::AnnouncementsController, type: :controller do context 'without token' do it 'returns http unauthorized' do post :dismiss, params: { id: announcement.id } - expect(response).to have_http_status :unauthorized + expect(response).to have_http_status 401 end end diff --git a/spec/controllers/api/v1/apps/credentials_controller_spec.rb b/spec/controllers/api/v1/apps/credentials_controller_spec.rb index 470093c3c..701ba8acb 100644 --- a/spec/controllers/api/v1/apps/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/apps/credentials_controller_spec.rb @@ -36,7 +36,7 @@ describe Api::V1::Apps::CredentialsController do describe 'GET #show' do it 'returns http unauthorized' do get :show - expect(response).to have_http_status(:unauthorized) + expect(response).to have_http_status(401) end end end diff --git a/spec/controllers/api/v1/bookmarks_controller_spec.rb b/spec/controllers/api/v1/bookmarks_controller_spec.rb index d7c5847b0..279d1a435 100644 --- a/spec/controllers/api/v1/bookmarks_controller_spec.rb +++ b/spec/controllers/api/v1/bookmarks_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do context 'without token' do it 'returns http unauthorized' do get :index - expect(response).to have_http_status :unauthorized + expect(response).to have_http_status 401 end end @@ -24,7 +24,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do it 'returns http forbidden' do get :index - expect(response).to have_http_status :forbidden + expect(response).to have_http_status 403 end end @@ -38,7 +38,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do it 'returns http unprocessable entity' do get :index - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status 422 end end diff --git a/spec/controllers/api/v1/emails/confirmations_controller_spec.rb b/spec/controllers/api/v1/emails/confirmations_controller_spec.rb index 15ac31cbc..d272ff38d 100644 --- a/spec/controllers/api/v1/emails/confirmations_controller_spec.rb +++ b/spec/controllers/api/v1/emails/confirmations_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do context 'from a random app' do it 'returns http forbidden' do post :create - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end @@ -30,7 +30,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do it 'returns http forbidden' do post :create - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end context 'but user changed e-mail and has not confirmed it' do @@ -57,7 +57,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do context 'without an oauth token' do it 'returns http unauthorized' do post :create - expect(response).to have_http_status(:unauthorized) + expect(response).to have_http_status(401) end end end diff --git a/spec/controllers/api/v1/favourites_controller_spec.rb b/spec/controllers/api/v1/favourites_controller_spec.rb index 231f76500..512dd0c0d 100644 --- a/spec/controllers/api/v1/favourites_controller_spec.rb +++ b/spec/controllers/api/v1/favourites_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do context 'without token' do it 'returns http unauthorized' do get :index - expect(response).to have_http_status :unauthorized + expect(response).to have_http_status 401 end end @@ -24,7 +24,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do it 'returns http forbidden' do get :index - expect(response).to have_http_status :forbidden + expect(response).to have_http_status 403 end end @@ -38,7 +38,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do it 'returns http unprocessable entity' do get :index - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status 422 end end diff --git a/spec/controllers/api/v1/media_controller_spec.rb b/spec/controllers/api/v1/media_controller_spec.rb index a1f6ddb24..ef1e439f9 100644 --- a/spec/controllers/api/v1/media_controller_spec.rb +++ b/spec/controllers/api/v1/media_controller_spec.rb @@ -19,7 +19,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do end it 'returns http 422' do - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(422) end end @@ -106,7 +106,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do it 'returns http not found' do put :update, params: { id: media.id, description: 'Lorem ipsum!!!' } - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(404) end end @@ -126,7 +126,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do let(:status) { Fabricate(:status, account: user.account) } it 'returns http not found' do - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(404) end end end diff --git a/spec/controllers/api/v1/timelines/home_controller_spec.rb b/spec/controllers/api/v1/timelines/home_controller_spec.rb index 131c2d92f..bb46d0aba 100644 --- a/spec/controllers/api/v1/timelines/home_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/home_controller_spec.rb @@ -36,7 +36,7 @@ describe Api::V1::Timelines::HomeController do it 'returns http unprocessable entity' do get :show - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(422) expect(response.headers['Link']).to be_nil end end diff --git a/spec/controllers/api/v1/timelines/list_controller_spec.rb b/spec/controllers/api/v1/timelines/list_controller_spec.rb index 526c66a05..4ef5d41af 100644 --- a/spec/controllers/api/v1/timelines/list_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/list_controller_spec.rb @@ -36,7 +36,7 @@ describe Api::V1::Timelines::ListController do describe 'GET #show' do it 'returns http not found' do get :show, params: { id: list.id } - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(404) end end end @@ -48,7 +48,7 @@ describe Api::V1::Timelines::ListController do it 'returns http unprocessable entity' do get :show, params: { id: list.id } - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(422) expect(response.headers['Link']).to be_nil end end diff --git a/spec/controllers/api/web/embeds_controller_spec.rb b/spec/controllers/api/web/embeds_controller_spec.rb index b3ef73915..e03f5a371 100644 --- a/spec/controllers/api/web/embeds_controller_spec.rb +++ b/spec/controllers/api/web/embeds_controller_spec.rb @@ -19,7 +19,7 @@ describe Api::Web::EmbedsController do let(:url) { "http://#{Rails.configuration.x.web_domain}/@#{status.account.username}/#{status.id}" } it 'returns a right response' do - expect(response).to have_http_status :ok + expect(response).to have_http_status 200 expect(body[:author_name]).to eq status.account.username end end @@ -37,7 +37,7 @@ describe Api::Web::EmbedsController do let(:call_result) { { result: :ok } } it 'returns a right response' do - expect(response).to have_http_status :ok + expect(response).to have_http_status 200 expect(body[:result]).to eq 'ok' end end @@ -46,7 +46,7 @@ describe Api::Web::EmbedsController do let(:call_result) { nil } it 'returns a right response' do - expect(response).to have_http_status :not_found + expect(response).to have_http_status 404 end end end diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 7298bde00..52023eb2e 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -245,7 +245,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end it 'returns http not found' do - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(404) end it 'does not delete user' do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index eb03dff50..58befa124 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -422,7 +422,7 @@ RSpec.describe Auth::SessionsController, type: :controller do it 'returns http success' do get :webauthn_options - expect(response).to have_http_status :ok + expect(response).to have_http_status 200 end end end diff --git a/spec/controllers/concerns/export_controller_concern_spec.rb b/spec/controllers/concerns/export_controller_concern_spec.rb index 1a5e46f8e..003fd17f6 100644 --- a/spec/controllers/concerns/export_controller_concern_spec.rb +++ b/spec/controllers/concerns/export_controller_concern_spec.rb @@ -29,7 +29,7 @@ describe ApplicationController, type: :controller do it 'returns unauthorized when not signed in' do get :index, format: :csv - expect(response).to have_http_status(:unauthorized) + expect(response).to have_http_status(401) end end end diff --git a/spec/controllers/disputes/strikes_controller_spec.rb b/spec/controllers/disputes/strikes_controller_spec.rb index 157f9ec3c..e060d37ac 100644 --- a/spec/controllers/disputes/strikes_controller_spec.rb +++ b/spec/controllers/disputes/strikes_controller_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Disputes::StrikesController, type: :controller do let(:strike) { Fabricate(:account_warning) } it 'returns http forbidden' do - expect(response).to have_http_status(:forbidden) + expect(response).to have_http_status(403) end end end diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 35ad4b2e7..33d874d10 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -32,7 +32,7 @@ describe Settings::ApplicationsController do app.update!(owner: nil) get :show, params: { id: app.id } - expect(response.status).to eq 404 + expect(response).to have_http_status 404 end end diff --git a/spec/controllers/settings/sessions_controller_spec.rb b/spec/controllers/settings/sessions_controller_spec.rb index 0e312c5a6..59c18889e 100644 --- a/spec/controllers/settings/sessions_controller_spec.rb +++ b/spec/controllers/settings/sessions_controller_spec.rb @@ -24,7 +24,7 @@ describe Settings::SessionsController do let(:id) { session_activation.id + 1000 } it 'destroys session activation' do - is_expected.to have_http_status :not_found + is_expected.to have_http_status 404 end end end diff --git a/spec/controllers/shares_controller_spec.rb b/spec/controllers/shares_controller_spec.rb index e365b356e..0fde8c692 100644 --- a/spec/controllers/shares_controller_spec.rb +++ b/spec/controllers/shares_controller_spec.rb @@ -13,7 +13,7 @@ describe SharesController do before { get :show, params: { title: 'test title', text: 'test text', url: 'url1 url2' } } it 'returns http success' do - expect(response).to have_http_status :ok + expect(response).to have_http_status 200 expect(body_classes).to eq 'modal-layout compose-standalone' end end diff --git a/spec/requests/catch_all_route_request_spec.rb b/spec/requests/catch_all_route_request_spec.rb index fb18965d8..dcfc1bf4b 100644 --- a/spec/requests/catch_all_route_request_spec.rb +++ b/spec/requests/catch_all_route_request_spec.rb @@ -5,7 +5,7 @@ describe 'The catch all route' do it 'returns a 404 page as html' do get '/test' - expect(response.status).to eq 404 + expect(response).to have_http_status 404 expect(response.media_type).to eq 'text/html' end end @@ -14,7 +14,7 @@ describe 'The catch all route' do it 'returns a 404 page as html' do get '/test.test' - expect(response.status).to eq 404 + expect(response).to have_http_status 404 expect(response.media_type).to eq 'text/html' end end -- cgit From 5179c47087e7807162f1466ec61a797586de007f Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 21:17:41 -0500 Subject: Autofix Rubocops RSpec/ScatteredLet (#23725) --- .rubocop_todo.yml | 13 ------ .../admin/domain_blocks_controller_spec.rb | 9 ++--- .../api/v1/admin/domain_blocks_controller_spec.rb | 9 ++--- .../api/v1/push/subscriptions_controller_spec.rb | 14 +++---- spec/lib/activitypub/activity/create_spec.rb | 46 ++++++++++------------ spec/lib/vacuum/media_attachments_vacuum_spec.rb | 5 +-- .../process_status_update_service_spec.rb | 28 ++++++------- spec/services/fan_out_on_write_service_spec.rb | 3 +- spec/services/import_service_spec.rb | 12 +++--- 9 files changed, 56 insertions(+), 83 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 521608de6..308e0e69e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1629,19 +1629,6 @@ RSpec/RepeatedExampleGroupDescription: - 'spec/controllers/admin/reports/actions_controller_spec.rb' - 'spec/policies/report_note_policy_spec.rb' -# Offense count: 18 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ScatteredLet: - Exclude: - - 'spec/controllers/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/api/v1/push/subscriptions_controller_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/vacuum/media_attachments_vacuum_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/fan_out_on_write_service_spec.rb' - - 'spec/services/import_service_spec.rb' - # Offense count: 12 RSpec/ScatteredSetup: Exclude: diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index 92fc19efa..d58a0cafc 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -72,16 +72,15 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do describe 'PUT #update' do let!(:remote_account) { Fabricate(:account, domain: 'example.com') } - let(:domain_block) { Fabricate(:domain_block, domain: 'example.com', severity: original_severity) } + let(:subject) do + post :update, params: { id: domain_block.id, domain_block: { domain: 'example.com', severity: new_severity } } + end + let(:domain_block) { Fabricate(:domain_block, domain: 'example.com', severity: original_severity) } before do BlockDomainService.new.call(domain_block) end - let(:subject) do - post :update, params: { id: domain_block.id, domain_block: { domain: 'example.com', severity: new_severity } } - end - context 'downgrading a domain suspension to silence' do let(:original_severity) { 'suspend' } let(:new_severity) { 'silence' } diff --git a/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb b/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb index 606def602..b367ab9ce 100644 --- a/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb @@ -73,16 +73,15 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do describe 'PUT #update' do let!(:remote_account) { Fabricate(:account, domain: 'example.com') } - let(:domain_block) { Fabricate(:domain_block, domain: 'example.com', severity: original_severity) } + let(:subject) do + post :update, params: { id: domain_block.id, domain: 'example.com', severity: new_severity } + end + let(:domain_block) { Fabricate(:domain_block, domain: 'example.com', severity: original_severity) } before do BlockDomainService.new.call(domain_block) end - let(:subject) do - post :update, params: { id: domain_block.id, domain: 'example.com', severity: new_severity } - end - context 'downgrading a domain suspension to silence' do let(:original_severity) { 'suspend' } let(:new_severity) { 'silence' } diff --git a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb index 67f09da2d..168191468 100644 --- a/spec/controllers/api/v1/push/subscriptions_controller_spec.rb +++ b/spec/controllers/api/v1/push/subscriptions_controller_spec.rb @@ -5,13 +5,7 @@ require 'rails_helper' describe Api::V1::Push::SubscriptionsController do render_views - let(:user) { Fabricate(:user) } - let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'push') } - - before do - allow(controller).to receive(:doorkeeper_token) { token } - end - + let(:user) { Fabricate(:user) } let(:create_payload) do { subscription: { @@ -23,7 +17,6 @@ describe Api::V1::Push::SubscriptionsController do }, }.with_indifferent_access end - let(:alerts_payload) do { data: { @@ -41,6 +34,11 @@ describe Api::V1::Push::SubscriptionsController do }, }.with_indifferent_access end + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'push') } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end describe 'POST #create' do before do diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 132e0c31c..ddbdb07aa 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -753,10 +753,6 @@ RSpec.describe ActivityPub::Activity::Create do context 'with an encrypted message' do let(:recipient) { Fabricate(:account) } - let(:target_device) { Fabricate(:device, account: recipient) } - - subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) } - let(:object_json) do { id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, @@ -778,6 +774,9 @@ RSpec.describe ActivityPub::Activity::Create do }, } end + let(:target_device) { Fabricate(:device, account: recipient) } + + subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) } before do subject.perform @@ -833,13 +832,6 @@ RSpec.describe ActivityPub::Activity::Create do context 'when sender replies to local status' do let!(:local_status) { Fabricate(:status) } - - subject { described_class.new(json, sender, delivery: true) } - - before do - subject.perform - end - let(:object_json) do { id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, @@ -849,6 +841,12 @@ RSpec.describe ActivityPub::Activity::Create do } end + subject { described_class.new(json, sender, delivery: true) } + + before do + subject.perform + end + it 'creates status' do status = sender.statuses.first @@ -859,13 +857,6 @@ RSpec.describe ActivityPub::Activity::Create do context 'when sender targets a local user' do let!(:local_account) { Fabricate(:account) } - - subject { described_class.new(json, sender, delivery: true) } - - before do - subject.perform - end - let(:object_json) do { id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, @@ -875,6 +866,12 @@ RSpec.describe ActivityPub::Activity::Create do } end + subject { described_class.new(json, sender, delivery: true) } + + before do + subject.perform + end + it 'creates status' do status = sender.statuses.first @@ -885,13 +882,6 @@ RSpec.describe ActivityPub::Activity::Create do context 'when sender cc\'s a local user' do let!(:local_account) { Fabricate(:account) } - - subject { described_class.new(json, sender, delivery: true) } - - before do - subject.perform - end - let(:object_json) do { id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, @@ -901,6 +891,12 @@ RSpec.describe ActivityPub::Activity::Create do } end + subject { described_class.new(json, sender, delivery: true) } + + before do + subject.perform + end + it 'creates status' do status = sender.statuses.first diff --git a/spec/lib/vacuum/media_attachments_vacuum_spec.rb b/spec/lib/vacuum/media_attachments_vacuum_spec.rb index be8458d9b..436237b25 100644 --- a/spec/lib/vacuum/media_attachments_vacuum_spec.rb +++ b/spec/lib/vacuum/media_attachments_vacuum_spec.rb @@ -2,12 +2,11 @@ require 'rails_helper' RSpec.describe Vacuum::MediaAttachmentsVacuum do let(:retention_period) { 7.days } - - subject { described_class.new(retention_period) } - let(:remote_status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com')) } let(:local_status) { Fabricate(:status) } + subject { described_class.new(retention_period) } + describe '#perform' do let!(:old_remote_media) { Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png', status: remote_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) } let!(:old_local_media) { Fabricate(:media_attachment, status: local_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) } diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index ae7db88bf..9a6d75ec0 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -6,20 +6,6 @@ end RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) } - - let(:alice) { Fabricate(:account) } - let(:bob) { Fabricate(:account) } - - let(:mentions) { [] } - let(:tags) { [] } - let(:media_attachments) { [] } - - before do - mentions.each { |a| Fabricate(:mention, status: status, account: a) } - tags.each { |t| status.tags << t } - media_attachments.each { |m| status.media_attachments << m } - end - let(:payload) do { '@context': 'https://www.w3.org/ns/activitystreams', @@ -34,9 +20,21 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do ], } end - let(:json) { Oj.load(Oj.dump(payload)) } + let(:alice) { Fabricate(:account) } + let(:bob) { Fabricate(:account) } + + let(:mentions) { [] } + let(:tags) { [] } + let(:media_attachments) { [] } + + before do + mentions.each { |a| Fabricate(:mention, status: status, account: a) } + tags.each { |t| status.tags << t } + media_attachments.each { |m| status.media_attachments << m } + end + subject { described_class.new } describe '#call' do diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 59e15d230..3c294cf95 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' RSpec.describe FanOutOnWriteService, type: :service do let(:last_active_at) { Time.now.utc } + let(:status) { Fabricate(:status, account: alice, visibility: visibility, text: 'Hello @bob #hoge') } let!(:alice) { Fabricate(:user, current_sign_in_at: last_active_at).account } let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account } @@ -9,8 +10,6 @@ RSpec.describe FanOutOnWriteService, type: :service do subject { described_class.new } - let(:status) { Fabricate(:status, account: alice, visibility: visibility, text: 'Hello @bob #hoge') } - before do bob.follow!(alice) tom.follow!(alice) diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index 2b1516ff0..4a517fb93 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -183,15 +183,14 @@ RSpec.describe ImportService, type: :service do subject { ImportService.new } let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } + let(:csv) { attachment_fixture('utf8-followers.txt') } + let(:import) { Import.create(account: account, type: 'following', data: csv) } # Make sure to not actually go to the remote server before do stub_request(:post, 'https://թութ.հայ/inbox').to_return(status: 200) end - let(:csv) { attachment_fixture('utf8-followers.txt') } - let(:import) { Import.create(account: account, type: 'following', data: csv) } - it 'follows the listed account' do expect(account.follow_requests.count).to eq 0 subject.call(import) @@ -203,6 +202,9 @@ RSpec.describe ImportService, type: :service do subject { ImportService.new } let(:csv) { attachment_fixture('bookmark-imports.txt') } + let(:local_account) { Fabricate(:account, username: 'foo', domain: '') } + 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| local_before = Rails.configuration.x.local_domain @@ -214,10 +216,6 @@ RSpec.describe ImportService, type: :service do Rails.configuration.x.local_domain = local_before end - let(:local_account) { Fabricate(:account, username: 'foo', domain: '') } - let!(:remote_status) { Fabricate(:status, uri: 'https://example.com/statuses/1312') } - let!(:direct_status) { Fabricate(:status, uri: 'https://example.com/statuses/direct', visibility: :direct) } - before do service = double allow(ActivityPub::FetchRemoteStatusService).to receive(:new).and_return(service) -- cgit From bf785df9fe044f2f13bfb93e6860a74084d8eb8a Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 20 Feb 2023 00:14:10 -0500 Subject: Audofix Rubocop Style/WordArray (#23739) --- .rubocop_todo.yml | 23 ---------------------- ...10000000_add_statuses_index_on_account_id_id.rb | 2 +- ...uses_for_api_v1_accounts_account_id_statuses.rb | 2 +- lib/mastodon/maintenance_cli.rb | 8 ++++---- lib/tasks/statistics.rake | 2 +- spec/controllers/api/v1/blocks_controller_spec.rb | 4 ++-- .../api/v1/bookmarks_controller_spec.rb | 4 ++-- .../api/v1/favourites_controller_spec.rb | 4 ++-- spec/controllers/api/v1/mutes_controller_spec.rb | 4 ++-- .../settings/applications_controller_spec.rb | 2 +- .../settings/preferences/other_controller_spec.rb | 2 +- spec/models/account_spec.rb | 2 +- .../models/account_statuses_cleanup_policy_spec.rb | 2 +- .../fetch_featured_tags_collection_service_spec.rb | 2 +- .../activitypub/process_account_service_spec.rb | 2 +- spec/services/delete_account_service_spec.rb | 6 +++--- .../accounts_statuses_cleanup_scheduler_spec.rb | 6 +++--- 17 files changed, 27 insertions(+), 50 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1eb039110..ce1ef9a2b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2667,26 +2667,3 @@ Style/UnpackFirst: Exclude: - 'app/models/concerns/account_interactions.rb' - 'lib/paperclip/gif_transcoder.rb' - -# Offense count: 25 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MinSize, WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - Exclude: - - 'db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb' - - 'db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb' - - 'lib/mastodon/maintenance_cli.rb' - - 'lib/tasks/statistics.rake' - - 'spec/controllers/api/v1/blocks_controller_spec.rb' - - 'spec/controllers/api/v1/bookmarks_controller_spec.rb' - - 'spec/controllers/api/v1/favourites_controller_spec.rb' - - 'spec/controllers/api/v1/mutes_controller_spec.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/controllers/settings/preferences/other_controller_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/services/delete_account_service_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' diff --git a/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb b/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb index 3e74346a8..86e425559 100644 --- a/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb +++ b/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb @@ -6,7 +6,7 @@ class AddStatusesIndexOnAccountIdId < ActiveRecord::Migration[5.1] # of an account to show them in his status page is one of the most # significant examples. # Add this index to improve the performance in such cases. - add_index 'statuses', ['account_id', 'id'], algorithm: :concurrently, name: 'index_statuses_on_account_id_id' + add_index 'statuses', %w(account_id id), algorithm: :concurrently, name: 'index_statuses_on_account_id_id' remove_index 'statuses', algorithm: :concurrently, column: 'account_id', name: 'index_statuses_on_account_id' end diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb index e23880bf5..c00302804 100644 --- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -10,6 +10,6 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor # These index may not exists (see migration 20180514130000) remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)') - remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ['account_id', 'id'], where: '(visibility = 3)') + remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, %w(account_id id), where: '(visibility = 3)') end end diff --git a/lib/mastodon/maintenance_cli.rb b/lib/mastodon/maintenance_cli.rb index bb3802f56..3e644045f 100644 --- a/lib/mastodon/maintenance_cli.rb +++ b/lib/mastodon/maintenance_cli.rb @@ -289,7 +289,7 @@ module Mastodon end @prompt.say 'Restoring account domain blocks indexes…' - ActiveRecord::Base.connection.add_index :account_domain_blocks, ['account_id', 'domain'], name: 'index_account_domain_blocks_on_account_id_and_domain', unique: true + ActiveRecord::Base.connection.add_index :account_domain_blocks, %w(account_id domain), name: 'index_account_domain_blocks_on_account_id_and_domain', unique: true end def deduplicate_account_identity_proofs! @@ -303,7 +303,7 @@ module Mastodon end @prompt.say 'Restoring account identity proofs indexes…' - ActiveRecord::Base.connection.add_index :account_identity_proofs, ['account_id', 'provider', 'provider_username'], name: 'index_account_proofs_on_account_and_provider_and_username', unique: true + ActiveRecord::Base.connection.add_index :account_identity_proofs, %w(account_id provider provider_username), name: 'index_account_proofs_on_account_and_provider_and_username', unique: true end def deduplicate_announcement_reactions! @@ -317,7 +317,7 @@ module Mastodon end @prompt.say 'Restoring announcement_reactions indexes…' - ActiveRecord::Base.connection.add_index :announcement_reactions, ['account_id', 'announcement_id', 'name'], name: 'index_announcement_reactions_on_account_id_and_announcement_id', unique: true + ActiveRecord::Base.connection.add_index :announcement_reactions, %w(account_id announcement_id name), name: 'index_announcement_reactions_on_account_id_and_announcement_id', unique: true end def deduplicate_conversations! @@ -359,7 +359,7 @@ module Mastodon end @prompt.say 'Restoring custom_emojis indexes…' - ActiveRecord::Base.connection.add_index :custom_emojis, ['shortcode', 'domain'], name: 'index_custom_emojis_on_shortcode_and_domain', unique: true + ActiveRecord::Base.connection.add_index :custom_emojis, %w(shortcode domain), name: 'index_custom_emojis_on_shortcode_and_domain', unique: true end def deduplicate_custom_emoji_categories! diff --git a/lib/tasks/statistics.rake b/lib/tasks/statistics.rake index 440c309ce..dde7890f6 100644 --- a/lib/tasks/statistics.rake +++ b/lib/tasks/statistics.rake @@ -7,7 +7,7 @@ namespace :mastodon do task :stats do require 'rails/code_statistics' [ - %w(App\ Libraries app/lib), + ['App Libraries', 'app/lib'], %w(Presenters app/presenters), %w(Services app/services), %w(Validators app/validators), diff --git a/spec/controllers/api/v1/blocks_controller_spec.rb b/spec/controllers/api/v1/blocks_controller_spec.rb index 0e5c8296d..cf996c47c 100644 --- a/spec/controllers/api/v1/blocks_controller_spec.rb +++ b/spec/controllers/api/v1/blocks_controller_spec.rb @@ -37,13 +37,13 @@ RSpec.describe Api::V1::BlocksController, type: :controller do it 'sets pagination header for next path' do blocks = 2.times.map { Fabricate(:block, account: user.account) } get :index, params: { limit: 1, since_id: blocks[0] } - expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq api_v1_blocks_url(limit: 1, max_id: blocks[1]) + expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v1_blocks_url(limit: 1, max_id: blocks[1]) end it 'sets pagination header for previous path' do block = Fabricate(:block, account: user.account) get :index - expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq api_v1_blocks_url(since_id: block) + expect(response.headers['Link'].find_link(%w(rel prev)).href).to eq api_v1_blocks_url(since_id: block) end it 'returns http success' do diff --git a/spec/controllers/api/v1/bookmarks_controller_spec.rb b/spec/controllers/api/v1/bookmarks_controller_spec.rb index 279d1a435..b7af60d2b 100644 --- a/spec/controllers/api/v1/bookmarks_controller_spec.rb +++ b/spec/controllers/api/v1/bookmarks_controller_spec.rb @@ -63,8 +63,8 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do get :index, params: { limit: 1 } - expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&max_id=#{bookmark.id}" - expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq "http://test.host/api/v1/bookmarks?limit=1&min_id=#{bookmark.id}" + expect(response.headers['Link'].find_link(%w(rel next)).href).to eq "http://test.host/api/v1/bookmarks?limit=1&max_id=#{bookmark.id}" + expect(response.headers['Link'].find_link(%w(rel prev)).href).to eq "http://test.host/api/v1/bookmarks?limit=1&min_id=#{bookmark.id}" end it 'does not add pagination headers if not necessary' do diff --git a/spec/controllers/api/v1/favourites_controller_spec.rb b/spec/controllers/api/v1/favourites_controller_spec.rb index 512dd0c0d..dfa3f1101 100644 --- a/spec/controllers/api/v1/favourites_controller_spec.rb +++ b/spec/controllers/api/v1/favourites_controller_spec.rb @@ -63,8 +63,8 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do get :index, params: { limit: 1 } - expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq "http://test.host/api/v1/favourites?limit=1&max_id=#{favourite.id}" - expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq "http://test.host/api/v1/favourites?limit=1&min_id=#{favourite.id}" + expect(response.headers['Link'].find_link(%w(rel next)).href).to eq "http://test.host/api/v1/favourites?limit=1&max_id=#{favourite.id}" + expect(response.headers['Link'].find_link(%w(rel prev)).href).to eq "http://test.host/api/v1/favourites?limit=1&min_id=#{favourite.id}" end it 'does not add pagination headers if not necessary' do diff --git a/spec/controllers/api/v1/mutes_controller_spec.rb b/spec/controllers/api/v1/mutes_controller_spec.rb index 8176815d4..8288cb815 100644 --- a/spec/controllers/api/v1/mutes_controller_spec.rb +++ b/spec/controllers/api/v1/mutes_controller_spec.rb @@ -37,13 +37,13 @@ RSpec.describe Api::V1::MutesController, type: :controller do it 'sets pagination header for next path' do mutes = 2.times.map { Fabricate(:mute, account: user.account) } get :index, params: { limit: 1, since_id: mutes[0] } - expect(response.headers['Link'].find_link(['rel', 'next']).href).to eq api_v1_mutes_url(limit: 1, max_id: mutes[1]) + expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v1_mutes_url(limit: 1, max_id: mutes[1]) end it 'sets pagination header for previous path' do mute = Fabricate(:mute, account: user.account) get :index - expect(response.headers['Link'].find_link(['rel', 'prev']).href).to eq api_v1_mutes_url(since_id: mute) + expect(response.headers['Link'].find_link(%w(rel prev)).href).to eq api_v1_mutes_url(since_id: mute) end it 'returns http success' do diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 33d874d10..a653b87c7 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -73,7 +73,7 @@ describe Settings::ApplicationsController do name: 'My New App', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', website: 'http://google.com', - scopes: ['read', 'write', 'follow'], + scopes: %w(read write follow), }, } response diff --git a/spec/controllers/settings/preferences/other_controller_spec.rb b/spec/controllers/settings/preferences/other_controller_spec.rb index dd7f01847..ffb37e0bd 100644 --- a/spec/controllers/settings/preferences/other_controller_spec.rb +++ b/spec/controllers/settings/preferences/other_controller_spec.rb @@ -23,7 +23,7 @@ describe Settings::Preferences::OtherController do expect(response).to redirect_to(settings_preferences_other_path) user.reload expect(user.locale).to eq 'en' - expect(user.chosen_languages).to eq ['es', 'fr'] + expect(user.chosen_languages).to eq %w(es fr) end it 'updates user settings' do diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 726e33048..24239f85d 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -895,7 +895,7 @@ RSpec.describe Account, type: :model do describe 'partitioned' do it 'returns a relation of accounts partitioned by domain' do - matches = ['a', 'b', 'a', 'b'] + matches = %w(a b a b) matches.size.times.to_a.shuffle.each do |index| matches[index] = Fabricate(:account, domain: matches[index]) end diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index 8bd86730b..d170050fc 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -262,7 +262,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do let!(:direct_message) { Fabricate(:status, created_at: 1.year.ago, account: account, visibility: :direct) } let!(:self_faved) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:self_bookmarked) { Fabricate(:status, created_at: 1.year.ago, account: account) } - let!(:status_with_poll) { Fabricate(:status, created_at: 1.year.ago, account: account, poll_attributes: { account: account, voters_count: 0, options: ['a', 'b'], expires_in: 2.days }) } + let!(:status_with_poll) { Fabricate(:status, created_at: 1.year.ago, account: account, poll_attributes: { account: account, voters_count: 0, options: %w(a b), expires_in: 2.days }) } let!(:status_with_media) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:faved4) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:faved5) { Fabricate(:status, created_at: 1.year.ago, account: account) } diff --git a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb index 2110baa2d..4f828bacc 100644 --- a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb @@ -29,7 +29,7 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service d end it 'sets expected tags as pinned tags' do - expect(actor.featured_tags.map(&:display_name)).to match_array ['Foo', 'bar', 'baZ'] + expect(actor.featured_tags.map(&:display_name)).to match_array %w(Foo bar baZ) end end diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 6c3236bae..78282e453 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -12,7 +12,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do attachment: [ { type: 'PropertyValue', name: 'Pronouns', value: 'They/them' }, { type: 'PropertyValue', name: 'Occupation', value: 'Unit test' }, - { type: 'PropertyValue', name: 'non-string', value: ['foo', 'bar'] }, + { type: 'PropertyValue', name: 'non-string', value: %w(foo bar) }, ], }.with_indifferent_access end diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index d0cc8d288..e5bfdd679 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -50,9 +50,9 @@ RSpec.describe DeleteAccountService, type: :service do it 'deletes associated target notifications' do expect { subject }.to change { - [ - 'poll', 'favourite', 'status', 'mention', 'follow' - ].map { |type| Notification.where(type: type).count } + %w( + poll favourite status mention follow + ).map { |type| Notification.where(type: type).count } }.from([1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0]) end end diff --git a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb index 8faf04836..a5dfed369 100644 --- a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb +++ b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb @@ -19,7 +19,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do [ { 'concurrency' => 2, - 'queues' => ['push', 'default'], + 'queues' => %w(push default), }, ] end @@ -82,7 +82,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do describe '#get_budget' do context 'on a single thread' do - let(:process_set_stub) { [{ 'concurrency' => 1, 'queues' => ['push', 'default'] }] } + let(:process_set_stub) { [{ 'concurrency' => 1, 'queues' => %w(push default) }] } it 'returns a low value' do expect(subject.compute_budget).to be < 10 @@ -92,7 +92,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do context 'on a lot of threads' do let(:process_set_stub) do [ - { 'concurrency' => 2, 'queues' => ['push', 'default'] }, + { 'concurrency' => 2, 'queues' => %w(push default) }, { 'concurrency' => 2, 'queues' => ['push'] }, { 'concurrency' => 2, 'queues' => ['push'] }, { 'concurrency' => 2, 'queues' => ['push'] }, -- cgit From 5116347eb7cfd0a09f55efbd84f8d3fa11d4d6ba Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 20 Feb 2023 00:14:50 -0500 Subject: Autofix Rubocop RSpec/BeEq (#23740) --- .rubocop_todo.yml | 43 ---------------------- .../admin/export_domain_allows_controller_spec.rb | 2 +- .../admin/reports/actions_controller_spec.rb | 2 +- spec/controllers/admin/reports_controller_spec.rb | 8 ++-- .../two_factor_authentications_controller_spec.rb | 6 +-- .../api/v1/accounts/credentials_controller_spec.rb | 2 +- .../api/v1/bookmarks_controller_spec.rb | 2 +- .../api/v1/favourites_controller_spec.rb | 2 +- .../api/v2/filters/keywords_controller_spec.rb | 4 +- spec/controllers/application_controller_spec.rb | 6 +-- .../auth/registrations_controller_spec.rb | 6 +-- .../statuses_cleanup_controller_spec.rb | 6 +-- spec/helpers/application_helper_spec.rb | 10 ++--- spec/helpers/jsonld_helper_spec.rb | 12 +++--- spec/lib/activitypub/activity/add_spec.rb | 8 ++-- spec/lib/activitypub/activity/create_spec.rb | 4 +- spec/lib/feed_manager_spec.rb | 28 +++++++------- spec/lib/ostatus/tag_manager_spec.rb | 6 +-- spec/lib/tag_manager_spec.rb | 20 +++++----- spec/lib/user_settings_decorator_spec.rb | 20 +++++----- spec/models/account_domain_block_spec.rb | 4 +- spec/models/account_spec.rb | 20 +++++----- spec/models/block_spec.rb | 8 ++-- spec/models/domain_block_spec.rb | 6 +-- spec/models/favourite_spec.rb | 2 +- spec/models/media_attachment_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- spec/models/web/push_subscription_spec.rb | 12 +++--- .../process_status_update_service_spec.rb | 2 +- spec/services/fetch_oembed_service_spec.rb | 6 +-- spec/services/fetch_resource_service_spec.rb | 2 +- spec/services/post_status_service_spec.rb | 2 +- spec/services/precompute_feed_service_spec.rb | 2 +- spec/services/resolve_account_service_spec.rb | 12 +++--- .../examples/lib/settings/scoped_settings.rb | 32 ++++++++-------- spec/workers/domain_block_worker_spec.rb | 2 +- spec/workers/domain_clear_media_worker_spec.rb | 2 +- spec/workers/feed_insert_worker_spec.rb | 4 +- spec/workers/regeneration_worker_spec.rb | 2 +- 39 files changed, 139 insertions(+), 182 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ce1ef9a2b..86a48a170 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -545,49 +545,6 @@ RSpec/AnyInstance: - 'spec/workers/activitypub/delivery_worker_spec.rb' - 'spec/workers/web/push_notification_worker_spec.rb' -# Offense count: 139 -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/BeEq: - Exclude: - - 'spec/controllers/admin/export_domain_allows_controller_spec.rb' - - 'spec/controllers/admin/reports/actions_controller_spec.rb' - - 'spec/controllers/admin/reports_controller_spec.rb' - - 'spec/controllers/admin/users/two_factor_authentications_controller_spec.rb' - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/bookmarks_controller_spec.rb' - - 'spec/controllers/api/v1/favourites_controller_spec.rb' - - 'spec/controllers/api/v2/filters/keywords_controller_spec.rb' - - 'spec/controllers/application_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/statuses_cleanup_controller_spec.rb' - - 'spec/helpers/application_helper_spec.rb' - - 'spec/helpers/jsonld_helper_spec.rb' - - 'spec/lib/activitypub/activity/add_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/feed_manager_spec.rb' - - 'spec/lib/ostatus/tag_manager_spec.rb' - - 'spec/lib/tag_manager_spec.rb' - - 'spec/lib/user_settings_decorator_spec.rb' - - 'spec/models/account_domain_block_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/block_spec.rb' - - 'spec/models/domain_block_spec.rb' - - 'spec/models/favourite_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/models/web/push_subscription_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - - 'spec/services/fetch_resource_service_spec.rb' - - 'spec/services/post_status_service_spec.rb' - - 'spec/services/precompute_feed_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/support/examples/lib/settings/scoped_settings.rb' - - 'spec/workers/domain_block_worker_spec.rb' - - 'spec/workers/domain_clear_media_worker_spec.rb' - - 'spec/workers/feed_insert_worker_spec.rb' - - 'spec/workers/regeneration_worker_spec.rb' - # Offense count: 1 RSpec/BeforeAfterAll: Exclude: diff --git a/spec/controllers/admin/export_domain_allows_controller_spec.rb b/spec/controllers/admin/export_domain_allows_controller_spec.rb index 1e1a5ae7d..7ee064de7 100644 --- a/spec/controllers/admin/export_domain_allows_controller_spec.rb +++ b/spec/controllers/admin/export_domain_allows_controller_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Admin::ExportDomainAllowsController, type: :controller do expect(response).to redirect_to(admin_instances_path) # Header should not be imported - expect(DomainAllow.where(domain: '#domain').present?).to eq(false) + expect(DomainAllow.where(domain: '#domain').present?).to be(false) # Domains should now be added get :export, params: { format: :csv } diff --git a/spec/controllers/admin/reports/actions_controller_spec.rb b/spec/controllers/admin/reports/actions_controller_spec.rb index db3a1d311..20f85680f 100644 --- a/spec/controllers/admin/reports/actions_controller_spec.rb +++ b/spec/controllers/admin/reports/actions_controller_spec.rb @@ -116,7 +116,7 @@ describe Admin::Reports::ActionsController do it 'marks the non-deleted as sensitive' do subject - expect(media_attached_status.reload.sensitive).to eq true + expect(media_attached_status.reload.sensitive).to be true end end end diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index 4dcc277d9..c6b5770a8 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -55,7 +55,7 @@ describe Admin::ReportsController do expect(response).to redirect_to(admin_reports_path) report.reload expect(report.action_taken_by_account).to eq user.account - expect(report.action_taken?).to eq true + expect(report.action_taken?).to be true end end @@ -66,8 +66,8 @@ describe Admin::ReportsController do put :reopen, params: { id: report } expect(response).to redirect_to(admin_report_path(report)) report.reload - expect(report.action_taken_by_account).to eq nil - expect(report.action_taken?).to eq false + expect(report.action_taken_by_account).to be_nil + expect(report.action_taken?).to be false end end @@ -89,7 +89,7 @@ describe Admin::ReportsController do put :unassign, params: { id: report } expect(response).to redirect_to(admin_report_path(report)) report.reload - expect(report.assigned_account).to eq nil + expect(report.assigned_account).to be_nil end end end diff --git a/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb b/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb index e56264ef6..990dcf640 100644 --- a/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb +++ b/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::Users::TwoFactorAuthenticationsController do delete :destroy, params: { user_id: user.id } user.reload - expect(user.otp_enabled?).to eq false + expect(user.otp_enabled?).to be false expect(response).to redirect_to(admin_account_path(user.account_id)) end end @@ -43,8 +43,8 @@ describe Admin::Users::TwoFactorAuthenticationsController do delete :destroy, params: { user_id: user.id } user.reload - expect(user.otp_enabled?).to eq false - expect(user.webauthn_enabled?).to eq false + expect(user.otp_enabled?).to be false + expect(user.webauthn_enabled?).to be false expect(response).to redirect_to(admin_account_path(user.account_id)) end end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index cf91aae38..3494ca674 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -51,7 +51,7 @@ describe Api::V1::Accounts::CredentialsController do expect(user.account.avatar).to exist expect(user.account.header).to exist expect(user.setting_default_privacy).to eq('unlisted') - expect(user.setting_default_sensitive).to eq(true) + expect(user.setting_default_sensitive).to be(true) end it 'queues up an account update distribution' do diff --git a/spec/controllers/api/v1/bookmarks_controller_spec.rb b/spec/controllers/api/v1/bookmarks_controller_spec.rb index b7af60d2b..48332b15a 100644 --- a/spec/controllers/api/v1/bookmarks_controller_spec.rb +++ b/spec/controllers/api/v1/bookmarks_controller_spec.rb @@ -70,7 +70,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do it 'does not add pagination headers if not necessary' do get :index - expect(response.headers['Link']).to eq nil + expect(response.headers['Link']).to be_nil end end end diff --git a/spec/controllers/api/v1/favourites_controller_spec.rb b/spec/controllers/api/v1/favourites_controller_spec.rb index dfa3f1101..f0fb8f37b 100644 --- a/spec/controllers/api/v1/favourites_controller_spec.rb +++ b/spec/controllers/api/v1/favourites_controller_spec.rb @@ -70,7 +70,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do it 'does not add pagination headers if not necessary' do get :index - expect(response.headers['Link']).to eq nil + expect(response.headers['Link']).to be_nil end end end diff --git a/spec/controllers/api/v2/filters/keywords_controller_spec.rb b/spec/controllers/api/v2/filters/keywords_controller_spec.rb index 1201a4ca2..0e0f52ea8 100644 --- a/spec/controllers/api/v2/filters/keywords_controller_spec.rb +++ b/spec/controllers/api/v2/filters/keywords_controller_spec.rb @@ -45,7 +45,7 @@ RSpec.describe Api::V2::Filters::KeywordsController, type: :controller do it 'returns a keyword' do json = body_as_json expect(json[:keyword]).to eq 'magic' - expect(json[:whole_word]).to eq false + expect(json[:whole_word]).to be false end it 'creates a keyword' do @@ -78,7 +78,7 @@ RSpec.describe Api::V2::Filters::KeywordsController, type: :controller do it 'returns expected data' do json = body_as_json expect(json[:keyword]).to eq 'foo' - expect(json[:whole_word]).to eq false + expect(json[:whole_word]).to be false end context "when trying to access another user's filter keyword" do diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index e2a63002b..35c7326cb 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -57,19 +57,19 @@ describe ApplicationController, type: :controller do describe 'helper_method :single_user_mode?' do it 'returns false if it is in single_user_mode but there is no account' do allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true) - expect(controller.view_context.single_user_mode?).to eq false + expect(controller.view_context.single_user_mode?).to be false end it 'returns false if there is an account but it is not in single_user_mode' do allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false) Fabricate(:account) - expect(controller.view_context.single_user_mode?).to eq false + expect(controller.view_context.single_user_mode?).to be false end it 'returns true if it is in single_user_mode and there is an account' do allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true) Fabricate(:account) - expect(controller.view_context.single_user_mode?).to eq true + expect(controller.view_context.single_user_mode?).to be true end end diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 8cfb8e277..f42f685c1 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -163,7 +163,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do user = User.find_by(email: 'test@example.com') expect(user).to_not be_nil expect(user.locale).to eq(accept_language) - expect(user.approved).to eq(false) + expect(user.approved).to be(false) end end @@ -191,7 +191,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do user = User.find_by(email: 'test@example.com') expect(user).to_not be_nil expect(user.locale).to eq(accept_language) - expect(user.approved).to eq(false) + expect(user.approved).to be(false) end end @@ -223,7 +223,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do user = User.find_by(email: 'test@example.com') expect(user).to_not be_nil expect(user.locale).to eq(accept_language) - expect(user.approved).to eq(true) + expect(user.approved).to be(true) end end diff --git a/spec/controllers/statuses_cleanup_controller_spec.rb b/spec/controllers/statuses_cleanup_controller_spec.rb index 347fe4027..24b4ea7b6 100644 --- a/spec/controllers/statuses_cleanup_controller_spec.rb +++ b/spec/controllers/statuses_cleanup_controller_spec.rb @@ -19,9 +19,9 @@ RSpec.describe StatusesCleanupController, type: :controller do it 'updates the account status cleanup policy' do put :update, params: { account_statuses_cleanup_policy: { enabled: true, min_status_age: 2.weeks.seconds, keep_direct: false, keep_polls: true } } expect(response).to redirect_to(statuses_cleanup_path) - expect(@user.account.statuses_cleanup_policy.enabled).to eq true - expect(@user.account.statuses_cleanup_policy.keep_direct).to eq false - expect(@user.account.statuses_cleanup_policy.keep_polls).to eq true + expect(@user.account.statuses_cleanup_policy.enabled).to be true + expect(@user.account.statuses_cleanup_policy.keep_direct).to be false + expect(@user.account.statuses_cleanup_policy.keep_polls).to be true end end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 6502cfebf..e0f71afd5 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -65,7 +65,7 @@ describe ApplicationHelper do expect(Setting).to receive(:registrations_mode).and_return('open') end - expect(helper.open_registrations?).to eq true + expect(helper.open_registrations?).to be true end it 'returns false when closed for registrations' do @@ -73,7 +73,7 @@ describe ApplicationHelper do expect(Setting).to receive(:registrations_mode).and_return('none') end - expect(helper.open_registrations?).to eq false + expect(helper.open_registrations?).to be false end end @@ -84,7 +84,7 @@ describe ApplicationHelper do end it 'does not show landing strip' do - expect(helper.show_landing_strip?).to eq false + expect(helper.show_landing_strip?).to be false end end @@ -96,13 +96,13 @@ describe ApplicationHelper do it 'does not show landing strip on single user instance' do allow(helper).to receive(:single_user_mode?).and_return(true) - expect(helper.show_landing_strip?).to eq false + expect(helper.show_landing_strip?).to be false end it 'shows landing strip on multi user instance' do allow(helper).to receive(:single_user_mode?).and_return(false) - expect(helper.show_landing_strip?).to eq true + expect(helper.show_landing_strip?).to be true end end end diff --git a/spec/helpers/jsonld_helper_spec.rb b/spec/helpers/jsonld_helper_spec.rb index debee17f0..ddd4bfe62 100644 --- a/spec/helpers/jsonld_helper_spec.rb +++ b/spec/helpers/jsonld_helper_spec.rb @@ -66,14 +66,14 @@ describe JsonLdHelper do stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://marvin.test/"}' stub_request(:get, 'https://marvin.test/').to_return body: '{"id": "https://alice.test/"}' - expect(fetch_resource('https://mallory.test/', false)).to eq nil + expect(fetch_resource('https://mallory.test/', false)).to be_nil end end context 'when the second argument is true' do it 'returns nil if the retrieved ID and the given URI does not match' do stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://alice.test/"}' - expect(fetch_resource('https://mallory.test/', true)).to eq nil + expect(fetch_resource('https://mallory.test/', true)).to be_nil end end end @@ -81,7 +81,7 @@ describe JsonLdHelper do describe '#fetch_resource_without_id_validation' do it 'returns nil if the status code is not 200' do stub_request(:get, 'https://host.test/').to_return status: 400, body: '{}' - expect(fetch_resource_without_id_validation('https://host.test/')).to eq nil + expect(fetch_resource_without_id_validation('https://host.test/')).to be_nil end it 'returns hash' do @@ -150,7 +150,7 @@ describe JsonLdHelper do patch_for_forwarding!(json, compacted) expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public'] expect(compacted.dig('object', 'tag', 0, 'href')).to eq ['foo'] - expect(safe_for_forwarding?(json, compacted)).to eq true + expect(safe_for_forwarding?(json, compacted)).to be true end end @@ -160,14 +160,14 @@ describe JsonLdHelper do compacted = compact(json) deemed_compatible = patch_for_forwarding!(json, compacted) expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public'] - expect(safe_for_forwarding?(json, compacted)).to eq true + expect(safe_for_forwarding?(json, compacted)).to be true end it 'deems an unsafe compacting as such' do compacted = compact(json) deemed_compatible = patch_for_forwarding!(json, compacted) expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public'] - expect(safe_for_forwarding?(json, compacted)).to eq false + expect(safe_for_forwarding?(json, compacted)).to be false end end end diff --git a/spec/lib/activitypub/activity/add_spec.rb b/spec/lib/activitypub/activity/add_spec.rb index e21c871e6..a69c3d2b1 100644 --- a/spec/lib/activitypub/activity/add_spec.rb +++ b/spec/lib/activitypub/activity/add_spec.rb @@ -50,8 +50,8 @@ RSpec.describe ActivityPub::Activity::Add do it 'fetches the status and pins it' do allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument expect(uri).to eq 'https://example.com/unknown' - expect(id).to eq true - expect(on_behalf_of&.following?(sender)).to eq true + expect(id).to be true + expect(on_behalf_of&.following?(sender)).to be true status end subject.perform @@ -64,8 +64,8 @@ RSpec.describe ActivityPub::Activity::Add do it 'tries to fetch the status' do allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument expect(uri).to eq 'https://example.com/unknown' - expect(id).to eq true - expect(on_behalf_of).to eq nil + expect(id).to be true + expect(on_behalf_of).to be_nil nil end subject.perform diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index c26c8b358..fd4983037 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -51,7 +51,7 @@ RSpec.describe ActivityPub::Activity::Create do status = sender.statuses.first expect(status).to_not be_nil - expect(status.edited?).to eq true + expect(status.edited?).to be true end end @@ -77,7 +77,7 @@ RSpec.describe ActivityPub::Activity::Create do status = sender.statuses.first expect(status).to_not be_nil - expect(status.edited?).to eq false + expect(status.edited?).to be false end end diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 7195cec06..d54050f8f 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -297,7 +297,7 @@ RSpec.describe FeedManager do status = Fabricate(:status, reblog: reblog) FeedManager.instance.push_to_home(account, status) - expect(FeedManager.instance.push_to_home(account, reblog)).to eq false + expect(FeedManager.instance.push_to_home(account, reblog)).to be false end end @@ -322,7 +322,7 @@ RSpec.describe FeedManager do status = Fabricate(:status, reblog: reblog) FeedManager.instance.push_to_list(list, status) - expect(FeedManager.instance.push_to_list(list, reblog)).to eq false + expect(FeedManager.instance.push_to_list(list, reblog)).to be false end context 'when replies policy is set to no replies' do @@ -332,19 +332,19 @@ RSpec.describe FeedManager do it 'pushes statuses that are not replies' do status = Fabricate(:status, text: 'Hello world', account: bob) - expect(FeedManager.instance.push_to_list(list, status)).to eq true + expect(FeedManager.instance.push_to_list(list, status)).to be true end it 'pushes statuses that are replies to list owner' do status = Fabricate(:status, text: 'Hello world', account: owner) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq true + expect(FeedManager.instance.push_to_list(list, reply)).to be true end it 'does not push replies to another member of the list' do status = Fabricate(:status, text: 'Hello world', account: alice) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq false + expect(FeedManager.instance.push_to_list(list, reply)).to be false end end @@ -355,25 +355,25 @@ RSpec.describe FeedManager do it 'pushes statuses that are not replies' do status = Fabricate(:status, text: 'Hello world', account: bob) - expect(FeedManager.instance.push_to_list(list, status)).to eq true + expect(FeedManager.instance.push_to_list(list, status)).to be true end it 'pushes statuses that are replies to list owner' do status = Fabricate(:status, text: 'Hello world', account: owner) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq true + expect(FeedManager.instance.push_to_list(list, reply)).to be true end it 'pushes replies to another member of the list' do status = Fabricate(:status, text: 'Hello world', account: alice) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq true + expect(FeedManager.instance.push_to_list(list, reply)).to be true end it 'does not push replies to someone not a member of the list' do status = Fabricate(:status, text: 'Hello world', account: eve) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq false + expect(FeedManager.instance.push_to_list(list, reply)).to be false end end @@ -384,25 +384,25 @@ RSpec.describe FeedManager do it 'pushes statuses that are not replies' do status = Fabricate(:status, text: 'Hello world', account: bob) - expect(FeedManager.instance.push_to_list(list, status)).to eq true + expect(FeedManager.instance.push_to_list(list, status)).to be true end it 'pushes statuses that are replies to list owner' do status = Fabricate(:status, text: 'Hello world', account: owner) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq true + expect(FeedManager.instance.push_to_list(list, reply)).to be true end it 'pushes replies to another member of the list' do status = Fabricate(:status, text: 'Hello world', account: alice) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq true + expect(FeedManager.instance.push_to_list(list, reply)).to be true end it 'pushes replies to someone not a member of the list' do status = Fabricate(:status, text: 'Hello world', account: eve) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) - expect(FeedManager.instance.push_to_list(list, reply)).to eq true + expect(FeedManager.instance.push_to_list(list, reply)).to be true end end end @@ -416,7 +416,7 @@ RSpec.describe FeedManager do FeedManager.instance.merge_into_home(account, reblog.account) - expect(redis.zscore('feed:home:0', reblog.id)).to eq nil + expect(redis.zscore('feed:home:0', reblog.id)).to be_nil end end diff --git a/spec/lib/ostatus/tag_manager_spec.rb b/spec/lib/ostatus/tag_manager_spec.rb index 65ba7577a..8104a7e79 100644 --- a/spec/lib/ostatus/tag_manager_spec.rb +++ b/spec/lib/ostatus/tag_manager_spec.rb @@ -15,15 +15,15 @@ describe OStatus::TagManager do end it 'returns nil if it is not local id' do - expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:remote,2000-01-01:objectId=12:objectType=Status', 'Status')).to eq nil + expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:remote,2000-01-01:objectId=12:objectType=Status', 'Status')).to be_nil end it 'returns nil if it is not expected type' do - expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to eq nil + expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to be_nil end it 'returns nil if it does not have object ID' do - expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to eq nil + expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to be_nil end end diff --git a/spec/lib/tag_manager_spec.rb b/spec/lib/tag_manager_spec.rb index cd9fb936c..d2bb24c0f 100644 --- a/spec/lib/tag_manager_spec.rb +++ b/spec/lib/tag_manager_spec.rb @@ -14,15 +14,15 @@ RSpec.describe TagManager do end it 'returns true for nil' do - expect(TagManager.instance.local_domain?(nil)).to eq true + expect(TagManager.instance.local_domain?(nil)).to be true end it 'returns true if the slash-stripped string equals to local domain' do - expect(TagManager.instance.local_domain?('DoMaIn.Example.com/')).to eq true + expect(TagManager.instance.local_domain?('DoMaIn.Example.com/')).to be true end it 'returns false for irrelevant string' do - expect(TagManager.instance.local_domain?('DoMaIn.Example.com!')).to eq false + expect(TagManager.instance.local_domain?('DoMaIn.Example.com!')).to be false end end @@ -39,21 +39,21 @@ RSpec.describe TagManager do end it 'returns true for nil' do - expect(TagManager.instance.web_domain?(nil)).to eq true + expect(TagManager.instance.web_domain?(nil)).to be true end it 'returns true if the slash-stripped string equals to web domain' do - expect(TagManager.instance.web_domain?('DoMaIn.Example.com/')).to eq true + expect(TagManager.instance.web_domain?('DoMaIn.Example.com/')).to be true end it 'returns false for string with irrelevant characters' do - expect(TagManager.instance.web_domain?('DoMaIn.Example.com!')).to eq false + expect(TagManager.instance.web_domain?('DoMaIn.Example.com!')).to be false end end describe '#normalize_domain' do it 'returns nil if the given parameter is nil' do - expect(TagManager.instance.normalize_domain(nil)).to eq nil + expect(TagManager.instance.normalize_domain(nil)).to be_nil end it 'returns normalized domain' do @@ -70,17 +70,17 @@ RSpec.describe TagManager do it 'returns true if the normalized string with port is local URL' do Rails.configuration.x.web_domain = 'domain.example.com:42' - expect(TagManager.instance.local_url?('https://DoMaIn.Example.com:42/')).to eq true + expect(TagManager.instance.local_url?('https://DoMaIn.Example.com:42/')).to be true end it 'returns true if the normalized string without port is local URL' do Rails.configuration.x.web_domain = 'domain.example.com' - expect(TagManager.instance.local_url?('https://DoMaIn.Example.com/')).to eq true + expect(TagManager.instance.local_url?('https://DoMaIn.Example.com/')).to be true end it 'returns false for string with irrelevant characters' do Rails.configuration.x.web_domain = 'domain.example.com' - expect(TagManager.instance.local_url?('https://domain.example.net/')).to eq false + expect(TagManager.instance.local_url?('https://domain.example.net/')).to be false end end end diff --git a/spec/lib/user_settings_decorator_spec.rb b/spec/lib/user_settings_decorator_spec.rb index 462c5b124..3b9b7ee2b 100644 --- a/spec/lib/user_settings_decorator_spec.rb +++ b/spec/lib/user_settings_decorator_spec.rb @@ -11,14 +11,14 @@ describe UserSettingsDecorator do values = { 'notification_emails' => { 'follow' => '1' } } settings.update(values) - expect(user.settings['notification_emails']['follow']).to eq true + expect(user.settings['notification_emails']['follow']).to be true end it 'updates the user settings value for interactions' do values = { 'interactions' => { 'must_be_follower' => '0' } } settings.update(values) - expect(user.settings['interactions']['must_be_follower']).to eq false + expect(user.settings['interactions']['must_be_follower']).to be false end it 'updates the user settings value for privacy' do @@ -32,42 +32,42 @@ describe UserSettingsDecorator do values = { 'setting_default_sensitive' => '1' } settings.update(values) - expect(user.settings['default_sensitive']).to eq true + expect(user.settings['default_sensitive']).to be true end it 'updates the user settings value for unfollow modal' do values = { 'setting_unfollow_modal' => '0' } settings.update(values) - expect(user.settings['unfollow_modal']).to eq false + expect(user.settings['unfollow_modal']).to be false end it 'updates the user settings value for boost modal' do values = { 'setting_boost_modal' => '1' } settings.update(values) - expect(user.settings['boost_modal']).to eq true + expect(user.settings['boost_modal']).to be true end it 'updates the user settings value for delete toot modal' do values = { 'setting_delete_modal' => '0' } settings.update(values) - expect(user.settings['delete_modal']).to eq false + expect(user.settings['delete_modal']).to be false end it 'updates the user settings value for gif auto play' do values = { 'setting_auto_play_gif' => '0' } settings.update(values) - expect(user.settings['auto_play_gif']).to eq false + expect(user.settings['auto_play_gif']).to be false end it 'updates the user settings value for system font in UI' do values = { 'setting_system_font_ui' => '0' } settings.update(values) - expect(user.settings['system_font_ui']).to eq false + expect(user.settings['system_font_ui']).to be false end it 'decoerces setting values before applying' do @@ -77,8 +77,8 @@ describe UserSettingsDecorator do } settings.update(values) - expect(user.settings['delete_modal']).to eq false - expect(user.settings['boost_modal']).to eq true + expect(user.settings['delete_modal']).to be false + expect(user.settings['boost_modal']).to be true end end end diff --git a/spec/models/account_domain_block_spec.rb b/spec/models/account_domain_block_spec.rb index 469bc05cb..a170abcd2 100644 --- a/spec/models/account_domain_block_spec.rb +++ b/spec/models/account_domain_block_spec.rb @@ -7,7 +7,7 @@ RSpec.describe AccountDomainBlock, type: :model do AccountDomainBlock.create!(account: account, domain: 'a.domain.blocked.later') - expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to eq false + expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false end it 'removes blocking cache after destruction' do @@ -17,6 +17,6 @@ RSpec.describe AccountDomainBlock, type: :model do block.destroy! - expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to eq false + expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false end end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 24239f85d..f3ad19877 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -160,7 +160,7 @@ RSpec.describe Account, type: :model do it 'sets default avatar, header, avatar_remote_url, and header_remote_url' do expect(account.avatar_remote_url).to eq 'https://remote.test/invalid_avatar' expect(account.header_remote_url).to eq expectation.header_remote_url - expect(account.avatar_file_name).to eq nil + expect(account.avatar_file_name).to be_nil expect(account.header_file_name).to eq expectation.header_file_name end end @@ -259,11 +259,11 @@ RSpec.describe Account, type: :model do it 'is true when this account has favourited it' do Fabricate(:favourite, status: original_reblog, account: subject) - expect(subject.favourited?(original_status)).to eq true + expect(subject.favourited?(original_status)).to be true end it 'is false when this account has not favourited it' do - expect(subject.favourited?(original_status)).to eq false + expect(subject.favourited?(original_status)).to be false end end @@ -271,11 +271,11 @@ RSpec.describe Account, type: :model do it 'is true when this account has favourited it' do Fabricate(:favourite, status: original_status, account: subject) - expect(subject.favourited?(original_status)).to eq true + expect(subject.favourited?(original_status)).to be true end it 'is false when this account has not favourited it' do - expect(subject.favourited?(original_status)).to eq false + expect(subject.favourited?(original_status)).to be false end end end @@ -297,11 +297,11 @@ RSpec.describe Account, type: :model do it 'is true when this account has reblogged it' do Fabricate(:status, reblog: original_reblog, account: subject) - expect(subject.reblogged?(original_reblog)).to eq true + expect(subject.reblogged?(original_reblog)).to be true end it 'is false when this account has not reblogged it' do - expect(subject.reblogged?(original_reblog)).to eq false + expect(subject.reblogged?(original_reblog)).to be false end end @@ -309,11 +309,11 @@ RSpec.describe Account, type: :model do it 'is true when this account has reblogged it' do Fabricate(:status, reblog: original_status, account: subject) - expect(subject.reblogged?(original_status)).to eq true + expect(subject.reblogged?(original_status)).to be true end it 'is false when this account has not reblogged it' do - expect(subject.reblogged?(original_status)).to eq false + expect(subject.reblogged?(original_status)).to be false end end end @@ -958,7 +958,7 @@ RSpec.describe Account, type: :model do # Test disabled because test environment omits autogenerating keys for performance xit 'generates keys' do account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_'])) - expect(account.keypair.private?).to eq true + expect(account.keypair.private?).to be true end end diff --git a/spec/models/block_spec.rb b/spec/models/block_spec.rb index acbdc77f5..1fd60c29d 100644 --- a/spec/models/block_spec.rb +++ b/spec/models/block_spec.rb @@ -28,8 +28,8 @@ RSpec.describe Block, type: :model do Block.create!(account: account, target_account: target_account) - expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false - expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false + expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false + expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false end it 'removes blocking cache after destruction' do @@ -41,7 +41,7 @@ RSpec.describe Block, type: :model do block.destroy! - expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false - expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false + expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false + expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false end end diff --git a/spec/models/domain_block_spec.rb b/spec/models/domain_block_spec.rb index 28647dc89..d1d57c167 100644 --- a/spec/models/domain_block_spec.rb +++ b/spec/models/domain_block_spec.rb @@ -24,16 +24,16 @@ RSpec.describe DomainBlock, type: :model do describe '.blocked?' do it 'returns true if the domain is suspended' do Fabricate(:domain_block, domain: 'example.com', severity: :suspend) - expect(DomainBlock.blocked?('example.com')).to eq true + expect(DomainBlock.blocked?('example.com')).to be true end it 'returns false even if the domain is silenced' do Fabricate(:domain_block, domain: 'example.com', severity: :silence) - expect(DomainBlock.blocked?('example.com')).to eq false + expect(DomainBlock.blocked?('example.com')).to be false end it 'returns false if the domain is not suspended nor silenced' do - expect(DomainBlock.blocked?('example.com')).to eq false + expect(DomainBlock.blocked?('example.com')).to be false end end diff --git a/spec/models/favourite_spec.rb b/spec/models/favourite_spec.rb index ba1410a45..f755590ee 100644 --- a/spec/models/favourite_spec.rb +++ b/spec/models/favourite_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Favourite, type: :model do it 'invalidates if the reblogged status is already a favourite' do Favourite.create!(account: account, status: reblog) - expect(Favourite.new(account: account, status: status).valid?).to eq false + expect(Favourite.new(account: account, status: status).valid?).to be false end it 'replaces status with the reblogged one if it is a reblog' do diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 57e131423..097c76f31 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -138,7 +138,7 @@ RSpec.describe MediaAttachment, type: :model do end it 'extracts thumbnail' do - expect(media.thumbnail.present?).to eq true + expect(media.thumbnail.present?).to be true end it 'extracts colors from thumbnail' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9af616b32..9dfd6678a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -46,7 +46,7 @@ RSpec.describe User, type: :model do it 'cleans out empty string from languages' do user = Fabricate.build(:user, chosen_languages: ['']) user.valid? - expect(user.chosen_languages).to eq nil + expect(user.chosen_languages).to be_nil end end diff --git a/spec/models/web/push_subscription_spec.rb b/spec/models/web/push_subscription_spec.rb index 388154000..a5c34f4ed 100644 --- a/spec/models/web/push_subscription_spec.rb +++ b/spec/models/web/push_subscription_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Web::PushSubscription, type: :model do let(:policy) { 'all' } it 'returns true' do - expect(subject.pushable?(notification)).to eq true + expect(subject.pushable?(notification)).to be true end end @@ -47,7 +47,7 @@ RSpec.describe Web::PushSubscription, type: :model do let(:policy) { 'none' } it 'returns false' do - expect(subject.pushable?(notification)).to eq false + expect(subject.pushable?(notification)).to be false end end @@ -60,13 +60,13 @@ RSpec.describe Web::PushSubscription, type: :model do end it 'returns true' do - expect(subject.pushable?(notification)).to eq true + expect(subject.pushable?(notification)).to be true end end context 'and notification is not from someone you follow' do it 'returns false' do - expect(subject.pushable?(notification)).to eq false + expect(subject.pushable?(notification)).to be false end end end @@ -80,13 +80,13 @@ RSpec.describe Web::PushSubscription, type: :model do end it 'returns true' do - expect(subject.pushable?(notification)).to eq true + expect(subject.pushable?(notification)).to be true end end context 'and notification is not from someone who follows you' do it 'returns false' do - expect(subject.pushable?(notification)).to eq false + expect(subject.pushable?(notification)).to be false end end end diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 3d6f76163..c8aa56def 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -410,7 +410,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'removes poll' do - expect(status.reload.poll).to eq nil + expect(status.reload.poll).to be_nil end it 'records media change in edit' do diff --git a/spec/services/fetch_oembed_service_spec.rb b/spec/services/fetch_oembed_service_spec.rb index cf46f2d39..8a0b49222 100644 --- a/spec/services/fetch_oembed_service_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -62,7 +62,7 @@ describe FetchOEmbedService, type: :service do it 'does not cache OEmbed endpoint' do subject.call('https://host.test/oembed.html', format: :xml) - expect(Rails.cache.exist?('oembed_endpoint:host.test')).to eq false + expect(Rails.cache.exist?('oembed_endpoint:host.test')).to be false end end @@ -83,7 +83,7 @@ describe FetchOEmbedService, type: :service do it 'does not cache OEmbed endpoint' do subject.call('https://host.test/oembed.html') - expect(Rails.cache.exist?('oembed_endpoint:host.test')).to eq false + expect(Rails.cache.exist?('oembed_endpoint:host.test')).to be false end end @@ -104,7 +104,7 @@ describe FetchOEmbedService, type: :service do it 'does not cache OEmbed endpoint' do subject.call('https://host.test/oembed.html') - expect(Rails.cache.exist?('oembed_endpoint:host.test')).to eq false + expect(Rails.cache.exist?('oembed_endpoint:host.test')).to be false end end diff --git a/spec/services/fetch_resource_service_spec.rb b/spec/services/fetch_resource_service_spec.rb index 84c4035cb..226c98d70 100644 --- a/spec/services/fetch_resource_service_spec.rb +++ b/spec/services/fetch_resource_service_spec.rb @@ -74,7 +74,7 @@ RSpec.describe FetchResourceService, type: :service do context 'when content type is application/atom+xml' do let(:content_type) { 'application/atom+xml' } - it { is_expected.to eq nil } + it { is_expected.to be_nil } end context 'when content type is activity+json' do diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 2148f1819..c34f2393a 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -216,7 +216,7 @@ RSpec.describe PostStatusService, type: :service do media_ids: [media.id] ) - expect(media.reload.status).to eq nil + expect(media.reload.status).to be_nil end it 'does not allow attaching more than 4 files' do diff --git a/spec/services/precompute_feed_service_spec.rb b/spec/services/precompute_feed_service_spec.rb index b28824f9a..86ab59b29 100644 --- a/spec/services/precompute_feed_service_spec.rb +++ b/spec/services/precompute_feed_service_spec.rb @@ -31,7 +31,7 @@ RSpec.describe PrecomputeFeedService, type: :service do subject.call(account) - expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq nil + expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to be_nil end end end diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 192225229..02869f8c8 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -108,7 +108,7 @@ RSpec.describe ResolveAccountService, type: :service do it 'returns new remote account' do account = subject.call('Foo@redirected.example.com') - expect(account.activitypub?).to eq true + expect(account.activitypub?).to be true expect(account.acct).to eq 'foo@ap.example.com' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' end @@ -123,7 +123,7 @@ RSpec.describe ResolveAccountService, type: :service do it 'returns new remote account' do account = subject.call('Foo@redirected.example.com') - expect(account.activitypub?).to eq true + expect(account.activitypub?).to be true expect(account.acct).to eq 'foo@ap.example.com' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' end @@ -146,7 +146,7 @@ RSpec.describe ResolveAccountService, type: :service do it 'returns new remote account' do account = subject.call('foo@ap.example.com') - expect(account.activitypub?).to eq true + expect(account.activitypub?).to be true expect(account.domain).to eq 'ap.example.com' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' end @@ -159,7 +159,7 @@ RSpec.describe ResolveAccountService, type: :service do it 'returns new remote account' do account = subject.call('foo@ap.example.com') - expect(account.activitypub?).to eq true + expect(account.activitypub?).to be true expect(account.domain).to eq 'ap.example.com' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.actor_type).to eq 'Person' @@ -174,7 +174,7 @@ RSpec.describe ResolveAccountService, type: :service do it 'returns new remote account' do account = subject.call('foo@ap.example.com') - expect(account.activitypub?).to eq true + expect(account.activitypub?).to be true expect(account.domain).to eq 'ap.example.com' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.uri).to eq 'https://ap.example.com/users/foo' @@ -195,7 +195,7 @@ RSpec.describe ResolveAccountService, type: :service do it 'returns new remote account' do account = subject.call('foo@ap.example.com') - expect(account.activitypub?).to eq true + expect(account.activitypub?).to be true expect(account.domain).to eq 'ap.example.com' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.uri).to eq 'https://ap.example.com/users/foo' diff --git a/spec/support/examples/lib/settings/scoped_settings.rb b/spec/support/examples/lib/settings/scoped_settings.rb index 2457dcfbf..106adb4fa 100644 --- a/spec/support/examples/lib/settings/scoped_settings.rb +++ b/spec/support/examples/lib/settings/scoped_settings.rb @@ -3,13 +3,13 @@ shared_examples 'ScopedSettings' do describe '[]' do it 'inherits default settings' do - expect(Setting.boost_modal).to eq false - expect(Setting.interactions['must_be_follower']).to eq false + expect(Setting.boost_modal).to be false + expect(Setting.interactions['must_be_follower']).to be false settings = create! - expect(settings['boost_modal']).to eq false - expect(settings['interactions']['must_be_follower']).to eq false + expect(settings['boost_modal']).to be false + expect(settings['interactions']['must_be_follower']).to be false end end @@ -17,16 +17,16 @@ shared_examples 'ScopedSettings' do # expecting [] and []= works it 'returns records merged with default values except hashes' do - expect(Setting.boost_modal).to eq false - expect(Setting.delete_modal).to eq true + expect(Setting.boost_modal).to be false + expect(Setting.delete_modal).to be true settings = create! settings['boost_modal'] = true records = settings.all_as_records - expect(records['boost_modal'].value).to eq true - expect(records['delete_modal'].value).to eq true + expect(records['boost_modal'].value).to be true + expect(records['delete_modal'].value).to be true end end @@ -34,15 +34,15 @@ shared_examples 'ScopedSettings' do # expecting [] and []= works. it 'reads settings' do - expect(Setting.boost_modal).to eq false + expect(Setting.boost_modal).to be false settings = create! - expect(settings.boost_modal).to eq false + expect(settings.boost_modal).to be false end it 'updates settings' do settings = fabricate settings.boost_modal = true - expect(settings['boost_modal']).to eq true + expect(settings['boost_modal']).to be true end end @@ -54,13 +54,13 @@ shared_examples 'ScopedSettings' do Setting.save! - expect(settings['boost_modal']).to eq true - expect(settings['interactions']['must_be_follower']).to eq true + expect(settings['boost_modal']).to be true + expect(settings['interactions']['must_be_follower']).to be true Rails.cache.clear - expect(settings['boost_modal']).to eq true - expect(settings['interactions']['must_be_follower']).to eq true + expect(settings['boost_modal']).to be true + expect(settings['interactions']['must_be_follower']).to be true end xit 'does not mutate defaults via the cache' do @@ -69,6 +69,6 @@ shared_examples 'ScopedSettings' do # This mutates the global settings default such that future # instances will inherit the incorrect starting values - expect(fabricate.settings['interactions']['must_be_follower']).to eq false + expect(fabricate.settings['interactions']['must_be_follower']).to be false end end diff --git a/spec/workers/domain_block_worker_spec.rb b/spec/workers/domain_block_worker_spec.rb index bd8fc4a62..8b98443fa 100644 --- a/spec/workers/domain_block_worker_spec.rb +++ b/spec/workers/domain_block_worker_spec.rb @@ -20,7 +20,7 @@ describe DomainBlockWorker do it 'returns true for non-existent domain block' do result = subject.perform('aaa') - expect(result).to eq(true) + expect(result).to be(true) end end end diff --git a/spec/workers/domain_clear_media_worker_spec.rb b/spec/workers/domain_clear_media_worker_spec.rb index 36251b1ec..f21d1fe18 100644 --- a/spec/workers/domain_clear_media_worker_spec.rb +++ b/spec/workers/domain_clear_media_worker_spec.rb @@ -20,7 +20,7 @@ describe DomainClearMediaWorker do it 'returns true for non-existent domain block' do result = subject.perform('aaa') - expect(result).to eq(true) + expect(result).to be(true) end end end diff --git a/spec/workers/feed_insert_worker_spec.rb b/spec/workers/feed_insert_worker_spec.rb index 1a723d63a..16f7d73e0 100644 --- a/spec/workers/feed_insert_worker_spec.rb +++ b/spec/workers/feed_insert_worker_spec.rb @@ -15,7 +15,7 @@ describe FeedInsertWorker do allow(FeedManager).to receive(:instance).and_return(instance) result = subject.perform(nil, follower.id) - expect(result).to eq true + expect(result).to be true expect(instance).to_not have_received(:push_to_home) end @@ -24,7 +24,7 @@ describe FeedInsertWorker do allow(FeedManager).to receive(:instance).and_return(instance) result = subject.perform(status.id, nil) - expect(result).to eq true + expect(result).to be true expect(instance).to_not have_received(:push_to_home) end end diff --git a/spec/workers/regeneration_worker_spec.rb b/spec/workers/regeneration_worker_spec.rb index c6bdfa0e5..147a76be5 100644 --- a/spec/workers/regeneration_worker_spec.rb +++ b/spec/workers/regeneration_worker_spec.rb @@ -20,7 +20,7 @@ describe RegenerationWorker do it 'fails when account does not exist' do result = subject.perform('aaa') - expect(result).to eq(true) + expect(result).to be(true) end end end -- cgit From 717683d1c39d2fe85d1cc3f5223e1f4cf43f1900 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 20 Feb 2023 00:58:28 -0500 Subject: Autofix Rubocop remaining Layout rules (#23679) --- .rubocop_todo.yml | 148 --------------------- Capfile | 1 + app/controllers/api/v1/tags_controller.rb | 1 + app/controllers/application_controller.rb | 1 + .../concerns/session_tracking_concern.rb | 1 + app/controllers/concerns/signature_verification.rb | 1 + app/helpers/application_helper.rb | 1 + app/helpers/languages_helper.rb | 1 + app/lib/activitypub/activity.rb | 1 + app/lib/activitypub/linked_data_signature.rb | 2 +- app/lib/activitypub/tag_manager.rb | 2 + app/lib/ostatus/tag_manager.rb | 32 ++--- app/lib/request.rb | 1 + app/lib/settings/scoped_settings.rb | 2 + app/lib/status_filter.rb | 1 + app/lib/tag_manager.rb | 1 + app/lib/webfinger.rb | 1 + app/models/account.rb | 2 + app/models/account/field.rb | 4 +- app/models/account_conversation.rb | 2 + app/models/account_domain_block.rb | 1 + app/models/account_moderation_note.rb | 1 + app/models/account_note.rb | 1 + app/models/account_pin.rb | 1 + app/models/account_stat.rb | 1 + app/models/account_summary.rb | 1 + app/models/account_warning.rb | 13 +- app/models/admin/import.rb | 1 + app/models/backup.rb | 1 + app/models/block.rb | 1 + app/models/bookmark.rb | 1 + app/models/canonical_email_block.rb | 1 + app/models/conversation.rb | 1 + app/models/conversation_mute.rb | 1 + app/models/custom_emoji.rb | 1 + app/models/custom_filter.rb | 3 + app/models/custom_filter_keyword.rb | 1 + app/models/custom_filter_status.rb | 1 + app/models/device.rb | 1 + app/models/domain_block.rb | 1 + app/models/email_domain_block.rb | 1 + app/models/encrypted_message.rb | 1 + app/models/favourite.rb | 2 + app/models/featured_tag.rb | 1 + app/models/follow.rb | 1 + app/models/follow_recommendation.rb | 1 + app/models/follow_recommendation_suppression.rb | 1 + app/models/follow_request.rb | 1 + app/models/form/admin_settings.rb | 1 + app/models/identity.rb | 1 + app/models/import.rb | 1 + app/models/instance.rb | 1 + app/models/invite.rb | 1 + app/models/ip_block.rb | 1 + app/models/list.rb | 1 + app/models/list_account.rb | 1 + app/models/login_activity.rb | 1 + app/models/media_attachment.rb | 3 +- app/models/mention.rb | 1 + app/models/mute.rb | 1 + app/models/notification.rb | 11 +- app/models/one_time_key.rb | 1 + app/models/poll.rb | 8 +- app/models/poll_vote.rb | 1 + app/models/preview_card.rb | 1 + app/models/preview_card_provider.rb | 1 + app/models/relay.rb | 1 + app/models/report.rb | 1 + app/models/report_note.rb | 1 + app/models/session_activation.rb | 2 + app/models/setting.rb | 4 + app/models/site_upload.rb | 1 + app/models/status.rb | 1 + app/models/status_edit.rb | 2 + app/models/status_pin.rb | 1 + app/models/status_stat.rb | 1 + app/models/tag.rb | 1 + app/models/unavailable_domain.rb | 1 + app/models/user.rb | 4 + app/models/user_ip.rb | 1 + app/models/user_role.rb | 2 + app/models/web/push_subscription.rb | 1 + app/models/web/setting.rb | 1 + app/models/webauthn_credential.rb | 1 + app/presenters/account_relationships_presenter.rb | 18 +-- .../activitypub/fetch_remote_actor_service.rb | 1 + .../activitypub/fetch_remote_status_service.rb | 1 + app/services/activitypub/fetch_replies_service.rb | 1 + .../activitypub/process_account_service.rb | 2 + app/services/favourite_service.rb | 1 + app/services/keys/claim_service.rb | 6 +- app/services/keys/query_service.rb | 6 +- app/services/notify_service.rb | 1 + app/services/post_status_service.rb | 3 + app/services/vote_service.rb | 2 + app/validators/follow_limit_validator.rb | 1 + app/validators/unreserved_username_validator.rb | 2 + .../accounts_statuses_cleanup_scheduler.rb | 2 + app/workers/web/push_notification_worker.rb | 12 +- config.ru | 1 + ...314181829_migrate_open_registrations_setting.rb | 2 + ...43559_preserve_old_layout_for_existing_users.rb | 1 + ...431_add_case_insensitive_btree_index_to_tags.rb | 1 + .../20220613110834_add_action_to_custom_filters.rb | 1 + .../20200917193528_migrate_notifications_type.rb | 10 +- ...110802_remove_whole_word_from_custom_filters.rb | 1 + ...0903_remove_irreversible_from_custom_filters.rb | 1 + .../20221101190723_backfill_admin_action_logs.rb | 13 ++ ...21206114142_backfill_admin_action_logs_again.rb | 13 ++ lib/mastodon/domains_cli.rb | 2 + lib/sanitize_ext/sanitize_config.rb | 12 +- lib/tasks/auto_annotate_models.rake | 70 +++++----- lib/tasks/mastodon.rake | 16 +-- .../api/v1/accounts/statuses_controller_spec.rb | 1 + spec/models/admin/account_action_spec.rb | 4 +- spec/models/concerns/account_interactions_spec.rb | 4 +- spec/models/tag_spec.rb | 1 + 117 files changed, 265 insertions(+), 261 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0f98d25d6..e667a7786 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,154 +14,6 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 81 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'app/controllers/api/v1/tags_controller.rb' - - 'app/controllers/application_controller.rb' - - 'app/controllers/concerns/session_tracking_concern.rb' - - 'app/controllers/concerns/signature_verification.rb' - - 'app/helpers/application_helper.rb' - - 'app/lib/activitypub/activity.rb' - - 'app/lib/activitypub/tag_manager.rb' - - 'app/lib/request.rb' - - 'app/lib/settings/scoped_settings.rb' - - 'app/lib/status_filter.rb' - - 'app/lib/tag_manager.rb' - - 'app/lib/webfinger.rb' - - 'app/models/account.rb' - - 'app/models/account_conversation.rb' - - 'app/models/admin/import.rb' - - 'app/models/custom_filter.rb' - - 'app/models/favourite.rb' - - 'app/models/form/admin_settings.rb' - - 'app/models/poll.rb' - - 'app/models/session_activation.rb' - - 'app/models/setting.rb' - - 'app/models/status_edit.rb' - - 'app/models/user.rb' - - 'app/models/user_role.rb' - - 'app/services/activitypub/fetch_remote_actor_service.rb' - - 'app/services/activitypub/fetch_remote_status_service.rb' - - 'app/services/activitypub/fetch_replies_service.rb' - - 'app/services/activitypub/process_account_service.rb' - - 'app/services/favourite_service.rb' - - 'app/services/notify_service.rb' - - 'app/services/post_status_service.rb' - - 'app/services/vote_service.rb' - - 'app/validators/follow_limit_validator.rb' - - 'app/validators/unreserved_username_validator.rb' - - 'app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb' - - 'db/migrate/20190314181829_migrate_open_registrations_setting.rb' - - 'db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb' - - 'db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb' - - 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb' - - 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb' - - 'lib/mastodon/domains_cli.rb' - -# Offense count: 71 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'Capfile' - - 'app/helpers/languages_helper.rb' - - 'app/models/account.rb' - - 'app/models/account_conversation.rb' - - 'app/models/account_domain_block.rb' - - 'app/models/account_moderation_note.rb' - - 'app/models/account_note.rb' - - 'app/models/account_pin.rb' - - 'app/models/account_stat.rb' - - 'app/models/account_summary.rb' - - 'app/models/account_warning.rb' - - 'app/models/backup.rb' - - 'app/models/block.rb' - - 'app/models/bookmark.rb' - - 'app/models/canonical_email_block.rb' - - 'app/models/conversation.rb' - - 'app/models/conversation_mute.rb' - - 'app/models/custom_emoji.rb' - - 'app/models/custom_filter.rb' - - 'app/models/custom_filter_keyword.rb' - - 'app/models/custom_filter_status.rb' - - 'app/models/device.rb' - - 'app/models/domain_block.rb' - - 'app/models/email_domain_block.rb' - - 'app/models/encrypted_message.rb' - - 'app/models/favourite.rb' - - 'app/models/featured_tag.rb' - - 'app/models/follow.rb' - - 'app/models/follow_recommendation.rb' - - 'app/models/follow_recommendation_suppression.rb' - - 'app/models/follow_request.rb' - - 'app/models/identity.rb' - - 'app/models/import.rb' - - 'app/models/instance.rb' - - 'app/models/invite.rb' - - 'app/models/ip_block.rb' - - 'app/models/list.rb' - - 'app/models/list_account.rb' - - 'app/models/login_activity.rb' - - 'app/models/media_attachment.rb' - - 'app/models/mention.rb' - - 'app/models/mute.rb' - - 'app/models/notification.rb' - - 'app/models/one_time_key.rb' - - 'app/models/poll.rb' - - 'app/models/poll_vote.rb' - - 'app/models/preview_card.rb' - - 'app/models/preview_card_provider.rb' - - 'app/models/relay.rb' - - 'app/models/report.rb' - - 'app/models/report_note.rb' - - 'app/models/session_activation.rb' - - 'app/models/setting.rb' - - 'app/models/site_upload.rb' - - 'app/models/status.rb' - - 'app/models/status_edit.rb' - - 'app/models/status_pin.rb' - - 'app/models/status_stat.rb' - - 'app/models/tag.rb' - - 'app/models/unavailable_domain.rb' - - 'app/models/user.rb' - - 'app/models/user_ip.rb' - - 'app/models/web/push_subscription.rb' - - 'app/models/web/setting.rb' - - 'app/models/webauthn_credential.rb' - - 'config.ru' - - 'db/migrate/20220613110834_add_action_to_custom_filters.rb' - - 'db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb' - - 'db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb' - - 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' - - 'spec/models/tag_spec.rb' - -# Offense count: 113 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'app/lib/activitypub/linked_data_signature.rb' - - 'app/lib/ostatus/tag_manager.rb' - - 'app/models/account/field.rb' - - 'app/models/account_warning.rb' - - 'app/models/media_attachment.rb' - - 'app/models/notification.rb' - - 'app/models/poll.rb' - - 'app/presenters/account_relationships_presenter.rb' - - 'app/services/keys/claim_service.rb' - - 'app/services/keys/query_service.rb' - - 'app/workers/web/push_notification_worker.rb' - - 'db/post_migrate/20200917193528_migrate_notifications_type.rb' - - 'lib/sanitize_ext/sanitize_config.rb' - - 'lib/tasks/auto_annotate_models.rake' - - 'lib/tasks/mastodon.rake' - - 'spec/models/admin/account_action_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - # Offense count: 581 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. diff --git a/Capfile b/Capfile index bf3ae7e24..86efa5bac 100644 --- a/Capfile +++ b/Capfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/scm/git' diff --git a/app/controllers/api/v1/tags_controller.rb b/app/controllers/api/v1/tags_controller.rb index 272362c31..a08fd2187 100644 --- a/app/controllers/api/v1/tags_controller.rb +++ b/app/controllers/api/v1/tags_controller.rb @@ -25,6 +25,7 @@ class Api::V1::TagsController < Api::BaseController def set_or_create_tag return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id]) + @tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 615536b96..ad70e28ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -128,6 +128,7 @@ class ApplicationController < ActionController::Base def current_theme return Setting.theme unless Themes.instance.names.include? current_user&.setting_theme + current_user.setting_theme end diff --git a/app/controllers/concerns/session_tracking_concern.rb b/app/controllers/concerns/session_tracking_concern.rb index eaaa4ac59..3f56c0d02 100644 --- a/app/controllers/concerns/session_tracking_concern.rb +++ b/app/controllers/concerns/session_tracking_concern.rb @@ -13,6 +13,7 @@ module SessionTrackingConcern def set_session_activity return unless session_needs_update? + current_session.touch end diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index 9c04ab4ca..b0a087d53 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -165,6 +165,7 @@ module SignatureVerification end raise SignatureVerificationError, "Invalid Digest value. The provided Digest value is not a SHA-256 digest. Given digest: #{sha256[1]}" if digest_size != 32 + raise SignatureVerificationError, "Invalid Digest value. Computed SHA-256 digest: #{body_digest}; given: #{sha256[1]}" end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1f93b33f5..08020a65a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -105,6 +105,7 @@ module ApplicationHelper def can?(action, record) return false if record.nil? + policy(record).public_send("#{action}?") end diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb index bb35ce08c..584394758 100644 --- a/app/helpers/languages_helper.rb +++ b/app/helpers/languages_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # rubocop:disable Metrics/ModuleLength, Style/WordArray module LanguagesHelper diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 900428e92..5d9596254 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -153,6 +153,7 @@ class ActivityPub::Activity def fetch_remote_original_status if object_uri.start_with?('http') return if ActivityPub::TagManager.instance.local_uri?(object_uri) + ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first, request_id: @options[:request_id]) elsif @object['url'].present? ::FetchRemoteStatusService.new.call(@object['url'], request_id: @options[:request_id]) diff --git a/app/lib/activitypub/linked_data_signature.rb b/app/lib/activitypub/linked_data_signature.rb index 61759649a..ea59879f3 100644 --- a/app/lib/activitypub/linked_data_signature.rb +++ b/app/lib/activitypub/linked_data_signature.rb @@ -32,7 +32,7 @@ class ActivityPub::LinkedDataSignature def sign!(creator, sign_with: nil) options = { - 'type' => 'RsaSignature2017', + 'type' => 'RsaSignature2017', 'creator' => ActivityPub::TagManager.instance.key_uri_for(creator), 'created' => Time.now.utc.iso8601, } diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 3d6b28ef5..a65a9565a 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -26,6 +26,7 @@ class ActivityPub::TagManager target.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(target) when :note, :comment, :activity return activity_account_status_url(target.account, target) if target.reblog? + short_account_status_url(target.account, target) end end @@ -38,6 +39,7 @@ class ActivityPub::TagManager target.instance_actor? ? instance_actor_url : account_url(target) when :note, :comment, :activity return activity_account_status_url(target.account, target) if target.reblog? + account_status_url(target.account, target) when :emoji emoji_url(target) diff --git a/app/lib/ostatus/tag_manager.rb b/app/lib/ostatus/tag_manager.rb index 4f4501312..7d8131622 100644 --- a/app/lib/ostatus/tag_manager.rb +++ b/app/lib/ostatus/tag_manager.rb @@ -5,27 +5,27 @@ class OStatus::TagManager include RoutingHelper VERBS = { - post: 'http://activitystrea.ms/schema/1.0/post', - share: 'http://activitystrea.ms/schema/1.0/share', - favorite: 'http://activitystrea.ms/schema/1.0/favorite', - unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite', - delete: 'http://activitystrea.ms/schema/1.0/delete', - follow: 'http://activitystrea.ms/schema/1.0/follow', + post: 'http://activitystrea.ms/schema/1.0/post', + share: 'http://activitystrea.ms/schema/1.0/share', + favorite: 'http://activitystrea.ms/schema/1.0/favorite', + unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite', + delete: 'http://activitystrea.ms/schema/1.0/delete', + follow: 'http://activitystrea.ms/schema/1.0/follow', request_friend: 'http://activitystrea.ms/schema/1.0/request-friend', - authorize: 'http://activitystrea.ms/schema/1.0/authorize', - reject: 'http://activitystrea.ms/schema/1.0/reject', - unfollow: 'http://ostatus.org/schema/1.0/unfollow', - block: 'http://mastodon.social/schema/1.0/block', - unblock: 'http://mastodon.social/schema/1.0/unblock', + authorize: 'http://activitystrea.ms/schema/1.0/authorize', + reject: 'http://activitystrea.ms/schema/1.0/reject', + unfollow: 'http://ostatus.org/schema/1.0/unfollow', + block: 'http://mastodon.social/schema/1.0/block', + unblock: 'http://mastodon.social/schema/1.0/unblock', }.freeze TYPES = { - activity: 'http://activitystrea.ms/schema/1.0/activity', - note: 'http://activitystrea.ms/schema/1.0/note', - comment: 'http://activitystrea.ms/schema/1.0/comment', - person: 'http://activitystrea.ms/schema/1.0/person', + activity: 'http://activitystrea.ms/schema/1.0/activity', + note: 'http://activitystrea.ms/schema/1.0/note', + comment: 'http://activitystrea.ms/schema/1.0/comment', + person: 'http://activitystrea.ms/schema/1.0/person', collection: 'http://activitystrea.ms/schema/1.0/collection', - group: 'http://activitystrea.ms/schema/1.0/group', + group: 'http://activitystrea.ms/schema/1.0/group', }.freeze COLLECTIONS = { diff --git a/app/lib/request.rb b/app/lib/request.rb index be6a69b3f..85716f999 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -182,6 +182,7 @@ class Request contents = truncated_body(limit) raise Mastodon::LengthValidationError if contents.bytesize > limit + contents end end diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb index 1e18d6d46..3ad57cc1e 100644 --- a/app/lib/settings/scoped_settings.rb +++ b/app/lib/settings/scoped_settings.rb @@ -34,6 +34,7 @@ module Settings Setting.default_settings.each do |key, default_value| next if records.key?(key) || default_value.is_a?(Hash) + records[key] = Setting.new(var: key, value: default_value) end @@ -54,6 +55,7 @@ module Settings if db_val default_value = ScopedSettings.default_settings[key] return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash) + db_val.value else ScopedSettings.default_settings[key] diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index b6c80b801..c0e6f3331 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -11,6 +11,7 @@ class StatusFilter def filtered? return false if !account.nil? && account.id == status.account_id + blocked_by_policy? || (account_present? && filtered_status?) || silenced_account? end diff --git a/app/lib/tag_manager.rb b/app/lib/tag_manager.rb index a1d12a654..7fbf4437d 100644 --- a/app/lib/tag_manager.rb +++ b/app/lib/tag_manager.rb @@ -25,6 +25,7 @@ class TagManager def local_url?(url) uri = Addressable::URI.parse(url).normalize return false unless uri.host + domain = uri.host + (uri.port ? ":#{uri.port}" : '') TagManager.instance.web_domain?(domain) diff --git a/app/lib/webfinger.rb b/app/lib/webfinger.rb index 42ddef47b..ae8a3b1ea 100644 --- a/app/lib/webfinger.rb +++ b/app/lib/webfinger.rb @@ -57,6 +57,7 @@ class Webfinger if res.code == 200 body = res.body_with_limit raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty? + body elsif res.code == 404 && use_fallback body_from_host_meta diff --git a/app/models/account.rb b/app/models/account.rb index d33110d55..09c450f2a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: accounts @@ -539,6 +540,7 @@ class Account < ApplicationRecord def ensure_keys! return unless local? && private_key.blank? && public_key.blank? + generate_keys save! end diff --git a/app/models/account/field.rb b/app/models/account/field.rb index 98c29726d..2bada6954 100644 --- a/app/models/account/field.rb +++ b/app/models/account/field.rb @@ -14,8 +14,8 @@ class Account::Field < ActiveModelSerializers::Model @account = account super( - name: sanitize(attributes['name']), - value: sanitize(attributes['value']), + name: sanitize(attributes['name']), + value: sanitize(attributes['value']), verified_at: attributes['verified_at']&.to_datetime, ) end diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb index 45e74bbeb..b3ddc04c1 100644 --- a/app/models/account_conversation.rb +++ b/app/models/account_conversation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_conversations @@ -107,6 +108,7 @@ class AccountConversation < ApplicationRecord def push_to_streaming_api return if destroyed? || !subscribed_to_timeline? + PushConversationWorker.perform_async(id) end diff --git a/app/models/account_domain_block.rb b/app/models/account_domain_block.rb index 3aaffde9a..af1e6a68d 100644 --- a/app/models/account_domain_block.rb +++ b/app/models/account_domain_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_domain_blocks diff --git a/app/models/account_moderation_note.rb b/app/models/account_moderation_note.rb index 22e312bb2..ff399bab0 100644 --- a/app/models/account_moderation_note.rb +++ b/app/models/account_moderation_note.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_moderation_notes diff --git a/app/models/account_note.rb b/app/models/account_note.rb index b338bc92f..9bc704d98 100644 --- a/app/models/account_note.rb +++ b/app/models/account_note.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_notes diff --git a/app/models/account_pin.rb b/app/models/account_pin.rb index b51d3d4cd..6c78e8c44 100644 --- a/app/models/account_pin.rb +++ b/app/models/account_pin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_pins diff --git a/app/models/account_stat.rb b/app/models/account_stat.rb index a5d71a5b8..834f8ba4c 100644 --- a/app/models/account_stat.rb +++ b/app/models/account_stat.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_stats diff --git a/app/models/account_summary.rb b/app/models/account_summary.rb index 3a3cebc55..0d8835b83 100644 --- a/app/models/account_summary.rb +++ b/app/models/account_summary.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_summaries diff --git a/app/models/account_warning.rb b/app/models/account_warning.rb index a181cd18d..4f8cc5320 100644 --- a/app/models/account_warning.rb +++ b/app/models/account_warning.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: account_warnings @@ -17,13 +18,13 @@ class AccountWarning < ApplicationRecord enum action: { - none: 0, - disable: 1_000, + none: 0, + disable: 1_000, mark_statuses_as_sensitive: 1_250, - delete_statuses: 1_500, - sensitive: 2_000, - silence: 3_000, - suspend: 4_000, + delete_statuses: 1_500, + sensitive: 2_000, + silence: 3_000, + suspend: 4_000, }, _suffix: :action before_validation :before_validate diff --git a/app/models/admin/import.rb b/app/models/admin/import.rb index fecde4878..0fd4bdb82 100644 --- a/app/models/admin/import.rb +++ b/app/models/admin/import.rb @@ -56,6 +56,7 @@ class Admin::Import def validate_data return if data.nil? + errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if csv_row_count > ROWS_PROCESSING_LIMIT rescue CSV::MalformedCSVError => e errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message)) diff --git a/app/models/backup.rb b/app/models/backup.rb index 277b9395b..bec3cbfe5 100644 --- a/app/models/backup.rb +++ b/app/models/backup.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: backups diff --git a/app/models/block.rb b/app/models/block.rb index bf3e07600..b42c1569b 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: blocks diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 6334ef0df..04b660372 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: bookmarks diff --git a/app/models/canonical_email_block.rb b/app/models/canonical_email_block.rb index 1eb69ac67..d09df6f5e 100644 --- a/app/models/canonical_email_block.rb +++ b/app/models/canonical_email_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: canonical_email_blocks diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 4dfaea889..5de259962 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: conversations diff --git a/app/models/conversation_mute.rb b/app/models/conversation_mute.rb index 52c1a33e0..31f8e1966 100644 --- a/app/models/conversation_mute.rb +++ b/app/models/conversation_mute.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: conversation_mutes diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index 304805659..3d7900226 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_emojis diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index 781bf4db8..d85e196e9 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_filters @@ -101,6 +102,7 @@ class CustomFilter < ApplicationRecord status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present? next if keyword_matches.blank? && status_matches.blank? + FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches) end end @@ -111,6 +113,7 @@ class CustomFilter < ApplicationRecord def invalidate_cache! return unless @should_invalidate_cache + @should_invalidate_cache = false Rails.cache.delete("filters:v3:#{account_id}") diff --git a/app/models/custom_filter_keyword.rb b/app/models/custom_filter_keyword.rb index e0d0289ae..3158b3b79 100644 --- a/app/models/custom_filter_keyword.rb +++ b/app/models/custom_filter_keyword.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_filter_keywords diff --git a/app/models/custom_filter_status.rb b/app/models/custom_filter_status.rb index e748d6963..0a5650204 100644 --- a/app/models/custom_filter_status.rb +++ b/app/models/custom_filter_status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: custom_filter_statuses diff --git a/app/models/device.rb b/app/models/device.rb index 97d0d2774..5dc6cf1e6 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: devices diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 190f5ba2e..fbb045416 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: domain_blocks diff --git a/app/models/email_domain_block.rb b/app/models/email_domain_block.rb index 3a56e4f2a..276e7d31a 100644 --- a/app/models/email_domain_block.rb +++ b/app/models/email_domain_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: email_domain_blocks diff --git a/app/models/encrypted_message.rb b/app/models/encrypted_message.rb index 7b4e32283..3e7e95594 100644 --- a/app/models/encrypted_message.rb +++ b/app/models/encrypted_message.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: encrypted_messages diff --git a/app/models/favourite.rb b/app/models/favourite.rb index 2f355739a..042f72bea 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: favourites @@ -38,6 +39,7 @@ class Favourite < ApplicationRecord def decrement_cache_counters return if association(:status).loaded? && status.marked_for_destruction? + status&.decrement_count!(:favourites_count) end diff --git a/app/models/featured_tag.rb b/app/models/featured_tag.rb index 70f949b6a..587dcf991 100644 --- a/app/models/featured_tag.rb +++ b/app/models/featured_tag.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: featured_tags diff --git a/app/models/follow.rb b/app/models/follow.rb index e5cecbbc1..108f5c5d5 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follows diff --git a/app/models/follow_recommendation.rb b/app/models/follow_recommendation.rb index 501f8ecb6..602d32985 100644 --- a/app/models/follow_recommendation.rb +++ b/app/models/follow_recommendation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follow_recommendations diff --git a/app/models/follow_recommendation_suppression.rb b/app/models/follow_recommendation_suppression.rb index 170506b85..a9dbbfc18 100644 --- a/app/models/follow_recommendation_suppression.rb +++ b/app/models/follow_recommendation_suppression.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follow_recommendation_suppressions diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb index 9034250c0..78f79c18f 100644 --- a/app/models/follow_request.rb +++ b/app/models/follow_request.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: follow_requests diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 95c53084a..de965cb0b 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -128,6 +128,7 @@ class Form::AdminSettings def validate_site_uploads UPLOAD_KEYS.each do |key| next unless instance_variable_defined?("@#{key}") + upload = instance_variable_get("@#{key}") next if upload.valid? diff --git a/app/models/identity.rb b/app/models/identity.rb index 8cc65aef4..6f10fed4d 100644 --- a/app/models/identity.rb +++ b/app/models/identity.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: identities diff --git a/app/models/import.rb b/app/models/import.rb index cd33eb07b..21634005e 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: imports diff --git a/app/models/instance.rb b/app/models/instance.rb index edbf02a6d..1f96d3728 100644 --- a/app/models/instance.rb +++ b/app/models/instance.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: instances diff --git a/app/models/invite.rb b/app/models/invite.rb index 7ea4e2f98..8e816cef0 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: invites diff --git a/app/models/ip_block.rb b/app/models/ip_block.rb index 31343f0e1..99783050b 100644 --- a/app/models/ip_block.rb +++ b/app/models/ip_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: ip_blocks diff --git a/app/models/list.rb b/app/models/list.rb index 7b8cf6636..bd1bdbd24 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: lists diff --git a/app/models/list_account.rb b/app/models/list_account.rb index 785923c4c..a5767d3d8 100644 --- a/app/models/list_account.rb +++ b/app/models/list_account.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: list_accounts diff --git a/app/models/login_activity.rb b/app/models/login_activity.rb index 52a0fd01d..2b7b37f8e 100644 --- a/app/models/login_activity.rb +++ b/app/models/login_activity.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: login_activities diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index c6f2352e0..08abd4e43 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: media_attachments @@ -372,7 +373,7 @@ class MediaAttachment < ApplicationRecord return {} if width.nil? { - width: width, + width: width, height: height, size: "#{width}x#{height}", aspect: width.to_f / height, diff --git a/app/models/mention.rb b/app/models/mention.rb index d01a88e32..2348b2905 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: mentions diff --git a/app/models/mute.rb b/app/models/mute.rb index 578345ef6..8fc542262 100644 --- a/app/models/mute.rb +++ b/app/models/mute.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: mutes diff --git a/app/models/notification.rb b/app/models/notification.rb index 01155c363..3eaf557b0 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: notifications @@ -19,12 +20,12 @@ class Notification < ApplicationRecord include Paginable LEGACY_TYPE_CLASS_MAP = { - 'Mention' => :mention, - 'Status' => :reblog, - 'Follow' => :follow, + 'Mention' => :mention, + 'Status' => :reblog, + 'Follow' => :follow, 'FollowRequest' => :follow_request, - 'Favourite' => :favourite, - 'Poll' => :poll, + 'Favourite' => :favourite, + 'Poll' => :poll, }.freeze TYPES = %i( diff --git a/app/models/one_time_key.rb b/app/models/one_time_key.rb index 8ada34824..23604e2f7 100644 --- a/app/models/one_time_key.rb +++ b/app/models/one_time_key.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: one_time_keys diff --git a/app/models/poll.rb b/app/models/poll.rb index af3b09315..dd35e953b 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: polls @@ -74,9 +75,9 @@ class Poll < ApplicationRecord def initialize(poll, id, title, votes_count) super( - poll: poll, - id: id, - title: title, + poll: poll, + id: id, + title: title, votes_count: votes_count, ) end @@ -105,6 +106,7 @@ class Poll < ApplicationRecord def reset_parent_cache return if status_id.nil? + Rails.cache.delete("statuses/#{status_id}") end diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb index ad24eb691..00eaedd12 100644 --- a/app/models/poll_vote.rb +++ b/app/models/poll_vote.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: poll_votes diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index d25fe6dad..6bce16562 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: preview_cards diff --git a/app/models/preview_card_provider.rb b/app/models/preview_card_provider.rb index d61fe6020..1dd95fc91 100644 --- a/app/models/preview_card_provider.rb +++ b/app/models/preview_card_provider.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: preview_card_providers diff --git a/app/models/relay.rb b/app/models/relay.rb index e9c425743..a5fa03a99 100644 --- a/app/models/relay.rb +++ b/app/models/relay.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: relays diff --git a/app/models/report.rb b/app/models/report.rb index fe6c292c5..a9940459d 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: reports diff --git a/app/models/report_note.rb b/app/models/report_note.rb index 6d7167e0e..74b46027e 100644 --- a/app/models/report_note.rb +++ b/app/models/report_note.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: report_notes diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb index 0b7fa6fe4..10c3a6c25 100644 --- a/app/models/session_activation.rb +++ b/app/models/session_activation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: session_activations @@ -51,6 +52,7 @@ class SessionActivation < ApplicationRecord def deactivate(id) return unless id + where(session_id: id).destroy_all end diff --git a/app/models/setting.rb b/app/models/setting.rb index c6558d692..3bdc6ffb4 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: settings @@ -30,6 +31,7 @@ class Setting < RailsSettings::Base default_value = default_settings[key] return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash) + db_val.value else default_settings[key] @@ -43,6 +45,7 @@ class Setting < RailsSettings::Base default_settings.each do |key, default_value| next if records.key?(key) || default_value.is_a?(Hash) + records[key] = Setting.new(var: key, value: default_value) end @@ -51,6 +54,7 @@ class Setting < RailsSettings::Base def default_settings return {} unless RailsSettings::Default.enabled? + RailsSettings::Default.instance end end diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb index 167131fdd..e17668110 100644 --- a/app/models/site_upload.rb +++ b/app/models/site_upload.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: site_uploads diff --git a/app/models/status.rb b/app/models/status.rb index 44a297a08..2eb47d72c 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: statuses diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb index dd2d5fc1e..683441bb5 100644 --- a/app/models/status_edit.rb +++ b/app/models/status_edit.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: status_edits @@ -45,6 +46,7 @@ class StatusEdit < ApplicationRecord def emojis return @emojis if defined?(@emojis) + @emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain) end diff --git a/app/models/status_pin.rb b/app/models/status_pin.rb index 93a0ea1c0..dae4a5b4e 100644 --- a/app/models/status_pin.rb +++ b/app/models/status_pin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: status_pins diff --git a/app/models/status_stat.rb b/app/models/status_stat.rb index 437861d1c..d101cc178 100644 --- a/app/models/status_stat.rb +++ b/app/models/status_stat.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: status_stats diff --git a/app/models/tag.rb b/app/models/tag.rb index 98001d60a..554a92d90 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: tags diff --git a/app/models/unavailable_domain.rb b/app/models/unavailable_domain.rb index dfc0ef14e..c3f2f20e9 100644 --- a/app/models/unavailable_domain.rb +++ b/app/models/unavailable_domain.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: unavailable_domains diff --git a/app/models/user.rb b/app/models/user.rb index c767f8984..5e106dee5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: users @@ -492,12 +493,14 @@ class User < ApplicationRecord def sanitize_languages return if chosen_languages.nil? + chosen_languages.reject!(&:blank?) self.chosen_languages = nil if chosen_languages.empty? end def sanitize_role return if role.nil? + self.role = nil if role.everyone? end @@ -516,6 +519,7 @@ class User < ApplicationRecord def notify_staff_about_pending_account! User.those_who_can(:manage_users).includes(:account).find_each do |u| next unless u.allows_pending_account_emails? + AdminMailer.new_pending_account(u.account, self).deliver_later end end diff --git a/app/models/user_ip.rb b/app/models/user_ip.rb index 1da615762..38287c2a6 100644 --- a/app/models/user_ip.rb +++ b/app/models/user_ip.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: user_ips diff --git a/app/models/user_role.rb b/app/models/user_role.rb index 74dfdc220..a1b91dc0f 100644 --- a/app/models/user_role.rb +++ b/app/models/user_role.rb @@ -163,6 +163,7 @@ class UserRole < ApplicationRecord def in_permissions?(privilege) raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege) + computed_permissions & FLAGS[privilege] == FLAGS[privilege] end @@ -172,6 +173,7 @@ class UserRole < ApplicationRecord def validate_own_role_edition return unless defined?(@current_account) && @current_account.user_role.id == id + errors.add(:permissions_as_keys, :own_role) if permissions_changed? errors.add(:position, :own_role) if position_changed? end diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index dfaadf5cc..0ffbe068e 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: web_push_subscriptions diff --git a/app/models/web/setting.rb b/app/models/web/setting.rb index 99588d26c..3d5efe664 100644 --- a/app/models/web/setting.rb +++ b/app/models/web/setting.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: web_settings diff --git a/app/models/webauthn_credential.rb b/app/models/webauthn_credential.rb index 48abfc1d4..4fa31ece5 100644 --- a/app/models/webauthn_credential.rb +++ b/app/models/webauthn_credential.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # == Schema Information # # Table name: webauthn_credentials diff --git a/app/presenters/account_relationships_presenter.rb b/app/presenters/account_relationships_presenter.rb index ab8bac412..5d2b5435d 100644 --- a/app/presenters/account_relationships_presenter.rb +++ b/app/presenters/account_relationships_presenter.rb @@ -70,16 +70,16 @@ class AccountRelationshipsPresenter def cache_uncached! @uncached_account_ids.each do |account_id| maps_for_account = { - following: { account_id => following[account_id] }, - followed_by: { account_id => followed_by[account_id] }, - blocking: { account_id => blocking[account_id] }, - blocked_by: { account_id => blocked_by[account_id] }, - muting: { account_id => muting[account_id] }, - requested: { account_id => requested[account_id] }, - requested_by: { account_id => requested_by[account_id] }, + following: { account_id => following[account_id] }, + followed_by: { account_id => followed_by[account_id] }, + blocking: { account_id => blocking[account_id] }, + blocked_by: { account_id => blocked_by[account_id] }, + muting: { account_id => muting[account_id] }, + requested: { account_id => requested[account_id] }, + requested_by: { account_id => requested_by[account_id] }, domain_blocking: { account_id => domain_blocking[account_id] }, - endorsed: { account_id => endorsed[account_id] }, - account_note: { account_id => account_note[account_id] }, + endorsed: { account_id => endorsed[account_id] }, + account_note: { account_id => account_note[account_id] }, } Rails.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day) diff --git a/app/services/activitypub/fetch_remote_actor_service.rb b/app/services/activitypub/fetch_remote_actor_service.rb index e8992b845..ee0eaff08 100644 --- a/app/services/activitypub/fetch_remote_actor_service.rb +++ b/app/services/activitypub/fetch_remote_actor_service.rb @@ -50,6 +50,7 @@ class ActivityPub::FetchRemoteActorService < BaseService if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero? raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri + return end diff --git a/app/services/activitypub/fetch_remote_status_service.rb b/app/services/activitypub/fetch_remote_status_service.rb index aea80f078..ab0acf7f0 100644 --- a/app/services/activitypub/fetch_remote_status_service.rb +++ b/app/services/activitypub/fetch_remote_status_service.rb @@ -56,6 +56,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService def trustworthy_attribution?(uri, attributed_to) return false if uri.nil? || attributed_to.nil? + Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero? end diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 4128df9ca..3fe150ba2 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -36,6 +36,7 @@ class ActivityPub::FetchRepliesService < BaseService return collection_or_uri if collection_or_uri.is_a?(Hash) return unless @allow_synchronous_requests return if invalid_origin?(collection_or_uri) + fetch_resource_without_id_validation(collection_or_uri, nil, true) end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 2da9096c7..603e4cf48 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -226,6 +226,7 @@ class ActivityPub::ProcessAccountService < BaseService def property_values return unless @json['attachment'].is_a?(Array) + as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') } end @@ -289,6 +290,7 @@ class ActivityPub::ProcessAccountService < BaseService def domain_block return @domain_block if defined?(@domain_block) + @domain_block = DomainBlock.rule_for(@domain) end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index dc7fe8855..6fdc92a17 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -40,6 +40,7 @@ class FavouriteService < BaseService def bump_potential_friendship(account, status) ActivityTracker.increment('activity:interactions') return if account.following?(status.account_id) + PotentialFriendshipTracker.record(account.id, status.account_id, :favourite) end diff --git a/app/services/keys/claim_service.rb b/app/services/keys/claim_service.rb index 0451c3cb1..ebce9cce7 100644 --- a/app/services/keys/claim_service.rb +++ b/app/services/keys/claim_service.rb @@ -9,10 +9,10 @@ class Keys::ClaimService < BaseService def initialize(account, device_id, key_attributes = {}) super( - account: account, + account: account, device_id: device_id, - key_id: key_attributes[:key_id], - key: key_attributes[:key], + key_id: key_attributes[:key_id], + key: key_attributes[:key], signature: key_attributes[:signature], ) end diff --git a/app/services/keys/query_service.rb b/app/services/keys/query_service.rb index 404854c9f..14c9d9205 100644 --- a/app/services/keys/query_service.rb +++ b/app/services/keys/query_service.rb @@ -23,9 +23,9 @@ class Keys::QueryService < BaseService def initialize(attributes = {}) super( - device_id: attributes[:device_id], - name: attributes[:name], - identity_key: attributes[:identity_key], + device_id: attributes[:device_id], + name: attributes[:name], + identity_key: attributes[:identity_key], fingerprint_key: attributes[:fingerprint_key], ) @claim_url = attributes[:claim_url] diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index c7454fc60..4c7acbcac 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -31,6 +31,7 @@ class NotifyService < BaseService def following_sender? return @following_sender if defined?(@following_sender) + @following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account) end diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 258af8827..ea27f374e 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -86,6 +86,7 @@ class PostStatusService < BaseService def safeguard_mentions!(status) return if @options[:allowed_mentions].nil? + expected_account_ids = @options[:allowed_mentions].map(&:to_i) unexpected_accounts = status.mentions.map(&:account).to_a.reject { |mentioned_account| expected_account_ids.include?(mentioned_account.id) } @@ -175,8 +176,10 @@ class PostStatusService < BaseService def bump_potential_friendship! return if !@status.reply? || @account.id == @status.in_reply_to_account_id + ActivityTracker.increment('activity:interactions') return if @account.following?(@status.in_reply_to_account_id) + PotentialFriendshipTracker.record(@account.id, @status.in_reply_to_account_id, :reply) end diff --git a/app/services/vote_service.rb b/app/services/vote_service.rb index 114ec285c..9ebf5a98d 100644 --- a/app/services/vote_service.rb +++ b/app/services/vote_service.rb @@ -44,11 +44,13 @@ class VoteService < BaseService def distribute_poll! return if @poll.hide_totals? + ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id) end def queue_final_poll_check! return unless @poll.expires? + PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id) end diff --git a/app/validators/follow_limit_validator.rb b/app/validators/follow_limit_validator.rb index 409bf0176..c619cb9a3 100644 --- a/app/validators/follow_limit_validator.rb +++ b/app/validators/follow_limit_validator.rb @@ -6,6 +6,7 @@ class FollowLimitValidator < ActiveModel::Validator def validate(follow) return if follow.account.nil? || !follow.account.local? + follow.errors.add(:base, I18n.t('users.follow_limit_reached', limit: self.class.limit_for_account(follow.account))) if limit_reached?(follow.account) end diff --git a/app/validators/unreserved_username_validator.rb b/app/validators/unreserved_username_validator.rb index 974f3ba62..f82f4b91d 100644 --- a/app/validators/unreserved_username_validator.rb +++ b/app/validators/unreserved_username_validator.rb @@ -13,12 +13,14 @@ class UnreservedUsernameValidator < ActiveModel::Validator def pam_controlled? return false unless Devise.pam_authentication && Devise.pam_controlled_service + Rpam2.account(Devise.pam_controlled_service, @username).present? end def reserved_username? return true if pam_controlled? return false unless Setting.reserved_usernames + Setting.reserved_usernames.include?(@username.downcase) end end diff --git a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb index cc5b6e137..09e0b37f0 100644 --- a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb +++ b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb @@ -62,6 +62,7 @@ class Scheduler::AccountsStatusesCleanupScheduler # The idea here is to loop through all policies at least once until the budget is exhausted # and start back after the last processed account otherwise break if budget.zero? || (num_processed_accounts.zero? && first_policy_id.nil?) + first_policy_id = nil end end @@ -73,6 +74,7 @@ class Scheduler::AccountsStatusesCleanupScheduler def under_load? return true if Sidekiq::Stats.new.retry_size > MAX_RETRY_SIZE + queue_under_load?('default', MAX_DEFAULT_SIZE, MAX_DEFAULT_LATENCY) || queue_under_load?('push', MAX_PUSH_SIZE, MAX_PUSH_LATENCY) || queue_under_load?('pull', MAX_PULL_SIZE, MAX_PULL_LATENCY) end diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb index 1ed5bb9e0..7e9691aab 100644 --- a/app/workers/web/push_notification_worker.rb +++ b/app/workers/web/push_notification_worker.rb @@ -22,13 +22,13 @@ class Web::PushNotificationWorker request = Request.new(:post, @subscription.endpoint, body: payload.fetch(:ciphertext), http_client: http_client) request.add_headers( - 'Content-Type' => 'application/octet-stream', - 'Ttl' => TTL, - 'Urgency' => URGENCY, + 'Content-Type' => 'application/octet-stream', + 'Ttl' => TTL, + 'Urgency' => URGENCY, 'Content-Encoding' => 'aesgcm', - 'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}", - 'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}", - 'Authorization' => @subscription.authorization_header + 'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}", + 'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}", + 'Authorization' => @subscription.authorization_header ) request.perform do |response| diff --git a/config.ru b/config.ru index 5e071f530..afd13e211 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,5 @@ # frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require File.expand_path('config/environment', __dir__) diff --git a/db/migrate/20190314181829_migrate_open_registrations_setting.rb b/db/migrate/20190314181829_migrate_open_registrations_setting.rb index e5fe95009..d2f6bf2c1 100644 --- a/db/migrate/20190314181829_migrate_open_registrations_setting.rb +++ b/db/migrate/20190314181829_migrate_open_registrations_setting.rb @@ -2,6 +2,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2] def up open_registrations = Setting.find_by(var: 'open_registrations') return if open_registrations.nil? || open_registrations.value + setting = Setting.where(var: 'registrations_mode').first_or_initialize(var: 'registrations_mode') setting.update(value: 'none') end @@ -9,6 +10,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2] def down registrations_mode = Setting.find_by(var: 'registrations_mode') return if registrations_mode.nil? + setting = Setting.where(var: 'open_registrations').first_or_initialize(var: 'open_registrations') setting.update(value: registrations_mode.value == 'open') end diff --git a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb index 19e86fbfe..1c18b85cb 100644 --- a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb +++ b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb @@ -8,6 +8,7 @@ class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2] User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user| next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists? + user.settings.advanced_layout = true end end diff --git a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb index 7f6a2c6dd..a3cc854d7 100644 --- a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb +++ b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb @@ -11,6 +11,7 @@ class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2] rescue ActiveRecord::StatementInvalid => e remove_index :tags, name: 'index_tags_on_name_lower_btree' raise CorruptionError, 'index_tags_on_name_lower_btree' if e.is_a?(ActiveRecord::RecordNotUnique) + raise e end diff --git a/db/migrate/20220613110834_add_action_to_custom_filters.rb b/db/migrate/20220613110834_add_action_to_custom_filters.rb index 9427a66fc..c1daf3c94 100644 --- a/db/migrate/20220613110834_add_action_to_custom_filters.rb +++ b/db/migrate/20220613110834_add_action_to_custom_filters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require Rails.root.join('lib', 'mastodon', 'migration_helpers') class AddActionToCustomFilters < ActiveRecord::Migration[6.1] diff --git a/db/post_migrate/20200917193528_migrate_notifications_type.rb b/db/post_migrate/20200917193528_migrate_notifications_type.rb index 88e423084..9dc9ecd48 100644 --- a/db/post_migrate/20200917193528_migrate_notifications_type.rb +++ b/db/post_migrate/20200917193528_migrate_notifications_type.rb @@ -4,12 +4,12 @@ class MigrateNotificationsType < ActiveRecord::Migration[5.2] disable_ddl_transaction! TYPES_TO_MIGRATE = { - 'Mention' => :mention, - 'Status' => :reblog, - 'Follow' => :follow, + 'Mention' => :mention, + 'Status' => :reblog, + 'Follow' => :follow, 'FollowRequest' => :follow_request, - 'Favourite' => :favourite, - 'Poll' => :poll, + 'Favourite' => :favourite, + 'Poll' => :poll, }.freeze def up diff --git a/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb b/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb index 7ef0749e5..99c3366a2 100644 --- a/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb +++ b/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require Rails.root.join('lib', 'mastodon', 'migration_helpers') class RemoveWholeWordFromCustomFilters < ActiveRecord::Migration[6.1] diff --git a/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb b/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb index 6ed8bcfee..1c366ee53 100644 --- a/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb +++ b/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require Rails.root.join('lib', 'mastodon', 'migration_helpers') class RemoveIrreversibleFromCustomFilters < ActiveRecord::Migration[6.1] diff --git a/db/post_migrate/20221101190723_backfill_admin_action_logs.rb b/db/post_migrate/20221101190723_backfill_admin_action_logs.rb index 6ab76a8f7..fa2ddbbca 100644 --- a/db/post_migrate/20221101190723_backfill_admin_action_logs.rb +++ b/db/post_migrate/20221101190723_backfill_admin_action_logs.rb @@ -79,11 +79,13 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1] safety_assured do AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log| next if log.account.nil? + log.update_attribute('human_identifier', log.account.acct) end AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log| next if log.user.nil? + log.update_attribute('human_identifier', log.user.account.acct) log.update_attribute('route_param', log.user.account_id) end @@ -92,57 +94,68 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1] AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log| next if log.domain_block.nil? + log.update_attribute('human_identifier', log.domain_block.domain) end AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log| next if log.domain_allow.nil? + log.update_attribute('human_identifier', log.domain_allow.domain) end AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log| next if log.email_domain_block.nil? + log.update_attribute('human_identifier', log.email_domain_block.domain) end AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log| next if log.unavailable_domain.nil? + log.update_attribute('human_identifier', log.unavailable_domain.domain) end AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log| next if log.status.nil? + log.update_attribute('human_identifier', log.status.account.acct) log.update_attribute('permalink', log.status.uri) end AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log| next if log.account_warning.nil? + log.update_attribute('human_identifier', log.account_warning.account.acct) end AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log| next if log.announcement.nil? + log.update_attribute('human_identifier', log.announcement.text) end AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log| next if log.ip_block.nil? + log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}") end AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log| next if log.custom_emoji.nil? + log.update_attribute('human_identifier', log.custom_emoji.shortcode) end AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log| next if log.canonical_email_block.nil? + log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash) end AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log| next if log.appeal.nil? + log.update_attribute('human_identifier', log.appeal.account.acct) log.update_attribute('route_param', log.appeal.account_warning_id) end diff --git a/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb b/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb index 42b7f3625..9c7ac7120 100644 --- a/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb +++ b/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb @@ -79,11 +79,13 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1] safety_assured do AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log| next if log.account.nil? + log.update_attribute('human_identifier', log.account.acct) end AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log| next if log.user.nil? + log.update_attribute('human_identifier', log.user.account.acct) log.update_attribute('route_param', log.user.account_id) end @@ -92,57 +94,68 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1] AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log| next if log.domain_block.nil? + log.update_attribute('human_identifier', log.domain_block.domain) end AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log| next if log.domain_allow.nil? + log.update_attribute('human_identifier', log.domain_allow.domain) end AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log| next if log.email_domain_block.nil? + log.update_attribute('human_identifier', log.email_domain_block.domain) end AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log| next if log.unavailable_domain.nil? + log.update_attribute('human_identifier', log.unavailable_domain.domain) end AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log| next if log.status.nil? + log.update_attribute('human_identifier', log.status.account.acct) log.update_attribute('permalink', log.status.uri) end AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log| next if log.account_warning.nil? + log.update_attribute('human_identifier', log.account_warning.account.acct) end AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log| next if log.announcement.nil? + log.update_attribute('human_identifier', log.announcement.text) end AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log| next if log.ip_block.nil? + log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}") end AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log| next if log.custom_emoji.nil? + log.update_attribute('human_identifier', log.custom_emoji.shortcode) end AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log| next if log.canonical_email_block.nil? + log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash) end AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log| next if log.appeal.nil? + log.update_attribute('human_identifier', log.appeal.account.acct) log.update_attribute('route_param', log.appeal.account_warning_id) end diff --git a/lib/mastodon/domains_cli.rb b/lib/mastodon/domains_cli.rb index f24a54e7e..41ea5b152 100644 --- a/lib/mastodon/domains_cli.rb +++ b/lib/mastodon/domains_cli.rb @@ -148,6 +148,7 @@ module Mastodon begin Request.new(:get, "https://#{domain}/api/v1/instance").perform do |res| next unless res.code == 200 + stats[domain] = Oj.load(res.to_s) end @@ -161,6 +162,7 @@ module Mastodon Request.new(:get, "https://#{domain}/api/v1/instance/activity").perform do |res| next unless res.code == 200 + stats[domain]['activity'] = Oj.load(res.to_s) end rescue StandardError diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index d5e62897f..dc39e9c90 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -72,7 +72,7 @@ class Sanitize elements: %w(p br span a), attributes: { - 'a' => %w(href rel class), + 'a' => %w(href rel class), 'span' => %w(class), }, @@ -98,17 +98,17 @@ class Sanitize attributes: merge( RELAXED[:attributes], - 'audio' => %w(controls), - 'embed' => %w(height src type width), + 'audio' => %w(controls), + 'embed' => %w(height src type width), 'iframe' => %w(allowfullscreen frameborder height scrolling src width), 'source' => %w(src type), - 'video' => %w(controls height loop width), - 'div' => [:data] + 'video' => %w(controls height loop width), + 'div' => [:data] ), protocols: merge( RELAXED[:protocols], - 'embed' => { 'src' => HTTP_PROTOCOLS }, + 'embed' => { 'src' => HTTP_PROTOCOLS }, 'iframe' => { 'src' => HTTP_PROTOCOLS }, 'source' => { 'src' => HTTP_PROTOCOLS } ) diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index a374e33ad..4b5997920 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -3,42 +3,42 @@ if Rails.env.development? task :set_annotation_options do Annotate.set_defaults( - 'routes' => 'false', - 'models' => 'true', - 'position_in_routes' => 'before', - 'position_in_class' => 'before', - 'position_in_test' => 'before', - 'position_in_fixture' => 'before', - 'position_in_factory' => 'before', - 'position_in_serializer' => 'before', - 'show_foreign_keys' => 'false', - 'show_indexes' => 'false', - 'simple_indexes' => 'false', - 'model_dir' => 'app/models', - 'root_dir' => '', - 'include_version' => 'false', - 'require' => '', - 'exclude_tests' => 'true', - 'exclude_fixtures' => 'true', - 'exclude_factories' => 'true', - 'exclude_serializers' => 'true', - 'exclude_scaffolds' => 'true', - 'exclude_controllers' => 'true', - 'exclude_helpers' => 'true', - 'ignore_model_sub_dir' => 'false', - 'ignore_columns' => nil, - 'ignore_routes' => nil, - 'ignore_unknown_models' => 'false', + 'routes' => 'false', + 'models' => 'true', + 'position_in_routes' => 'before', + 'position_in_class' => 'before', + 'position_in_test' => 'before', + 'position_in_fixture' => 'before', + 'position_in_factory' => 'before', + 'position_in_serializer' => 'before', + 'show_foreign_keys' => 'false', + 'show_indexes' => 'false', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'true', + 'exclude_fixtures' => 'true', + 'exclude_factories' => 'true', + 'exclude_serializers' => 'true', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', 'hide_limit_column_types' => 'integer,boolean', - 'skip_on_db_migrate' => 'false', - 'format_bare' => 'true', - 'format_rdoc' => 'false', - 'format_markdown' => 'false', - 'sort' => 'false', - 'force' => 'false', - 'trace' => 'false', - 'wrapper_open' => nil, - 'wrapper_close' => nil + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil ) end diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 179a730bc..f919ba989 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -399,14 +399,14 @@ namespace :mastodon do end ActionMailer::Base.smtp_settings = { - port: env['SMTP_PORT'], - address: env['SMTP_SERVER'], - user_name: env['SMTP_LOGIN'].presence, - password: env['SMTP_PASSWORD'].presence, - domain: env['LOCAL_DOMAIN'], - authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain, - openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'], - enable_starttls: enable_starttls, + port: env['SMTP_PORT'], + address: env['SMTP_SERVER'], + user_name: env['SMTP_LOGIN'].presence, + password: env['SMTP_PASSWORD'].presence, + domain: env['LOCAL_DOMAIN'], + authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain, + openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'], + enable_starttls: enable_starttls, enable_starttls_auto: enable_starttls_auto, } diff --git a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb index 4630fac90..e57c37179 100644 --- a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::StatusesController do diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index 4516df2c2..7248356e5 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -12,9 +12,9 @@ RSpec.describe Admin::AccountAction, type: :model do before do account_action.assign_attributes( - type: type, + type: type, current_account: account, - target_account: target_account + target_account: target_account ) end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index ed3fc056b..50ff0b149 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -149,8 +149,8 @@ describe AccountInteractions do let(:mute) do Fabricate(:mute, - account: account, - target_account: target_account, + account: account, + target_account: target_account, hide_notifications: hide_notifications) end diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 7043449c5..4d6e5c380 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rails_helper' RSpec.describe Tag do -- cgit From 0cfdd1a401f055c23e308a4b823bd250b1cbb3d3 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 21 Feb 2023 19:54:36 -0500 Subject: Enable Rubocop Style/StringConcatenation defaults (#23792) --- .rubocop_todo.yml | 19 ------------------- app/lib/activitypub/case_transform.rb | 2 +- app/lib/validation_error_formatter.rb | 2 +- app/services/backup_service.rb | 10 +++++----- app/services/fetch_link_card_service.rb | 2 +- lib/mastodon/emoji_cli.rb | 2 +- lib/mastodon/redis_config.rb | 16 ++++++++-------- lib/mastodon/snowflake.rb | 2 +- lib/paperclip/gif_transcoder.rb | 2 +- lib/paperclip/type_corrector.rb | 2 +- spec/controllers/api/v1/apps_controller_spec.rb | 4 ++-- spec/controllers/api/v1/streaming_controller_spec.rb | 2 +- spec/validators/disallowed_hashtags_validator_spec.rb | 2 +- spec/workers/web/push_notification_worker_spec.rb | 2 +- 14 files changed, 25 insertions(+), 44 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d99774e8e..a72606b35 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2263,25 +2263,6 @@ Style/SlicingWithRange: - 'lib/mastodon/premailer_webpack_strategy.rb' - 'lib/tasks/repo.rake' -# Offense count: 25 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Mode. -Style/StringConcatenation: - Exclude: - - 'app/lib/activitypub/case_transform.rb' - - 'app/lib/validation_error_formatter.rb' - - 'app/services/backup_service.rb' - - 'app/services/fetch_link_card_service.rb' - - 'lib/mastodon/emoji_cli.rb' - - 'lib/mastodon/redis_config.rb' - - 'lib/mastodon/snowflake.rb' - - 'lib/paperclip/gif_transcoder.rb' - - 'lib/paperclip/type_corrector.rb' - - 'spec/controllers/api/v1/apps_controller_spec.rb' - - 'spec/controllers/api/v1/streaming_controller_spec.rb' - - 'spec/validators/disallowed_hashtags_validator_spec.rb' - - 'spec/workers/web/push_notification_worker_spec.rb' - # Offense count: 272 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize. diff --git a/app/lib/activitypub/case_transform.rb b/app/lib/activitypub/case_transform.rb index 7f716f862..d36e01b8f 100644 --- a/app/lib/activitypub/case_transform.rb +++ b/app/lib/activitypub/case_transform.rb @@ -13,7 +13,7 @@ module ActivityPub::CaseTransform when Symbol then camel_lower(value.to_s).to_sym when String camel_lower_cache[value] ||= if value.start_with?('_:') - '_:' + value.gsub(/\A_:/, '').underscore.camelize(:lower) + "_:#{value.gsub(/\A_:/, '').underscore.camelize(:lower)}" else value.underscore.camelize(:lower) end diff --git a/app/lib/validation_error_formatter.rb b/app/lib/validation_error_formatter.rb index 3f964f739..1d3e8955b 100644 --- a/app/lib/validation_error_formatter.rb +++ b/app/lib/validation_error_formatter.rb @@ -19,7 +19,7 @@ class ValidationErrorFormatter messages = errors.messages[attribute_name] h[@aliases[attribute_name] || attribute_name] = attribute_errors.map.with_index do |error, index| - { error: 'ERR_' + error[:error].to_s.upcase, description: messages[index] } + { error: "ERR_#{error[:error].to_s.upcase}", description: messages[index] } end end diff --git a/app/services/backup_service.rb b/app/services/backup_service.rb index b880dfbe7..5498cdd45 100644 --- a/app/services/backup_service.rb +++ b/app/services/backup_service.rb @@ -53,7 +53,7 @@ class BackupService < BaseService end end - archive_filename = ['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-') + '.tar.gz' + archive_filename = "#{['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-')}.tar.gz" @backup.dump = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file, filename: archive_filename) @backup.processed = true @@ -86,14 +86,14 @@ class BackupService < BaseService def dump_actor!(tar) actor = serialize(account, ActivityPub::ActorSerializer) - actor[:icon][:url] = 'avatar' + File.extname(actor[:icon][:url]) if actor[:icon] - actor[:image][:url] = 'header' + File.extname(actor[:image][:url]) if actor[:image] + actor[:icon][:url] = "avatar#{File.extname(actor[:icon][:url])}" if actor[:icon] + actor[:image][:url] = "header#{File.extname(actor[:image][:url])}" if actor[:image] actor[:outbox] = 'outbox.json' actor[:likes] = 'likes.json' actor[:bookmarks] = 'bookmarks.json' - download_to_tar(tar, account.avatar, 'avatar' + File.extname(account.avatar.path)) if account.avatar.exists? - download_to_tar(tar, account.header, 'header' + File.extname(account.header.path)) if account.header.exists? + download_to_tar(tar, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists? + download_to_tar(tar, account.header, "header#{File.extname(account.header.path)}") if account.header.exists? json = Oj.dump(actor) diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index d5fa9af54..8d07958b7 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -45,7 +45,7 @@ class FetchLinkCardService < BaseService def html return @html if defined?(@html) - Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => Mastodon::Version.user_agent + ' Bot').perform do |res| + Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => "#{Mastodon::Version.user_agent} Bot").perform do |res| # We follow redirects, and ideally we want to save the preview card for # the destination URL and not any link shortener in-between, so here # we set the URL to the one of the last response in the redirect chain diff --git a/lib/mastodon/emoji_cli.rb b/lib/mastodon/emoji_cli.rb index feb77107f..88065c2a3 100644 --- a/lib/mastodon/emoji_cli.rb +++ b/lib/mastodon/emoji_cli.rb @@ -68,7 +68,7 @@ module Mastodon failed += 1 say('Failure/Error: ', :red) say(entry.full_name) - say(' ' + custom_emoji.errors[:image].join(', '), :red) + say(" #{custom_emoji.errors[:image].join(', ')}", :red) end end end diff --git a/lib/mastodon/redis_config.rb b/lib/mastodon/redis_config.rb index 037ca5edc..3e97da873 100644 --- a/lib/mastodon/redis_config.rb +++ b/lib/mastodon/redis_config.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true def setup_redis_env_url(prefix = nil, defaults = true) - prefix = prefix.to_s.upcase + '_' unless prefix.nil? + prefix = "#{prefix.to_s.upcase}_" unless prefix.nil? prefix = '' if prefix.nil? - return if ENV[prefix + 'REDIS_URL'].present? + return if ENV["#{prefix}REDIS_URL"].present? - password = ENV.fetch(prefix + 'REDIS_PASSWORD') { '' if defaults } - host = ENV.fetch(prefix + 'REDIS_HOST') { 'localhost' if defaults } - port = ENV.fetch(prefix + 'REDIS_PORT') { 6379 if defaults } - db = ENV.fetch(prefix + 'REDIS_DB') { 0 if defaults } + password = ENV.fetch("#{prefix}REDIS_PASSWORD") { '' if defaults } + host = ENV.fetch("#{prefix}REDIS_HOST") { 'localhost' if defaults } + port = ENV.fetch("#{prefix}REDIS_PORT") { 6379 if defaults } + db = ENV.fetch("#{prefix}REDIS_DB") { 0 if defaults } - ENV[prefix + 'REDIS_URL'] = begin + ENV["#{prefix}REDIS_URL"] = begin if [password, host, port, db].all?(&:nil?) ENV['REDIS_URL'] else @@ -27,7 +27,7 @@ setup_redis_env_url(:cache, false) setup_redis_env_url(:sidekiq, false) namespace = ENV.fetch('REDIS_NAMESPACE', nil) -cache_namespace = namespace ? namespace + '_cache' : 'cache' +cache_namespace = namespace ? "#{namespace}_cache" : 'cache' sidekiq_namespace = namespace REDIS_CACHE_PARAMS = { diff --git a/lib/mastodon/snowflake.rb b/lib/mastodon/snowflake.rb index fe0dc1722..8030288af 100644 --- a/lib/mastodon/snowflake.rb +++ b/lib/mastodon/snowflake.rb @@ -115,7 +115,7 @@ module Mastodon::Snowflake # And only those that are using timestamp_id. next unless (data = DEFAULT_REGEX.match(id_col.default_function)) - seq_name = data[:seq_prefix] + '_id_seq' + seq_name = "#{data[:seq_prefix]}_id_seq" # If we were on Postgres 9.5+, we could do CREATE SEQUENCE IF # NOT EXISTS, but we can't depend on that. Instead, catch the diff --git a/lib/paperclip/gif_transcoder.rb b/lib/paperclip/gif_transcoder.rb index f385b00a3..32bdb8a86 100644 --- a/lib/paperclip/gif_transcoder.rb +++ b/lib/paperclip/gif_transcoder.rb @@ -109,7 +109,7 @@ module Paperclip final_file = Paperclip::Transcoder.make(file, options, attachment) if options[:style] == :original - attachment.instance.file_file_name = File.basename(attachment.instance.file_file_name, '.*') + '.mp4' + attachment.instance.file_file_name = "#{File.basename(attachment.instance.file_file_name, '.*')}.mp4" attachment.instance.file_content_type = 'video/mp4' attachment.instance.type = MediaAttachment.types[:gifv] end diff --git a/lib/paperclip/type_corrector.rb b/lib/paperclip/type_corrector.rb index 17e2fc5da..030b98b12 100644 --- a/lib/paperclip/type_corrector.rb +++ b/lib/paperclip/type_corrector.rb @@ -7,7 +7,7 @@ module Paperclip def make return @file unless options[:format] - target_extension = '.' + options[:format] + target_extension = ".#{options[:format]}" extension = File.extname(attachment.instance_read(:file_name)) return @file unless options[:style] == :original && target_extension && extension != target_extension diff --git a/spec/controllers/api/v1/apps_controller_spec.rb b/spec/controllers/api/v1/apps_controller_spec.rb index 9ac7880a4..61158e881 100644 --- a/spec/controllers/api/v1/apps_controller_spec.rb +++ b/spec/controllers/api/v1/apps_controller_spec.rb @@ -68,7 +68,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do end context 'with a too-long website' do - let(:website) { 'https://foo.bar/' + ('hoge' * 2_000) } + let(:website) { "https://foo.bar/#{'hoge' * 2_000}" } it 'returns http unprocessable entity' do expect(response).to have_http_status(422) @@ -76,7 +76,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do end context 'with a too-long redirect_uris' do - let(:redirect_uris) { 'https://foo.bar/' + ('hoge' * 2_000) } + let(:redirect_uris) { "https://foo.bar/#{'hoge' * 2_000}" } it 'returns http unprocessable entity' do expect(response).to have_http_status(422) diff --git a/spec/controllers/api/v1/streaming_controller_spec.rb b/spec/controllers/api/v1/streaming_controller_spec.rb index 9dbca0178..7014ed9b2 100644 --- a/spec/controllers/api/v1/streaming_controller_spec.rb +++ b/spec/controllers/api/v1/streaming_controller_spec.rb @@ -25,7 +25,7 @@ describe Api::V1::StreamingController do context 'with streaming api on different host' do before(:each) do - Rails.configuration.x.streaming_api_base_url = 'wss://streaming-' + Rails.configuration.x.web_domain + 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/validators/disallowed_hashtags_validator_spec.rb b/spec/validators/disallowed_hashtags_validator_spec.rb index 2c4ebc4f2..896fd4fc5 100644 --- a/spec/validators/disallowed_hashtags_validator_spec.rb +++ b/spec/validators/disallowed_hashtags_validator_spec.rb @@ -11,7 +11,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do described_class.new.validate(status) end - let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| '#' + x }.join(' ')) } + let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| "##{x}" }.join(' ')) } let(:errors) { double(add: nil) } context 'for a remote reblog' do diff --git a/spec/workers/web/push_notification_worker_spec.rb b/spec/workers/web/push_notification_worker_spec.rb index 5bc24f888..822ef5257 100644 --- a/spec/workers/web/push_notification_worker_spec.rb +++ b/spec/workers/web/push_notification_worker_spec.rb @@ -37,7 +37,7 @@ describe Web::PushNotificationWorker do expect(a_request(:post, endpoint).with(headers: { 'Content-Encoding' => 'aesgcm', 'Content-Type' => 'application/octet-stream', - 'Crypto-Key' => 'dh=BAgtUks5d90kFmxGevk9tH7GEmvz9DB0qcEMUsOBgKwMf-TMjsKIIG6LQvGcFAf6jcmAod15VVwmYwGIIxE4VWE;p256ecdsa=' + vapid_public_key.delete('='), + 'Crypto-Key' => "dh=BAgtUks5d90kFmxGevk9tH7GEmvz9DB0qcEMUsOBgKwMf-TMjsKIIG6LQvGcFAf6jcmAod15VVwmYwGIIxE4VWE;p256ecdsa=#{vapid_public_key.delete('=')}", 'Encryption' => 'salt=WJeVM-RY-F9351SVxTFx_g', 'Ttl' => '172800', 'Urgency' => 'normal', -- cgit From 84cc805caea566d4fb0fafce411cd07f83cfd0e2 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Tue, 21 Feb 2023 19:55:31 -0500 Subject: Enable Style/FrozenStringLiteralComment for specs (#23790) --- spec/config/initializers/rack_attack_spec.rb | 2 ++ spec/controllers/about_controller_spec.rb | 2 ++ spec/controllers/accounts_controller_spec.rb | 2 ++ .../activitypub/followers_synchronizations_controller_spec.rb | 2 ++ spec/controllers/activitypub/outboxes_controller_spec.rb | 2 ++ spec/controllers/admin/account_moderation_notes_controller_spec.rb | 2 ++ spec/controllers/admin/accounts_controller_spec.rb | 2 ++ spec/controllers/admin/change_email_controller_spec.rb | 2 ++ spec/controllers/admin/confirmations_controller_spec.rb | 2 ++ spec/controllers/admin/custom_emojis_controller_spec.rb | 2 ++ spec/controllers/admin/disputes/appeals_controller_spec.rb | 2 ++ spec/controllers/admin/domain_allows_controller_spec.rb | 2 ++ spec/controllers/admin/domain_blocks_controller_spec.rb | 2 ++ spec/controllers/admin/export_domain_allows_controller_spec.rb | 2 ++ spec/controllers/admin/export_domain_blocks_controller_spec.rb | 2 ++ spec/controllers/admin/instances_controller_spec.rb | 2 ++ spec/controllers/admin/report_notes_controller_spec.rb | 2 ++ spec/controllers/admin/reports/actions_controller_spec.rb | 2 ++ spec/controllers/admin/reports_controller_spec.rb | 2 ++ spec/controllers/admin/resets_controller_spec.rb | 2 ++ spec/controllers/admin/roles_controller_spec.rb | 2 ++ spec/controllers/admin/statuses_controller_spec.rb | 2 ++ spec/controllers/admin/users/roles_controller.rb | 2 ++ .../admin/users/two_factor_authentications_controller_spec.rb | 2 ++ spec/controllers/api/oembed_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/credentials_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/lists_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/notes_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/relationships_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts/search_controller_spec.rb | 2 ++ spec/controllers/api/v1/accounts_controller_spec.rb | 2 ++ spec/controllers/api/v1/admin/account_actions_controller_spec.rb | 2 ++ spec/controllers/api/v1/admin/accounts_controller_spec.rb | 2 ++ spec/controllers/api/v1/admin/domain_allows_controller_spec.rb | 2 ++ spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb | 2 ++ spec/controllers/api/v1/admin/reports_controller_spec.rb | 2 ++ spec/controllers/api/v1/apps/credentials_controller_spec.rb | 2 ++ spec/controllers/api/v1/apps_controller_spec.rb | 2 ++ spec/controllers/api/v1/blocks_controller_spec.rb | 2 ++ spec/controllers/api/v1/bookmarks_controller_spec.rb | 2 ++ spec/controllers/api/v1/conversations_controller_spec.rb | 2 ++ spec/controllers/api/v1/domain_blocks_controller_spec.rb | 2 ++ spec/controllers/api/v1/emails/confirmations_controller_spec.rb | 2 ++ spec/controllers/api/v1/favourites_controller_spec.rb | 2 ++ spec/controllers/api/v1/filters_controller_spec.rb | 2 ++ spec/controllers/api/v1/follow_requests_controller_spec.rb | 2 ++ spec/controllers/api/v1/followed_tags_controller_spec.rb | 2 ++ spec/controllers/api/v1/lists/accounts_controller_spec.rb | 2 ++ spec/controllers/api/v1/lists_controller_spec.rb | 2 ++ spec/controllers/api/v1/markers_controller_spec.rb | 2 ++ spec/controllers/api/v1/media_controller_spec.rb | 2 ++ spec/controllers/api/v1/mutes_controller_spec.rb | 2 ++ spec/controllers/api/v1/notifications_controller_spec.rb | 2 ++ spec/controllers/api/v1/polls/votes_controller_spec.rb | 2 ++ spec/controllers/api/v1/polls_controller_spec.rb | 2 ++ .../api/v1/statuses/favourited_by_accounts_controller_spec.rb | 2 ++ .../api/v1/statuses/reblogged_by_accounts_controller_spec.rb | 2 ++ spec/controllers/api/v1/statuses_controller_spec.rb | 2 ++ spec/controllers/api/v1/suggestions_controller_spec.rb | 2 ++ spec/controllers/api/v1/tags_controller_spec.rb | 2 ++ spec/controllers/api/v2/admin/accounts_controller_spec.rb | 2 ++ spec/controllers/api/v2/filters/keywords_controller_spec.rb | 2 ++ spec/controllers/api/v2/filters/statuses_controller_spec.rb | 2 ++ spec/controllers/api/v2/filters_controller_spec.rb | 2 ++ spec/controllers/auth/registrations_controller_spec.rb | 2 ++ spec/controllers/disputes/appeals_controller_spec.rb | 2 ++ spec/controllers/disputes/strikes_controller_spec.rb | 2 ++ spec/controllers/emojis_controller_spec.rb | 2 ++ spec/controllers/follower_accounts_controller_spec.rb | 2 ++ spec/controllers/following_accounts_controller_spec.rb | 2 ++ spec/controllers/home_controller_spec.rb | 2 ++ spec/controllers/instance_actors_controller_spec.rb | 2 ++ spec/controllers/intents_controller_spec.rb | 2 ++ spec/controllers/invites_controller_spec.rb | 2 ++ spec/controllers/manifests_controller_spec.rb | 2 ++ spec/controllers/relationships_controller_spec.rb | 2 ++ spec/controllers/settings/applications_controller_spec.rb | 2 ++ spec/controllers/settings/deletes_controller_spec.rb | 2 ++ spec/controllers/settings/exports/blocked_accounts_controller_spec.rb | 2 ++ spec/controllers/settings/exports/bookmarks_controller_spec.rb | 2 ++ spec/controllers/settings/exports/following_accounts_controller_spec.rb | 2 ++ spec/controllers/settings/exports/muted_accounts_controller_spec.rb | 2 ++ spec/controllers/settings/featured_tags_controller_spec.rb | 2 ++ spec/controllers/settings/imports_controller_spec.rb | 2 ++ spec/controllers/settings/migrations_controller_spec.rb | 2 ++ spec/controllers/settings/preferences/notifications_controller_spec.rb | 2 ++ spec/controllers/settings/preferences/other_controller_spec.rb | 2 ++ spec/controllers/settings/profiles_controller_spec.rb | 2 ++ spec/controllers/settings/sessions_controller_spec.rb | 2 ++ spec/controllers/shares_controller_spec.rb | 2 ++ spec/controllers/statuses_cleanup_controller_spec.rb | 2 ++ spec/controllers/tags_controller_spec.rb | 2 ++ spec/controllers/well_known/host_meta_controller_spec.rb | 2 ++ spec/controllers/well_known/nodeinfo_controller_spec.rb | 2 ++ spec/controllers/well_known/webfinger_controller_spec.rb | 2 ++ spec/fabricators/access_grant_fabricator.rb | 2 ++ spec/fabricators/access_token_fabricator.rb | 2 ++ spec/fabricators/accessible_access_token_fabricator.rb | 2 ++ spec/fabricators/account_alias_fabricator.rb | 2 ++ spec/fabricators/account_deletion_request_fabricator.rb | 2 ++ spec/fabricators/account_domain_block_fabricator.rb | 2 ++ spec/fabricators/account_fabricator.rb | 2 ++ spec/fabricators/account_migration_fabricator.rb | 2 ++ spec/fabricators/account_moderation_note_fabricator.rb | 2 ++ spec/fabricators/account_note_fabricator.rb | 2 ++ spec/fabricators/account_pin_fabricator.rb | 2 ++ spec/fabricators/account_stat_fabricator.rb | 2 ++ spec/fabricators/account_statuses_cleanup_policy_fabricator.rb | 2 ++ spec/fabricators/account_tag_stat_fabricator.rb | 2 ++ spec/fabricators/account_warning_fabricator.rb | 2 ++ spec/fabricators/account_warning_preset_fabricator.rb | 2 ++ spec/fabricators/admin_action_log_fabricator.rb | 2 ++ spec/fabricators/announcement_fabricator.rb | 2 ++ spec/fabricators/announcement_mute_fabricator.rb | 2 ++ spec/fabricators/announcement_reaction_fabricator.rb | 2 ++ spec/fabricators/appeal_fabricator.rb | 2 ++ spec/fabricators/application_fabricator.rb | 2 ++ spec/fabricators/backup_fabricator.rb | 2 ++ spec/fabricators/block_fabricator.rb | 2 ++ spec/fabricators/bookmark_fabricator.rb | 2 ++ spec/fabricators/canonical_email_block_fabricator.rb | 2 ++ spec/fabricators/conversation_account_fabricator.rb | 2 ++ spec/fabricators/conversation_fabricator.rb | 2 ++ spec/fabricators/conversation_mute_fabricator.rb | 2 ++ spec/fabricators/custom_emoji_category_fabricator.rb | 2 ++ spec/fabricators/custom_emoji_fabricator.rb | 2 ++ spec/fabricators/custom_filter_fabricator.rb | 2 ++ spec/fabricators/custom_filter_keyword_fabricator.rb | 2 ++ spec/fabricators/custom_filter_status_fabricator.rb | 2 ++ spec/fabricators/device_fabricator.rb | 2 ++ spec/fabricators/domain_allow_fabricator.rb | 2 ++ spec/fabricators/domain_block_fabricator.rb | 2 ++ spec/fabricators/email_domain_block_fabricator.rb | 2 ++ spec/fabricators/encrypted_message_fabricator.rb | 2 ++ spec/fabricators/favourite_fabricator.rb | 2 ++ spec/fabricators/featured_tag_fabricator.rb | 2 ++ spec/fabricators/follow_fabricator.rb | 2 ++ spec/fabricators/follow_recommendation_suppression_fabricator.rb | 2 ++ spec/fabricators/follow_request_fabricator.rb | 2 ++ spec/fabricators/identity_fabricator.rb | 2 ++ spec/fabricators/import_fabricator.rb | 2 ++ spec/fabricators/invite_fabricator.rb | 2 ++ spec/fabricators/ip_block_fabricator.rb | 2 ++ spec/fabricators/list_account_fabricator.rb | 2 ++ spec/fabricators/list_fabricator.rb | 2 ++ spec/fabricators/login_activity_fabricator.rb | 2 ++ spec/fabricators/marker_fabricator.rb | 2 ++ spec/fabricators/media_attachment_fabricator.rb | 2 ++ spec/fabricators/mention_fabricator.rb | 2 ++ spec/fabricators/mute_fabricator.rb | 2 ++ spec/fabricators/notification_fabricator.rb | 2 ++ spec/fabricators/one_time_key_fabricator.rb | 2 ++ spec/fabricators/poll_fabricator.rb | 2 ++ spec/fabricators/poll_vote_fabricator.rb | 2 ++ spec/fabricators/preview_card_fabricator.rb | 2 ++ spec/fabricators/relay_fabricator.rb | 2 ++ spec/fabricators/report_fabricator.rb | 2 ++ spec/fabricators/report_note_fabricator.rb | 2 ++ spec/fabricators/rule_fabricator.rb | 2 ++ spec/fabricators/scheduled_status_fabricator.rb | 2 ++ spec/fabricators/session_activation_fabricator.rb | 2 ++ spec/fabricators/site_upload_fabricator.rb | 2 ++ spec/fabricators/status_edit_fabricator.rb | 2 ++ spec/fabricators/status_fabricator.rb | 2 ++ spec/fabricators/status_pin_fabricator.rb | 2 ++ spec/fabricators/status_stat_fabricator.rb | 2 ++ spec/fabricators/system_key_fabricator.rb | 2 ++ spec/fabricators/tag_fabricator.rb | 2 ++ spec/fabricators/tag_follow_fabricator.rb | 2 ++ spec/fabricators/unavailable_domain_fabricator.rb | 2 ++ spec/fabricators/user_fabricator.rb | 2 ++ spec/fabricators/user_invite_request_fabricator.rb | 2 ++ spec/fabricators/user_role_fabricator.rb | 2 ++ spec/fabricators/web_push_subscription_fabricator.rb | 2 ++ spec/fabricators/web_setting_fabricator.rb | 2 ++ spec/fabricators/webauthn_credential_fabricator.rb | 2 ++ spec/fabricators/webhook_fabricator.rb | 2 ++ spec/helpers/accounts_helper_spec.rb | 2 ++ spec/helpers/admin/filter_helper_spec.rb | 2 ++ spec/helpers/application_helper_spec.rb | 2 ++ spec/helpers/home_helper_spec.rb | 2 ++ spec/helpers/statuses_helper_spec.rb | 2 ++ spec/lib/activitypub/activity/accept_spec.rb | 2 ++ spec/lib/activitypub/activity/add_spec.rb | 2 ++ spec/lib/activitypub/activity/announce_spec.rb | 2 ++ spec/lib/activitypub/activity/block_spec.rb | 2 ++ spec/lib/activitypub/activity/create_spec.rb | 2 ++ spec/lib/activitypub/activity/delete_spec.rb | 2 ++ spec/lib/activitypub/activity/flag_spec.rb | 2 ++ spec/lib/activitypub/activity/follow_spec.rb | 2 ++ spec/lib/activitypub/activity/like_spec.rb | 2 ++ spec/lib/activitypub/activity/move_spec.rb | 2 ++ spec/lib/activitypub/activity/reject_spec.rb | 2 ++ spec/lib/activitypub/activity/remove_spec.rb | 2 ++ spec/lib/activitypub/activity/undo_spec.rb | 2 ++ spec/lib/activitypub/activity/update_spec.rb | 2 ++ spec/lib/activitypub/adapter_spec.rb | 2 ++ spec/lib/activitypub/dereferencer_spec.rb | 2 ++ spec/lib/activitypub/linked_data_signature_spec.rb | 2 ++ spec/lib/activitypub/tag_manager_spec.rb | 2 ++ spec/lib/emoji_formatter_spec.rb | 2 ++ spec/lib/entity_cache_spec.rb | 2 ++ spec/lib/feed_manager_spec.rb | 2 ++ spec/lib/html_aware_formatter_spec.rb | 2 ++ spec/lib/link_details_extractor_spec.rb | 2 ++ spec/lib/plain_text_formatter_spec.rb | 2 ++ spec/lib/suspicious_sign_in_detector_spec.rb | 2 ++ spec/lib/tag_manager_spec.rb | 2 ++ spec/lib/text_formatter_spec.rb | 2 ++ spec/lib/vacuum/access_tokens_vacuum_spec.rb | 2 ++ spec/lib/vacuum/backups_vacuum_spec.rb | 2 ++ spec/lib/vacuum/feeds_vacuum_spec.rb | 2 ++ spec/lib/vacuum/media_attachments_vacuum_spec.rb | 2 ++ spec/lib/vacuum/preview_cards_vacuum_spec.rb | 2 ++ spec/lib/vacuum/statuses_vacuum_spec.rb | 2 ++ spec/lib/vacuum/system_keys_vacuum_spec.rb | 2 ++ spec/lib/webfinger_resource_spec.rb | 2 ++ spec/mailers/notification_mailer_spec.rb | 2 ++ spec/mailers/previews/admin_mailer_preview.rb | 2 ++ spec/mailers/previews/notification_mailer_preview.rb | 2 ++ spec/mailers/previews/user_mailer_preview.rb | 2 ++ spec/models/account/field_spec.rb | 2 ++ spec/models/account_alias_spec.rb | 2 ++ spec/models/account_conversation_spec.rb | 2 ++ spec/models/account_deletion_request_spec.rb | 2 ++ spec/models/account_domain_block_spec.rb | 2 ++ spec/models/account_filter_spec.rb | 2 ++ spec/models/account_migration_spec.rb | 2 ++ spec/models/account_moderation_note_spec.rb | 2 ++ spec/models/account_spec.rb | 2 ++ spec/models/account_statuses_cleanup_policy_spec.rb | 2 ++ spec/models/admin/account_action_spec.rb | 2 ++ spec/models/announcement_mute_spec.rb | 2 ++ spec/models/announcement_reaction_spec.rb | 2 ++ spec/models/announcement_spec.rb | 2 ++ spec/models/appeal_spec.rb | 2 ++ spec/models/backup_spec.rb | 2 ++ spec/models/block_spec.rb | 2 ++ spec/models/canonical_email_block_spec.rb | 2 ++ spec/models/concerns/account_counters_spec.rb | 2 ++ spec/models/concerns/account_interactions_spec.rb | 2 ++ spec/models/conversation_mute_spec.rb | 2 ++ spec/models/conversation_spec.rb | 2 ++ spec/models/custom_emoji_category_spec.rb | 2 ++ spec/models/custom_emoji_spec.rb | 2 ++ spec/models/custom_filter_keyword_spec.rb | 2 ++ spec/models/custom_filter_spec.rb | 2 ++ spec/models/device_spec.rb | 2 ++ spec/models/domain_allow_spec.rb | 2 ++ spec/models/domain_block_spec.rb | 2 ++ spec/models/email_domain_block_spec.rb | 2 ++ spec/models/encrypted_message_spec.rb | 2 ++ spec/models/export_spec.rb | 2 ++ spec/models/favourite_spec.rb | 2 ++ spec/models/featured_tag_spec.rb | 2 ++ spec/models/follow_recommendation_suppression_spec.rb | 2 ++ spec/models/follow_request_spec.rb | 2 ++ spec/models/follow_spec.rb | 2 ++ spec/models/home_feed_spec.rb | 2 ++ spec/models/identity_spec.rb | 2 ++ spec/models/import_spec.rb | 2 ++ spec/models/invite_spec.rb | 2 ++ spec/models/ip_block_spec.rb | 2 ++ spec/models/list_account_spec.rb | 2 ++ spec/models/list_spec.rb | 2 ++ spec/models/login_activity_spec.rb | 2 ++ spec/models/marker_spec.rb | 2 ++ spec/models/media_attachment_spec.rb | 2 ++ spec/models/mention_spec.rb | 2 ++ spec/models/mute_spec.rb | 2 ++ spec/models/notification_spec.rb | 2 ++ spec/models/one_time_key_spec.rb | 2 ++ spec/models/poll_spec.rb | 2 ++ spec/models/preview_card_spec.rb | 2 ++ spec/models/preview_card_trend_spec.rb | 2 ++ spec/models/public_feed_spec.rb | 2 ++ spec/models/relay_spec.rb | 2 ++ spec/models/report_filter_spec.rb | 2 ++ spec/models/report_spec.rb | 2 ++ spec/models/rule_spec.rb | 2 ++ spec/models/scheduled_status_spec.rb | 2 ++ spec/models/status_edit_spec.rb | 2 ++ spec/models/status_pin_spec.rb | 2 ++ spec/models/status_spec.rb | 2 ++ spec/models/status_stat_spec.rb | 2 ++ spec/models/status_trend_spec.rb | 2 ++ spec/models/system_key_spec.rb | 2 ++ spec/models/tag_feed_spec.rb | 2 ++ spec/models/tag_follow_spec.rb | 2 ++ spec/models/trends/statuses_spec.rb | 2 ++ spec/models/trends/tags_spec.rb | 2 ++ spec/models/unavailable_domain_spec.rb | 2 ++ spec/models/user_invite_request_spec.rb | 2 ++ spec/models/user_role_spec.rb | 2 ++ spec/models/user_spec.rb | 2 ++ spec/models/web/push_subscription_spec.rb | 2 ++ spec/models/web/setting_spec.rb | 2 ++ spec/models/webauthn_credentials_spec.rb | 2 ++ spec/models/webhook_spec.rb | 2 ++ spec/presenters/instance_presenter_spec.rb | 2 ++ spec/rails_helper.rb | 2 ++ spec/requests/catch_all_route_request_spec.rb | 2 ++ spec/requests/host_meta_request_spec.rb | 2 ++ spec/requests/webfinger_request_spec.rb | 2 ++ spec/routing/accounts_routing_spec.rb | 2 ++ spec/routing/well_known_routes_spec.rb | 2 ++ spec/services/account_search_service_spec.rb | 2 ++ spec/services/account_statuses_cleanup_service_spec.rb | 2 ++ spec/services/activitypub/fetch_featured_collection_service_spec.rb | 2 ++ .../services/activitypub/fetch_featured_tags_collection_service_spec.rb | 2 ++ spec/services/activitypub/fetch_remote_account_service_spec.rb | 2 ++ spec/services/activitypub/fetch_remote_actor_service_spec.rb | 2 ++ spec/services/activitypub/fetch_remote_key_service_spec.rb | 2 ++ spec/services/activitypub/fetch_remote_status_service_spec.rb | 2 ++ spec/services/activitypub/fetch_replies_service_spec.rb | 2 ++ spec/services/activitypub/process_account_service_spec.rb | 2 ++ spec/services/activitypub/process_collection_service_spec.rb | 2 ++ spec/services/activitypub/process_status_update_service_spec.rb | 2 ++ spec/services/activitypub/synchronize_followers_service_spec.rb | 2 ++ spec/services/after_block_domain_from_account_service_spec.rb | 2 ++ spec/services/after_block_service_spec.rb | 2 ++ spec/services/app_sign_up_service_spec.rb | 2 ++ spec/services/authorize_follow_service_spec.rb | 2 ++ spec/services/batched_remove_status_service_spec.rb | 2 ++ spec/services/block_domain_service_spec.rb | 2 ++ spec/services/block_service_spec.rb | 2 ++ spec/services/bootstrap_timeline_service_spec.rb | 2 ++ spec/services/clear_domain_media_service_spec.rb | 2 ++ spec/services/delete_account_service_spec.rb | 2 ++ spec/services/fan_out_on_write_service_spec.rb | 2 ++ spec/services/favourite_service_spec.rb | 2 ++ spec/services/fetch_link_card_service_spec.rb | 2 ++ spec/services/fetch_remote_status_service_spec.rb | 2 ++ spec/services/fetch_resource_service_spec.rb | 2 ++ spec/services/follow_service_spec.rb | 2 ++ spec/services/import_service_spec.rb | 2 ++ spec/services/mute_service_spec.rb | 2 ++ spec/services/notify_service_spec.rb | 2 ++ spec/services/post_status_service_spec.rb | 2 ++ spec/services/process_mentions_service_spec.rb | 2 ++ spec/services/purge_domain_service_spec.rb | 2 ++ spec/services/reblog_service_spec.rb | 2 ++ spec/services/reject_follow_service_spec.rb | 2 ++ spec/services/remove_from_follwers_service_spec.rb | 2 ++ spec/services/remove_status_service_spec.rb | 2 ++ spec/services/report_service_spec.rb | 2 ++ spec/services/resolve_account_service_spec.rb | 2 ++ spec/services/suspend_account_service_spec.rb | 2 ++ spec/services/unallow_domain_service_spec.rb | 2 ++ spec/services/unblock_service_spec.rb | 2 ++ spec/services/unfollow_service_spec.rb | 2 ++ spec/services/unmute_service_spec.rb | 2 ++ spec/services/unsuspend_account_service_spec.rb | 2 ++ spec/services/update_account_service_spec.rb | 2 ++ spec/services/update_status_service_spec.rb | 2 ++ spec/services/verify_link_service_spec.rb | 2 ++ spec/spec_helper.rb | 2 ++ spec/support/matchers/json/match_json_schema.rb | 2 ++ spec/support/matchers/model/model_have_error_on_field.rb | 2 ++ spec/workers/activitypub/distribute_poll_update_worker_spec.rb | 2 ++ spec/workers/activitypub/distribution_worker_spec.rb | 2 ++ spec/workers/activitypub/move_distribution_worker_spec.rb | 2 ++ spec/workers/activitypub/processing_worker_spec.rb | 2 ++ spec/workers/activitypub/status_update_distribution_worker_spec.rb | 2 ++ spec/workers/activitypub/update_distribution_worker_spec.rb | 2 ++ spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb | 2 ++ spec/workers/scheduler/user_cleanup_scheduler_spec.rb | 2 ++ 369 files changed, 738 insertions(+) (limited to 'spec/controllers/api/v1') diff --git a/spec/config/initializers/rack_attack_spec.rb b/spec/config/initializers/rack_attack_spec.rb index 50d4505b7..2cfe90b1a 100644 --- a/spec/config/initializers/rack_attack_spec.rb +++ b/spec/config/initializers/rack_attack_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Rack::Attack do diff --git a/spec/controllers/about_controller_spec.rb b/spec/controllers/about_controller_spec.rb index 97143ec43..ccd28a96c 100644 --- a/spec/controllers/about_controller_spec.rb +++ b/spec/controllers/about_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AboutController, type: :controller do diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index db588156c..9c38b3032 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountsController, type: :controller do diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb index 6ec756d3c..8357f5f39 100644 --- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb +++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controller do diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index 7369ee413..167bbcc21 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::OutboxesController, type: :controller do diff --git a/spec/controllers/admin/account_moderation_notes_controller_spec.rb b/spec/controllers/admin/account_moderation_notes_controller_spec.rb index b8d606322..d2c52f594 100644 --- a/spec/controllers/admin/account_moderation_notes_controller_spec.rb +++ b/spec/controllers/admin/account_moderation_notes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::AccountModerationNotesController, type: :controller do diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index fdc98ed46..b182715b0 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::AccountsController, type: :controller do diff --git a/spec/controllers/admin/change_email_controller_spec.rb b/spec/controllers/admin/change_email_controller_spec.rb index 520842a19..832998471 100644 --- a/spec/controllers/admin/change_email_controller_spec.rb +++ b/spec/controllers/admin/change_email_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::ChangeEmailsController, type: :controller do diff --git a/spec/controllers/admin/confirmations_controller_spec.rb b/spec/controllers/admin/confirmations_controller_spec.rb index 7ca90f3e1..d05711e27 100644 --- a/spec/controllers/admin/confirmations_controller_spec.rb +++ b/spec/controllers/admin/confirmations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::ConfirmationsController, type: :controller do diff --git a/spec/controllers/admin/custom_emojis_controller_spec.rb b/spec/controllers/admin/custom_emojis_controller_spec.rb index 06cd0c22d..d40691e1b 100644 --- a/spec/controllers/admin/custom_emojis_controller_spec.rb +++ b/spec/controllers/admin/custom_emojis_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::CustomEmojisController do diff --git a/spec/controllers/admin/disputes/appeals_controller_spec.rb b/spec/controllers/admin/disputes/appeals_controller_spec.rb index 712657791..576a0c12b 100644 --- a/spec/controllers/admin/disputes/appeals_controller_spec.rb +++ b/spec/controllers/admin/disputes/appeals_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::Disputes::AppealsController, type: :controller do diff --git a/spec/controllers/admin/domain_allows_controller_spec.rb b/spec/controllers/admin/domain_allows_controller_spec.rb index 6c4e67787..2a0f47145 100644 --- a/spec/controllers/admin/domain_allows_controller_spec.rb +++ b/spec/controllers/admin/domain_allows_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::DomainAllowsController, type: :controller do diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index d58a0cafc..ef13f7676 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::DomainBlocksController, type: :controller do diff --git a/spec/controllers/admin/export_domain_allows_controller_spec.rb b/spec/controllers/admin/export_domain_allows_controller_spec.rb index 1f974bc00..f12bd1344 100644 --- a/spec/controllers/admin/export_domain_allows_controller_spec.rb +++ b/spec/controllers/admin/export_domain_allows_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::ExportDomainAllowsController, type: :controller do diff --git a/spec/controllers/admin/export_domain_blocks_controller_spec.rb b/spec/controllers/admin/export_domain_blocks_controller_spec.rb index a8d7b7383..4da9f90e4 100644 --- a/spec/controllers/admin/export_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/export_domain_blocks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::ExportDomainBlocksController, type: :controller do diff --git a/spec/controllers/admin/instances_controller_spec.rb b/spec/controllers/admin/instances_controller_spec.rb index 4716e486a..33174b992 100644 --- a/spec/controllers/admin/instances_controller_spec.rb +++ b/spec/controllers/admin/instances_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::InstancesController, type: :controller do diff --git a/spec/controllers/admin/report_notes_controller_spec.rb b/spec/controllers/admin/report_notes_controller_spec.rb index 8a2603611..fb2fbd058 100644 --- a/spec/controllers/admin/report_notes_controller_spec.rb +++ b/spec/controllers/admin/report_notes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::ReportNotesController do diff --git a/spec/controllers/admin/reports/actions_controller_spec.rb b/spec/controllers/admin/reports/actions_controller_spec.rb index 20f85680f..3e42e4cb1 100644 --- a/spec/controllers/admin/reports/actions_controller_spec.rb +++ b/spec/controllers/admin/reports/actions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::Reports::ActionsController do diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index c6b5770a8..97daaf8da 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::ReportsController do diff --git a/spec/controllers/admin/resets_controller_spec.rb b/spec/controllers/admin/resets_controller_spec.rb index 64fe027fd..16adb8a12 100644 --- a/spec/controllers/admin/resets_controller_spec.rb +++ b/spec/controllers/admin/resets_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::ResetsController do diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb index e2b1030d9..223d0a472 100644 --- a/spec/controllers/admin/roles_controller_spec.rb +++ b/spec/controllers/admin/roles_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::RolesController do diff --git a/spec/controllers/admin/statuses_controller_spec.rb b/spec/controllers/admin/statuses_controller_spec.rb index 7f912c1c0..79d83db97 100644 --- a/spec/controllers/admin/statuses_controller_spec.rb +++ b/spec/controllers/admin/statuses_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::StatusesController do diff --git a/spec/controllers/admin/users/roles_controller.rb b/spec/controllers/admin/users/roles_controller.rb index 9fa8aef41..fe2cee01b 100644 --- a/spec/controllers/admin/users/roles_controller.rb +++ b/spec/controllers/admin/users/roles_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::Users::RolesController do diff --git a/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb b/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb index 990dcf640..eb10d4796 100644 --- a/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb +++ b/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'webauthn/fake_client' diff --git a/spec/controllers/api/oembed_controller_spec.rb b/spec/controllers/api/oembed_controller_spec.rb index b9082bde1..930f36250 100644 --- a/spec/controllers/api/oembed_controller_spec.rb +++ b/spec/controllers/api/oembed_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::OEmbedController, type: :controller do diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index 3494ca674..57fe0aee6 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::CredentialsController do diff --git a/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb b/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb index 1e6e1d8e0..53298a2e4 100644 --- a/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::FollowerAccountsController do diff --git a/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb b/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb index cc962c6ee..7390b25b5 100644 --- a/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::FollowingAccountsController do diff --git a/spec/controllers/api/v1/accounts/lists_controller_spec.rb b/spec/controllers/api/v1/accounts/lists_controller_spec.rb index d71485633..418839cfa 100644 --- a/spec/controllers/api/v1/accounts/lists_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/lists_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::ListsController do diff --git a/spec/controllers/api/v1/accounts/notes_controller_spec.rb b/spec/controllers/api/v1/accounts/notes_controller_spec.rb index 42c2d8a86..fd4d34f69 100644 --- a/spec/controllers/api/v1/accounts/notes_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/notes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::NotesController do diff --git a/spec/controllers/api/v1/accounts/relationships_controller_spec.rb b/spec/controllers/api/v1/accounts/relationships_controller_spec.rb index 69ad0d061..da8d7fe3f 100644 --- a/spec/controllers/api/v1/accounts/relationships_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/relationships_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Accounts::RelationshipsController do diff --git a/spec/controllers/api/v1/accounts/search_controller_spec.rb b/spec/controllers/api/v1/accounts/search_controller_spec.rb index 5b23bff68..d2b675a3c 100644 --- a/spec/controllers/api/v1/accounts/search_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/search_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Accounts::SearchController, type: :controller do diff --git a/spec/controllers/api/v1/accounts_controller_spec.rb b/spec/controllers/api/v1/accounts_controller_spec.rb index d6bbcefd7..5fbb65021 100644 --- a/spec/controllers/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::AccountsController, type: :controller do diff --git a/spec/controllers/api/v1/admin/account_actions_controller_spec.rb b/spec/controllers/api/v1/admin/account_actions_controller_spec.rb index 462c2cfa9..cafbee212 100644 --- a/spec/controllers/api/v1/admin/account_actions_controller_spec.rb +++ b/spec/controllers/api/v1/admin/account_actions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Admin::AccountActionsController, type: :controller do diff --git a/spec/controllers/api/v1/admin/accounts_controller_spec.rb b/spec/controllers/api/v1/admin/accounts_controller_spec.rb index a4c509c60..9ffcdb34f 100644 --- a/spec/controllers/api/v1/admin/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/admin/accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Admin::AccountsController, type: :controller do diff --git a/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb b/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb index 8100363f6..15567907e 100644 --- a/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb +++ b/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Admin::DomainAllowsController, type: :controller do diff --git a/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb b/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb index b367ab9ce..0460c701a 100644 --- a/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do diff --git a/spec/controllers/api/v1/admin/reports_controller_spec.rb b/spec/controllers/api/v1/admin/reports_controller_spec.rb index 880e72030..3d61fe5c3 100644 --- a/spec/controllers/api/v1/admin/reports_controller_spec.rb +++ b/spec/controllers/api/v1/admin/reports_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Admin::ReportsController, type: :controller do diff --git a/spec/controllers/api/v1/apps/credentials_controller_spec.rb b/spec/controllers/api/v1/apps/credentials_controller_spec.rb index 701ba8acb..350e0c7a0 100644 --- a/spec/controllers/api/v1/apps/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/apps/credentials_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Apps::CredentialsController do diff --git a/spec/controllers/api/v1/apps_controller_spec.rb b/spec/controllers/api/v1/apps_controller_spec.rb index 61158e881..bde132c52 100644 --- a/spec/controllers/api/v1/apps_controller_spec.rb +++ b/spec/controllers/api/v1/apps_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::AppsController, type: :controller do diff --git a/spec/controllers/api/v1/blocks_controller_spec.rb b/spec/controllers/api/v1/blocks_controller_spec.rb index cf996c47c..a746389ca 100644 --- a/spec/controllers/api/v1/blocks_controller_spec.rb +++ b/spec/controllers/api/v1/blocks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::BlocksController, type: :controller do diff --git a/spec/controllers/api/v1/bookmarks_controller_spec.rb b/spec/controllers/api/v1/bookmarks_controller_spec.rb index 48332b15a..352d2ca02 100644 --- a/spec/controllers/api/v1/bookmarks_controller_spec.rb +++ b/spec/controllers/api/v1/bookmarks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::BookmarksController, type: :controller do diff --git a/spec/controllers/api/v1/conversations_controller_spec.rb b/spec/controllers/api/v1/conversations_controller_spec.rb index 5add7cf1d..36c4cb56f 100644 --- a/spec/controllers/api/v1/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/conversations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::ConversationsController, type: :controller do diff --git a/spec/controllers/api/v1/domain_blocks_controller_spec.rb b/spec/controllers/api/v1/domain_blocks_controller_spec.rb index d9dc1bdbf..467ddbccc 100644 --- a/spec/controllers/api/v1/domain_blocks_controller_spec.rb +++ b/spec/controllers/api/v1/domain_blocks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::DomainBlocksController, type: :controller do diff --git a/spec/controllers/api/v1/emails/confirmations_controller_spec.rb b/spec/controllers/api/v1/emails/confirmations_controller_spec.rb index d272ff38d..fc9843fef 100644 --- a/spec/controllers/api/v1/emails/confirmations_controller_spec.rb +++ b/spec/controllers/api/v1/emails/confirmations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do diff --git a/spec/controllers/api/v1/favourites_controller_spec.rb b/spec/controllers/api/v1/favourites_controller_spec.rb index f0fb8f37b..6ae0fdc49 100644 --- a/spec/controllers/api/v1/favourites_controller_spec.rb +++ b/spec/controllers/api/v1/favourites_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::FavouritesController, type: :controller do diff --git a/spec/controllers/api/v1/filters_controller_spec.rb b/spec/controllers/api/v1/filters_controller_spec.rb index 8acb46a00..d583365cc 100644 --- a/spec/controllers/api/v1/filters_controller_spec.rb +++ b/spec/controllers/api/v1/filters_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::FiltersController, type: :controller do diff --git a/spec/controllers/api/v1/follow_requests_controller_spec.rb b/spec/controllers/api/v1/follow_requests_controller_spec.rb index 856ba2a1c..0220e0277 100644 --- a/spec/controllers/api/v1/follow_requests_controller_spec.rb +++ b/spec/controllers/api/v1/follow_requests_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::FollowRequestsController, type: :controller do diff --git a/spec/controllers/api/v1/followed_tags_controller_spec.rb b/spec/controllers/api/v1/followed_tags_controller_spec.rb index 2191350ef..e990065a9 100644 --- a/spec/controllers/api/v1/followed_tags_controller_spec.rb +++ b/spec/controllers/api/v1/followed_tags_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::FollowedTagsController, type: :controller do diff --git a/spec/controllers/api/v1/lists/accounts_controller_spec.rb b/spec/controllers/api/v1/lists/accounts_controller_spec.rb index 526d8b561..337a5645c 100644 --- a/spec/controllers/api/v1/lists/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/lists/accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Api::V1::Lists::AccountsController do diff --git a/spec/controllers/api/v1/lists_controller_spec.rb b/spec/controllers/api/v1/lists_controller_spec.rb index 71a8094e6..f54d27e42 100644 --- a/spec/controllers/api/v1/lists_controller_spec.rb +++ b/spec/controllers/api/v1/lists_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::ListsController, type: :controller do diff --git a/spec/controllers/api/v1/markers_controller_spec.rb b/spec/controllers/api/v1/markers_controller_spec.rb index 64ec18e59..fb5f59a7c 100644 --- a/spec/controllers/api/v1/markers_controller_spec.rb +++ b/spec/controllers/api/v1/markers_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::MarkersController, type: :controller do diff --git a/spec/controllers/api/v1/media_controller_spec.rb b/spec/controllers/api/v1/media_controller_spec.rb index ef1e439f9..90379dd92 100644 --- a/spec/controllers/api/v1/media_controller_spec.rb +++ b/spec/controllers/api/v1/media_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::MediaController, type: :controller do diff --git a/spec/controllers/api/v1/mutes_controller_spec.rb b/spec/controllers/api/v1/mutes_controller_spec.rb index 8288cb815..122d9d1c5 100644 --- a/spec/controllers/api/v1/mutes_controller_spec.rb +++ b/spec/controllers/api/v1/mutes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::MutesController, type: :controller do diff --git a/spec/controllers/api/v1/notifications_controller_spec.rb b/spec/controllers/api/v1/notifications_controller_spec.rb index 22ebfa3dd..f6cbd105e 100644 --- a/spec/controllers/api/v1/notifications_controller_spec.rb +++ b/spec/controllers/api/v1/notifications_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::NotificationsController, type: :controller do diff --git a/spec/controllers/api/v1/polls/votes_controller_spec.rb b/spec/controllers/api/v1/polls/votes_controller_spec.rb index d7a9c1970..9d9b14e81 100644 --- a/spec/controllers/api/v1/polls/votes_controller_spec.rb +++ b/spec/controllers/api/v1/polls/votes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Polls::VotesController, type: :controller do diff --git a/spec/controllers/api/v1/polls_controller_spec.rb b/spec/controllers/api/v1/polls_controller_spec.rb index f0d9eaf92..0602e44ee 100644 --- a/spec/controllers/api/v1/polls_controller_spec.rb +++ b/spec/controllers/api/v1/polls_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::PollsController, type: :controller do diff --git a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb index c1c6f5f12..c7e1b73c7 100644 --- a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :controller do diff --git a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb index 90187a585..1aab502ef 100644 --- a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controller do diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index e839c8494..f011bfd47 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::StatusesController, type: :controller do diff --git a/spec/controllers/api/v1/suggestions_controller_spec.rb b/spec/controllers/api/v1/suggestions_controller_spec.rb index 35ba155e7..c99380c58 100644 --- a/spec/controllers/api/v1/suggestions_controller_spec.rb +++ b/spec/controllers/api/v1/suggestions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::SuggestionsController, type: :controller do diff --git a/spec/controllers/api/v1/tags_controller_spec.rb b/spec/controllers/api/v1/tags_controller_spec.rb index 216faad87..ed17a4fbf 100644 --- a/spec/controllers/api/v1/tags_controller_spec.rb +++ b/spec/controllers/api/v1/tags_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V1::TagsController, type: :controller do diff --git a/spec/controllers/api/v2/admin/accounts_controller_spec.rb b/spec/controllers/api/v2/admin/accounts_controller_spec.rb index 1477049a1..5766fd549 100644 --- a/spec/controllers/api/v2/admin/accounts_controller_spec.rb +++ b/spec/controllers/api/v2/admin/accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V2::Admin::AccountsController, type: :controller do diff --git a/spec/controllers/api/v2/filters/keywords_controller_spec.rb b/spec/controllers/api/v2/filters/keywords_controller_spec.rb index 0e0f52ea8..8c61059c6 100644 --- a/spec/controllers/api/v2/filters/keywords_controller_spec.rb +++ b/spec/controllers/api/v2/filters/keywords_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V2::Filters::KeywordsController, type: :controller do diff --git a/spec/controllers/api/v2/filters/statuses_controller_spec.rb b/spec/controllers/api/v2/filters/statuses_controller_spec.rb index 969b2ea73..330cf45a6 100644 --- a/spec/controllers/api/v2/filters/statuses_controller_spec.rb +++ b/spec/controllers/api/v2/filters/statuses_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V2::Filters::StatusesController, type: :controller do diff --git a/spec/controllers/api/v2/filters_controller_spec.rb b/spec/controllers/api/v2/filters_controller_spec.rb index cc0070d57..2b5610a4d 100644 --- a/spec/controllers/api/v2/filters_controller_spec.rb +++ b/spec/controllers/api/v2/filters_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Api::V2::FiltersController, type: :controller do diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index f42f685c1..e3a00fa39 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Auth::RegistrationsController, type: :controller do diff --git a/spec/controllers/disputes/appeals_controller_spec.rb b/spec/controllers/disputes/appeals_controller_spec.rb index 90f222f49..affe63c59 100644 --- a/spec/controllers/disputes/appeals_controller_spec.rb +++ b/spec/controllers/disputes/appeals_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Disputes::AppealsController, type: :controller do diff --git a/spec/controllers/disputes/strikes_controller_spec.rb b/spec/controllers/disputes/strikes_controller_spec.rb index e060d37ac..1d678875c 100644 --- a/spec/controllers/disputes/strikes_controller_spec.rb +++ b/spec/controllers/disputes/strikes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Disputes::StrikesController, type: :controller do diff --git a/spec/controllers/emojis_controller_spec.rb b/spec/controllers/emojis_controller_spec.rb index 9f6604964..710d23d92 100644 --- a/spec/controllers/emojis_controller_spec.rb +++ b/spec/controllers/emojis_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe EmojisController do diff --git a/spec/controllers/follower_accounts_controller_spec.rb b/spec/controllers/follower_accounts_controller_spec.rb index 43fc4203c..7c53e5b47 100644 --- a/spec/controllers/follower_accounts_controller_spec.rb +++ b/spec/controllers/follower_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe FollowerAccountsController do diff --git a/spec/controllers/following_accounts_controller_spec.rb b/spec/controllers/following_accounts_controller_spec.rb index b41bf0575..122f72e2d 100644 --- a/spec/controllers/following_accounts_controller_spec.rb +++ b/spec/controllers/following_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe FollowingAccountsController do diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 2409bf42c..0d3722920 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe HomeController, type: :controller do diff --git a/spec/controllers/instance_actors_controller_spec.rb b/spec/controllers/instance_actors_controller_spec.rb index d6b4c793b..84a07d497 100644 --- a/spec/controllers/instance_actors_controller_spec.rb +++ b/spec/controllers/instance_actors_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe InstanceActorsController, type: :controller do diff --git a/spec/controllers/intents_controller_spec.rb b/spec/controllers/intents_controller_spec.rb index 394f7d512..02b46ddc7 100644 --- a/spec/controllers/intents_controller_spec.rb +++ b/spec/controllers/intents_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe IntentsController, type: :controller do diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index 23b98fb12..408c5e1b5 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe InvitesController do diff --git a/spec/controllers/manifests_controller_spec.rb b/spec/controllers/manifests_controller_spec.rb index a549adef3..ecd6957fc 100644 --- a/spec/controllers/manifests_controller_spec.rb +++ b/spec/controllers/manifests_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ManifestsController do diff --git a/spec/controllers/relationships_controller_spec.rb b/spec/controllers/relationships_controller_spec.rb index 4c4227d66..39f455e03 100644 --- a/spec/controllers/relationships_controller_spec.rb +++ b/spec/controllers/relationships_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe RelationshipsController do diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index a653b87c7..5c6b04a15 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::ApplicationsController do diff --git a/spec/controllers/settings/deletes_controller_spec.rb b/spec/controllers/settings/deletes_controller_spec.rb index a94dc042a..a7edac6a9 100644 --- a/spec/controllers/settings/deletes_controller_spec.rb +++ b/spec/controllers/settings/deletes_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::DeletesController do diff --git a/spec/controllers/settings/exports/blocked_accounts_controller_spec.rb b/spec/controllers/settings/exports/blocked_accounts_controller_spec.rb index 5ff41b7fc..459b278d6 100644 --- a/spec/controllers/settings/exports/blocked_accounts_controller_spec.rb +++ b/spec/controllers/settings/exports/blocked_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::Exports::BlockedAccountsController do diff --git a/spec/controllers/settings/exports/bookmarks_controller_spec.rb b/spec/controllers/settings/exports/bookmarks_controller_spec.rb index a06c02e0c..9982eff16 100644 --- a/spec/controllers/settings/exports/bookmarks_controller_spec.rb +++ b/spec/controllers/settings/exports/bookmarks_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::Exports::BookmarksController do diff --git a/spec/controllers/settings/exports/following_accounts_controller_spec.rb b/spec/controllers/settings/exports/following_accounts_controller_spec.rb index bfe010555..72b0b94e1 100644 --- a/spec/controllers/settings/exports/following_accounts_controller_spec.rb +++ b/spec/controllers/settings/exports/following_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::Exports::FollowingAccountsController do diff --git a/spec/controllers/settings/exports/muted_accounts_controller_spec.rb b/spec/controllers/settings/exports/muted_accounts_controller_spec.rb index 642f0a9b8..b4170cb16 100644 --- a/spec/controllers/settings/exports/muted_accounts_controller_spec.rb +++ b/spec/controllers/settings/exports/muted_accounts_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::Exports::MutedAccountsController do diff --git a/spec/controllers/settings/featured_tags_controller_spec.rb b/spec/controllers/settings/featured_tags_controller_spec.rb index fc338672d..5c61351af 100644 --- a/spec/controllers/settings/featured_tags_controller_spec.rb +++ b/spec/controllers/settings/featured_tags_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::FeaturedTagsController do diff --git a/spec/controllers/settings/imports_controller_spec.rb b/spec/controllers/settings/imports_controller_spec.rb index e50504cc5..78973df2b 100644 --- a/spec/controllers/settings/imports_controller_spec.rb +++ b/spec/controllers/settings/imports_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Settings::ImportsController, type: :controller do diff --git a/spec/controllers/settings/migrations_controller_spec.rb b/spec/controllers/settings/migrations_controller_spec.rb index 8159bb21b..9b12bc40f 100644 --- a/spec/controllers/settings/migrations_controller_spec.rb +++ b/spec/controllers/settings/migrations_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::MigrationsController do diff --git a/spec/controllers/settings/preferences/notifications_controller_spec.rb b/spec/controllers/settings/preferences/notifications_controller_spec.rb index a821052ed..66fb8c5eb 100644 --- a/spec/controllers/settings/preferences/notifications_controller_spec.rb +++ b/spec/controllers/settings/preferences/notifications_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::Preferences::NotificationsController do diff --git a/spec/controllers/settings/preferences/other_controller_spec.rb b/spec/controllers/settings/preferences/other_controller_spec.rb index ffb37e0bd..63eeefaf0 100644 --- a/spec/controllers/settings/preferences/other_controller_spec.rb +++ b/spec/controllers/settings/preferences/other_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::Preferences::OtherController do diff --git a/spec/controllers/settings/profiles_controller_spec.rb b/spec/controllers/settings/profiles_controller_spec.rb index c7a6ad664..e45596b1a 100644 --- a/spec/controllers/settings/profiles_controller_spec.rb +++ b/spec/controllers/settings/profiles_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Settings::ProfilesController, type: :controller do diff --git a/spec/controllers/settings/sessions_controller_spec.rb b/spec/controllers/settings/sessions_controller_spec.rb index fdf46d947..a4248e1bd 100644 --- a/spec/controllers/settings/sessions_controller_spec.rb +++ b/spec/controllers/settings/sessions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Settings::SessionsController do diff --git a/spec/controllers/shares_controller_spec.rb b/spec/controllers/shares_controller_spec.rb index 0fde8c692..6d5bb4f8d 100644 --- a/spec/controllers/shares_controller_spec.rb +++ b/spec/controllers/shares_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe SharesController do diff --git a/spec/controllers/statuses_cleanup_controller_spec.rb b/spec/controllers/statuses_cleanup_controller_spec.rb index 24b4ea7b6..969778bbf 100644 --- a/spec/controllers/statuses_cleanup_controller_spec.rb +++ b/spec/controllers/statuses_cleanup_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe StatusesCleanupController, type: :controller do diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 547bcfb39..8a3fa0bf8 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe TagsController, type: :controller do diff --git a/spec/controllers/well_known/host_meta_controller_spec.rb b/spec/controllers/well_known/host_meta_controller_spec.rb index 654bad406..d53704370 100644 --- a/spec/controllers/well_known/host_meta_controller_spec.rb +++ b/spec/controllers/well_known/host_meta_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe WellKnown::HostMetaController, type: :controller do diff --git a/spec/controllers/well_known/nodeinfo_controller_spec.rb b/spec/controllers/well_known/nodeinfo_controller_spec.rb index 0cadc5435..f5cde150d 100644 --- a/spec/controllers/well_known/nodeinfo_controller_spec.rb +++ b/spec/controllers/well_known/nodeinfo_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe WellKnown::NodeInfoController, type: :controller do diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb index 1ccfb218e..00103df70 100644 --- a/spec/controllers/well_known/webfinger_controller_spec.rb +++ b/spec/controllers/well_known/webfinger_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe WellKnown::WebfingerController, type: :controller do diff --git a/spec/fabricators/access_grant_fabricator.rb b/spec/fabricators/access_grant_fabricator.rb index ae1945f2b..adc2b8369 100644 --- a/spec/fabricators/access_grant_fabricator.rb +++ b/spec/fabricators/access_grant_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator :access_grant, from: 'Doorkeeper::AccessGrant' do application resource_owner_id { Fabricate(:user).id } diff --git a/spec/fabricators/access_token_fabricator.rb b/spec/fabricators/access_token_fabricator.rb index 1856a8eb3..508c32808 100644 --- a/spec/fabricators/access_token_fabricator.rb +++ b/spec/fabricators/access_token_fabricator.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Fabricator :access_token, from: 'Doorkeeper::AccessToken' do end diff --git a/spec/fabricators/accessible_access_token_fabricator.rb b/spec/fabricators/accessible_access_token_fabricator.rb index 4b7e99b20..fb3d0889b 100644 --- a/spec/fabricators/accessible_access_token_fabricator.rb +++ b/spec/fabricators/accessible_access_token_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator :accessible_access_token, from: :access_token do expires_in { nil } revoked_at { nil } diff --git a/spec/fabricators/account_alias_fabricator.rb b/spec/fabricators/account_alias_fabricator.rb index 94dde9bb8..4f434c078 100644 --- a/spec/fabricators/account_alias_fabricator.rb +++ b/spec/fabricators/account_alias_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_alias) do account acct 'test@example.com' diff --git a/spec/fabricators/account_deletion_request_fabricator.rb b/spec/fabricators/account_deletion_request_fabricator.rb index 08a82ba3c..3d3d37398 100644 --- a/spec/fabricators/account_deletion_request_fabricator.rb +++ b/spec/fabricators/account_deletion_request_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_deletion_request) do account end diff --git a/spec/fabricators/account_domain_block_fabricator.rb b/spec/fabricators/account_domain_block_fabricator.rb index 2ad4b67a9..ff85e17f3 100644 --- a/spec/fabricators/account_domain_block_fabricator.rb +++ b/spec/fabricators/account_domain_block_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_domain_block) do account domain 'example.com' diff --git a/spec/fabricators/account_fabricator.rb b/spec/fabricators/account_fabricator.rb index 205706532..6ffbba584 100644 --- a/spec/fabricators/account_fabricator.rb +++ b/spec/fabricators/account_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + keypair = OpenSSL::PKey::RSA.new(2048) public_key = keypair.public_key.to_pem private_key = keypair.to_pem diff --git a/spec/fabricators/account_migration_fabricator.rb b/spec/fabricators/account_migration_fabricator.rb index 2a8e747a8..fd453f6d2 100644 --- a/spec/fabricators/account_migration_fabricator.rb +++ b/spec/fabricators/account_migration_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_migration) do account target_account { |attrs| Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(attrs[:account])]) } diff --git a/spec/fabricators/account_moderation_note_fabricator.rb b/spec/fabricators/account_moderation_note_fabricator.rb index 343a41fb1..403870db6 100644 --- a/spec/fabricators/account_moderation_note_fabricator.rb +++ b/spec/fabricators/account_moderation_note_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_moderation_note) do content 'MyText' account nil diff --git a/spec/fabricators/account_note_fabricator.rb b/spec/fabricators/account_note_fabricator.rb index 285703b38..bb4ed8b24 100644 --- a/spec/fabricators/account_note_fabricator.rb +++ b/spec/fabricators/account_note_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_note) do account target_account { Fabricate(:account) } diff --git a/spec/fabricators/account_pin_fabricator.rb b/spec/fabricators/account_pin_fabricator.rb index c0f8b8afb..7d8a77bb5 100644 --- a/spec/fabricators/account_pin_fabricator.rb +++ b/spec/fabricators/account_pin_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_pin) do account nil target_account nil diff --git a/spec/fabricators/account_stat_fabricator.rb b/spec/fabricators/account_stat_fabricator.rb index b1b47ffef..45b1524ef 100644 --- a/spec/fabricators/account_stat_fabricator.rb +++ b/spec/fabricators/account_stat_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_stat) do account nil statuses_count '' diff --git a/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb b/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb index 29cf1d133..0e756ddba 100644 --- a/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb +++ b/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_statuses_cleanup_policy) do account end diff --git a/spec/fabricators/account_tag_stat_fabricator.rb b/spec/fabricators/account_tag_stat_fabricator.rb index 7a4de07f6..769015bd0 100644 --- a/spec/fabricators/account_tag_stat_fabricator.rb +++ b/spec/fabricators/account_tag_stat_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_tag_stat) do accounts_count '' end diff --git a/spec/fabricators/account_warning_fabricator.rb b/spec/fabricators/account_warning_fabricator.rb index 72fe835d9..e5059e37f 100644 --- a/spec/fabricators/account_warning_fabricator.rb +++ b/spec/fabricators/account_warning_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_warning) do account target_account(fabricator: :account) diff --git a/spec/fabricators/account_warning_preset_fabricator.rb b/spec/fabricators/account_warning_preset_fabricator.rb index 7e7c03cb8..7588e7f9c 100644 --- a/spec/fabricators/account_warning_preset_fabricator.rb +++ b/spec/fabricators/account_warning_preset_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:account_warning_preset) do text 'MyText' end diff --git a/spec/fabricators/admin_action_log_fabricator.rb b/spec/fabricators/admin_action_log_fabricator.rb index 474bef1bc..eb738c01c 100644 --- a/spec/fabricators/admin_action_log_fabricator.rb +++ b/spec/fabricators/admin_action_log_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator('Admin::ActionLog') do account nil action 'MyString' diff --git a/spec/fabricators/announcement_fabricator.rb b/spec/fabricators/announcement_fabricator.rb index 5a3871d90..5d7736587 100644 --- a/spec/fabricators/announcement_fabricator.rb +++ b/spec/fabricators/announcement_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:announcement) do text { Faker::Lorem.paragraph(sentence_count: 2) } published true diff --git a/spec/fabricators/announcement_mute_fabricator.rb b/spec/fabricators/announcement_mute_fabricator.rb index c4eafe8f4..109fec041 100644 --- a/spec/fabricators/announcement_mute_fabricator.rb +++ b/spec/fabricators/announcement_mute_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:announcement_mute) do account announcement diff --git a/spec/fabricators/announcement_reaction_fabricator.rb b/spec/fabricators/announcement_reaction_fabricator.rb index f923c59c6..5da51caaa 100644 --- a/spec/fabricators/announcement_reaction_fabricator.rb +++ b/spec/fabricators/announcement_reaction_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:announcement_reaction) do account announcement diff --git a/spec/fabricators/appeal_fabricator.rb b/spec/fabricators/appeal_fabricator.rb index 339363822..039086c4e 100644 --- a/spec/fabricators/appeal_fabricator.rb +++ b/spec/fabricators/appeal_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:appeal) do strike(fabricator: :account_warning) account { |attrs| attrs[:strike].target_account } diff --git a/spec/fabricators/application_fabricator.rb b/spec/fabricators/application_fabricator.rb index 42b7009dc..272821304 100644 --- a/spec/fabricators/application_fabricator.rb +++ b/spec/fabricators/application_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:application, from: Doorkeeper::Application) do name 'Example' website 'http://example.com' diff --git a/spec/fabricators/backup_fabricator.rb b/spec/fabricators/backup_fabricator.rb index 99a5bdcda..c73ae54be 100644 --- a/spec/fabricators/backup_fabricator.rb +++ b/spec/fabricators/backup_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:backup) do user end diff --git a/spec/fabricators/block_fabricator.rb b/spec/fabricators/block_fabricator.rb index 379931ba6..c2e9e9628 100644 --- a/spec/fabricators/block_fabricator.rb +++ b/spec/fabricators/block_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:block) do account target_account { Fabricate(:account) } diff --git a/spec/fabricators/bookmark_fabricator.rb b/spec/fabricators/bookmark_fabricator.rb index 12cbc5bfa..e21046fc2 100644 --- a/spec/fabricators/bookmark_fabricator.rb +++ b/spec/fabricators/bookmark_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:bookmark) do account status diff --git a/spec/fabricators/canonical_email_block_fabricator.rb b/spec/fabricators/canonical_email_block_fabricator.rb index 61afde3de..21d7c2402 100644 --- a/spec/fabricators/canonical_email_block_fabricator.rb +++ b/spec/fabricators/canonical_email_block_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:canonical_email_block) do email 'test@example.com' reference_account { Fabricate(:account) } diff --git a/spec/fabricators/conversation_account_fabricator.rb b/spec/fabricators/conversation_account_fabricator.rb index 0fe7a494e..f69d36855 100644 --- a/spec/fabricators/conversation_account_fabricator.rb +++ b/spec/fabricators/conversation_account_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:conversation_account) do account nil conversation nil diff --git a/spec/fabricators/conversation_fabricator.rb b/spec/fabricators/conversation_fabricator.rb index b4fadb46b..07c6780bf 100644 --- a/spec/fabricators/conversation_fabricator.rb +++ b/spec/fabricators/conversation_fabricator.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Fabricator(:conversation) do end diff --git a/spec/fabricators/conversation_mute_fabricator.rb b/spec/fabricators/conversation_mute_fabricator.rb index 84f131c26..5cf4dd3d5 100644 --- a/spec/fabricators/conversation_mute_fabricator.rb +++ b/spec/fabricators/conversation_mute_fabricator.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Fabricator(:conversation_mute) do end diff --git a/spec/fabricators/custom_emoji_category_fabricator.rb b/spec/fabricators/custom_emoji_category_fabricator.rb index 119c343cf..6019baba2 100644 --- a/spec/fabricators/custom_emoji_category_fabricator.rb +++ b/spec/fabricators/custom_emoji_category_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:custom_emoji_category) do name 'MyString' end diff --git a/spec/fabricators/custom_emoji_fabricator.rb b/spec/fabricators/custom_emoji_fabricator.rb index 18a7d23dc..298a50b4b 100644 --- a/spec/fabricators/custom_emoji_fabricator.rb +++ b/spec/fabricators/custom_emoji_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:custom_emoji) do shortcode 'coolcat' domain nil diff --git a/spec/fabricators/custom_filter_fabricator.rb b/spec/fabricators/custom_filter_fabricator.rb index 64297a7e3..5fee4f01a 100644 --- a/spec/fabricators/custom_filter_fabricator.rb +++ b/spec/fabricators/custom_filter_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:custom_filter) do account expires_at nil diff --git a/spec/fabricators/custom_filter_keyword_fabricator.rb b/spec/fabricators/custom_filter_keyword_fabricator.rb index 201566cbe..f1fb440dc 100644 --- a/spec/fabricators/custom_filter_keyword_fabricator.rb +++ b/spec/fabricators/custom_filter_keyword_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:custom_filter_keyword) do custom_filter keyword 'discourse' diff --git a/spec/fabricators/custom_filter_status_fabricator.rb b/spec/fabricators/custom_filter_status_fabricator.rb index d082b81c5..3ef1d0ec8 100644 --- a/spec/fabricators/custom_filter_status_fabricator.rb +++ b/spec/fabricators/custom_filter_status_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:custom_filter_status) do custom_filter status diff --git a/spec/fabricators/device_fabricator.rb b/spec/fabricators/device_fabricator.rb index b15d8248f..26c71b4fd 100644 --- a/spec/fabricators/device_fabricator.rb +++ b/spec/fabricators/device_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:device) do access_token account diff --git a/spec/fabricators/domain_allow_fabricator.rb b/spec/fabricators/domain_allow_fabricator.rb index 6f62ce3b8..b32af129b 100644 --- a/spec/fabricators/domain_allow_fabricator.rb +++ b/spec/fabricators/domain_allow_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:domain_allow) do domain 'MyString' end diff --git a/spec/fabricators/domain_block_fabricator.rb b/spec/fabricators/domain_block_fabricator.rb index cc1f928e5..c703a18e9 100644 --- a/spec/fabricators/domain_block_fabricator.rb +++ b/spec/fabricators/domain_block_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:domain_block) do domain { sequence(:domain) { |i| "#{i}#{Faker::Internet.domain_name}" } } end diff --git a/spec/fabricators/email_domain_block_fabricator.rb b/spec/fabricators/email_domain_block_fabricator.rb index d18af6433..a74cca73d 100644 --- a/spec/fabricators/email_domain_block_fabricator.rb +++ b/spec/fabricators/email_domain_block_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:email_domain_block) do domain { sequence(:domain) { |i| "#{i}#{Faker::Internet.domain_name}" } } end diff --git a/spec/fabricators/encrypted_message_fabricator.rb b/spec/fabricators/encrypted_message_fabricator.rb index 4de0d7add..289882754 100644 --- a/spec/fabricators/encrypted_message_fabricator.rb +++ b/spec/fabricators/encrypted_message_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:encrypted_message) do device from_account diff --git a/spec/fabricators/favourite_fabricator.rb b/spec/fabricators/favourite_fabricator.rb index 464ac8d71..005947e6f 100644 --- a/spec/fabricators/favourite_fabricator.rb +++ b/spec/fabricators/favourite_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:favourite) do account status diff --git a/spec/fabricators/featured_tag_fabricator.rb b/spec/fabricators/featured_tag_fabricator.rb index 25cbdaac0..4bfa3e924 100644 --- a/spec/fabricators/featured_tag_fabricator.rb +++ b/spec/fabricators/featured_tag_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:featured_tag) do account tag diff --git a/spec/fabricators/follow_fabricator.rb b/spec/fabricators/follow_fabricator.rb index 9b25dc547..41b5305d5 100644 --- a/spec/fabricators/follow_fabricator.rb +++ b/spec/fabricators/follow_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:follow) do account target_account { Fabricate(:account) } diff --git a/spec/fabricators/follow_recommendation_suppression_fabricator.rb b/spec/fabricators/follow_recommendation_suppression_fabricator.rb index 4a6a07a66..6477baee1 100644 --- a/spec/fabricators/follow_recommendation_suppression_fabricator.rb +++ b/spec/fabricators/follow_recommendation_suppression_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:follow_recommendation_suppression) do account end diff --git a/spec/fabricators/follow_request_fabricator.rb b/spec/fabricators/follow_request_fabricator.rb index c00ddf84d..86b82611f 100644 --- a/spec/fabricators/follow_request_fabricator.rb +++ b/spec/fabricators/follow_request_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:follow_request) do account target_account { Fabricate(:account, locked: true) } diff --git a/spec/fabricators/identity_fabricator.rb b/spec/fabricators/identity_fabricator.rb index fcfb15518..b83010111 100644 --- a/spec/fabricators/identity_fabricator.rb +++ b/spec/fabricators/identity_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:identity) do user nil provider 'MyString' diff --git a/spec/fabricators/import_fabricator.rb b/spec/fabricators/import_fabricator.rb index e2eb1e0df..11602f407 100644 --- a/spec/fabricators/import_fabricator.rb +++ b/spec/fabricators/import_fabricator.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Fabricator(:import) do end diff --git a/spec/fabricators/invite_fabricator.rb b/spec/fabricators/invite_fabricator.rb index 62b9b3904..4f47d6ce2 100644 --- a/spec/fabricators/invite_fabricator.rb +++ b/spec/fabricators/invite_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:invite) do user expires_at nil diff --git a/spec/fabricators/ip_block_fabricator.rb b/spec/fabricators/ip_block_fabricator.rb index 5bd018f9c..a5da3f706 100644 --- a/spec/fabricators/ip_block_fabricator.rb +++ b/spec/fabricators/ip_block_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:ip_block) do ip '' severity '' diff --git a/spec/fabricators/list_account_fabricator.rb b/spec/fabricators/list_account_fabricator.rb index 30e4004aa..b0af29e6f 100644 --- a/spec/fabricators/list_account_fabricator.rb +++ b/spec/fabricators/list_account_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:list_account) do list nil account nil diff --git a/spec/fabricators/list_fabricator.rb b/spec/fabricators/list_fabricator.rb index 4ad29a386..47af752b8 100644 --- a/spec/fabricators/list_fabricator.rb +++ b/spec/fabricators/list_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:list) do account title 'MyString' diff --git a/spec/fabricators/login_activity_fabricator.rb b/spec/fabricators/login_activity_fabricator.rb index 686fd6483..2b30658ff 100644 --- a/spec/fabricators/login_activity_fabricator.rb +++ b/spec/fabricators/login_activity_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:login_activity) do user authentication_method 'password' diff --git a/spec/fabricators/marker_fabricator.rb b/spec/fabricators/marker_fabricator.rb index 0c94150e0..561c2553a 100644 --- a/spec/fabricators/marker_fabricator.rb +++ b/spec/fabricators/marker_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:marker) do user timeline 'home' diff --git a/spec/fabricators/media_attachment_fabricator.rb b/spec/fabricators/media_attachment_fabricator.rb index 651927c2d..4a081dccb 100644 --- a/spec/fabricators/media_attachment_fabricator.rb +++ b/spec/fabricators/media_attachment_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:media_attachment) do account diff --git a/spec/fabricators/mention_fabricator.rb b/spec/fabricators/mention_fabricator.rb index cb5fe4299..5a8392827 100644 --- a/spec/fabricators/mention_fabricator.rb +++ b/spec/fabricators/mention_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:mention) do account status diff --git a/spec/fabricators/mute_fabricator.rb b/spec/fabricators/mute_fabricator.rb index 30d20e87e..242ae2b08 100644 --- a/spec/fabricators/mute_fabricator.rb +++ b/spec/fabricators/mute_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:mute) do account target_account { Fabricate(:account) } diff --git a/spec/fabricators/notification_fabricator.rb b/spec/fabricators/notification_fabricator.rb index 638844e0f..959fda913 100644 --- a/spec/fabricators/notification_fabricator.rb +++ b/spec/fabricators/notification_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:notification) do activity fabricator: [:mention, :status, :follow, :follow_request, :favourite].sample account diff --git a/spec/fabricators/one_time_key_fabricator.rb b/spec/fabricators/one_time_key_fabricator.rb index 8794baeb5..e317c28bd 100644 --- a/spec/fabricators/one_time_key_fabricator.rb +++ b/spec/fabricators/one_time_key_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:one_time_key) do device key_id { Faker::Alphanumeric.alphanumeric(number: 10) } diff --git a/spec/fabricators/poll_fabricator.rb b/spec/fabricators/poll_fabricator.rb index 746610f7c..19c3b1d16 100644 --- a/spec/fabricators/poll_fabricator.rb +++ b/spec/fabricators/poll_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:poll) do account status diff --git a/spec/fabricators/poll_vote_fabricator.rb b/spec/fabricators/poll_vote_fabricator.rb index c06e61f67..9099ae96f 100644 --- a/spec/fabricators/poll_vote_fabricator.rb +++ b/spec/fabricators/poll_vote_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:poll_vote) do account poll diff --git a/spec/fabricators/preview_card_fabricator.rb b/spec/fabricators/preview_card_fabricator.rb index 99b5edc43..b8f2c5097 100644 --- a/spec/fabricators/preview_card_fabricator.rb +++ b/spec/fabricators/preview_card_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:preview_card) do url { Faker::Internet.url } title { Faker::Lorem.sentence } diff --git a/spec/fabricators/relay_fabricator.rb b/spec/fabricators/relay_fabricator.rb index d6255866c..ad8ba86fc 100644 --- a/spec/fabricators/relay_fabricator.rb +++ b/spec/fabricators/relay_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:relay) do inbox_url 'https://example.com/inbox' state :idle diff --git a/spec/fabricators/report_fabricator.rb b/spec/fabricators/report_fabricator.rb index 3011c49c6..7124773ad 100644 --- a/spec/fabricators/report_fabricator.rb +++ b/spec/fabricators/report_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:report) do account target_account { Fabricate(:account) } diff --git a/spec/fabricators/report_note_fabricator.rb b/spec/fabricators/report_note_fabricator.rb index 33f384074..f257fe2b7 100644 --- a/spec/fabricators/report_note_fabricator.rb +++ b/spec/fabricators/report_note_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:report_note) do report account { Fabricate(:account) } diff --git a/spec/fabricators/rule_fabricator.rb b/spec/fabricators/rule_fabricator.rb index bc29bc48e..a29fd905a 100644 --- a/spec/fabricators/rule_fabricator.rb +++ b/spec/fabricators/rule_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:rule) do priority 0 deleted_at nil diff --git a/spec/fabricators/scheduled_status_fabricator.rb b/spec/fabricators/scheduled_status_fabricator.rb index 52384d137..e517f258a 100644 --- a/spec/fabricators/scheduled_status_fabricator.rb +++ b/spec/fabricators/scheduled_status_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:scheduled_status) do account scheduled_at { 20.hours.from_now } diff --git a/spec/fabricators/session_activation_fabricator.rb b/spec/fabricators/session_activation_fabricator.rb index a7fc3b017..b28d5e41d 100644 --- a/spec/fabricators/session_activation_fabricator.rb +++ b/spec/fabricators/session_activation_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:session_activation) do user session_id 'MyString' diff --git a/spec/fabricators/site_upload_fabricator.rb b/spec/fabricators/site_upload_fabricator.rb index 2efc57e28..b6841dea3 100644 --- a/spec/fabricators/site_upload_fabricator.rb +++ b/spec/fabricators/site_upload_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:site_upload) do file { File.open(File.join(Rails.root, 'spec', 'fabricators', 'assets', 'utah_teapot.png')) } end diff --git a/spec/fabricators/status_edit_fabricator.rb b/spec/fabricators/status_edit_fabricator.rb index 0e5796b23..33735a459 100644 --- a/spec/fabricators/status_edit_fabricator.rb +++ b/spec/fabricators/status_edit_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:status_edit) do status nil account nil diff --git a/spec/fabricators/status_fabricator.rb b/spec/fabricators/status_fabricator.rb index 8a0a8aa55..17ac9ccd8 100644 --- a/spec/fabricators/status_fabricator.rb +++ b/spec/fabricators/status_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:status) do account text 'Lorem ipsum dolor sit amet' diff --git a/spec/fabricators/status_pin_fabricator.rb b/spec/fabricators/status_pin_fabricator.rb index f1f1c05f3..9ad0ac9de 100644 --- a/spec/fabricators/status_pin_fabricator.rb +++ b/spec/fabricators/status_pin_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:status_pin) do account status { |attrs| Fabricate(:status, account: attrs[:account], visibility: :public) } diff --git a/spec/fabricators/status_stat_fabricator.rb b/spec/fabricators/status_stat_fabricator.rb index feba9fbca..8a358c51a 100644 --- a/spec/fabricators/status_stat_fabricator.rb +++ b/spec/fabricators/status_stat_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:status_stat) do status_id nil replies_count '' diff --git a/spec/fabricators/system_key_fabricator.rb b/spec/fabricators/system_key_fabricator.rb index c744bb286..ef6cec9c4 100644 --- a/spec/fabricators/system_key_fabricator.rb +++ b/spec/fabricators/system_key_fabricator.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Fabricator(:system_key) do end diff --git a/spec/fabricators/tag_fabricator.rb b/spec/fabricators/tag_fabricator.rb index 33d57c928..a7b52e967 100644 --- a/spec/fabricators/tag_fabricator.rb +++ b/spec/fabricators/tag_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:tag) do name { sequence(:hashtag) { |i| "#{Faker::Lorem.word}#{i}" } } end diff --git a/spec/fabricators/tag_follow_fabricator.rb b/spec/fabricators/tag_follow_fabricator.rb index a2cccb07a..cbe5b0989 100644 --- a/spec/fabricators/tag_follow_fabricator.rb +++ b/spec/fabricators/tag_follow_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:tag_follow) do tag account diff --git a/spec/fabricators/unavailable_domain_fabricator.rb b/spec/fabricators/unavailable_domain_fabricator.rb index f661b87c4..300a9e7a1 100644 --- a/spec/fabricators/unavailable_domain_fabricator.rb +++ b/spec/fabricators/unavailable_domain_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:unavailable_domain) do domain { Faker::Internet.domain } end diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index 93ce07a74..967347319 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:user) do account { Fabricate.build(:account, user: nil) } email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } } diff --git a/spec/fabricators/user_invite_request_fabricator.rb b/spec/fabricators/user_invite_request_fabricator.rb index 5cc6ae56f..7736263e4 100644 --- a/spec/fabricators/user_invite_request_fabricator.rb +++ b/spec/fabricators/user_invite_request_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:user_invite_request) do user text { Faker::Lorem.sentence } diff --git a/spec/fabricators/user_role_fabricator.rb b/spec/fabricators/user_role_fabricator.rb index 592b4edca..d44322760 100644 --- a/spec/fabricators/user_role_fabricator.rb +++ b/spec/fabricators/user_role_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:user_role) do name 'MyString' color '' diff --git a/spec/fabricators/web_push_subscription_fabricator.rb b/spec/fabricators/web_push_subscription_fabricator.rb index 97f90675d..baffdbf83 100644 --- a/spec/fabricators/web_push_subscription_fabricator.rb +++ b/spec/fabricators/web_push_subscription_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:web_push_subscription, from: Web::PushSubscription) do endpoint Faker::Internet.url key_p256dh Faker::Internet.password diff --git a/spec/fabricators/web_setting_fabricator.rb b/spec/fabricators/web_setting_fabricator.rb index 369b86bc1..7c9f30079 100644 --- a/spec/fabricators/web_setting_fabricator.rb +++ b/spec/fabricators/web_setting_fabricator.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + Fabricator(:web_setting, from: Web::Setting) do end diff --git a/spec/fabricators/webauthn_credential_fabricator.rb b/spec/fabricators/webauthn_credential_fabricator.rb index ba59ce967..b578d55f0 100644 --- a/spec/fabricators/webauthn_credential_fabricator.rb +++ b/spec/fabricators/webauthn_credential_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:webauthn_credential) do user_id { Fabricate(:user).id } external_id { Base64.urlsafe_encode64(SecureRandom.random_bytes(16)) } diff --git a/spec/fabricators/webhook_fabricator.rb b/spec/fabricators/webhook_fabricator.rb index fa4f17b55..477e715ef 100644 --- a/spec/fabricators/webhook_fabricator.rb +++ b/spec/fabricators/webhook_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:webhook) do url { Faker::Internet.url } secret { SecureRandom.hex } diff --git a/spec/helpers/accounts_helper_spec.rb b/spec/helpers/accounts_helper_spec.rb index 1f412a39f..184b47dec 100644 --- a/spec/helpers/accounts_helper_spec.rb +++ b/spec/helpers/accounts_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountsHelper, type: :helper do diff --git a/spec/helpers/admin/filter_helper_spec.rb b/spec/helpers/admin/filter_helper_spec.rb index 9d4ea2829..bbf90a996 100644 --- a/spec/helpers/admin/filter_helper_spec.rb +++ b/spec/helpers/admin/filter_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::FilterHelper do diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index e0f71afd5..2db2ee288 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ApplicationHelper do diff --git a/spec/helpers/home_helper_spec.rb b/spec/helpers/home_helper_spec.rb index a3dc6f836..77db327c2 100644 --- a/spec/helpers/home_helper_spec.rb +++ b/spec/helpers/home_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe HomeHelper, type: :helper do diff --git a/spec/helpers/statuses_helper_spec.rb b/spec/helpers/statuses_helper_spec.rb index cba659bfb..ce2a4680e 100644 --- a/spec/helpers/statuses_helper_spec.rb +++ b/spec/helpers/statuses_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe StatusesHelper, type: :helper do diff --git a/spec/lib/activitypub/activity/accept_spec.rb b/spec/lib/activitypub/activity/accept_spec.rb index 95a5a8747..890a07be5 100644 --- a/spec/lib/activitypub/activity/accept_spec.rb +++ b/spec/lib/activitypub/activity/accept_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Accept do diff --git a/spec/lib/activitypub/activity/add_spec.rb b/spec/lib/activitypub/activity/add_spec.rb index a69c3d2b1..9c45e465e 100644 --- a/spec/lib/activitypub/activity/add_spec.rb +++ b/spec/lib/activitypub/activity/add_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Add do diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index b3257e881..394b1d7b9 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Announce do diff --git a/spec/lib/activitypub/activity/block_spec.rb b/spec/lib/activitypub/activity/block_spec.rb index 42bdfdc81..6f6898401 100644 --- a/spec/lib/activitypub/activity/block_spec.rb +++ b/spec/lib/activitypub/activity/block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Block do diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index fd4983037..933eff225 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Create do diff --git a/spec/lib/activitypub/activity/delete_spec.rb b/spec/lib/activitypub/activity/delete_spec.rb index 40cd0fce9..3a73b3726 100644 --- a/spec/lib/activitypub/activity/delete_spec.rb +++ b/spec/lib/activitypub/activity/delete_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Delete do diff --git a/spec/lib/activitypub/activity/flag_spec.rb b/spec/lib/activitypub/activity/flag_spec.rb index c2a505356..005e185e6 100644 --- a/spec/lib/activitypub/activity/flag_spec.rb +++ b/spec/lib/activitypub/activity/flag_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Flag do diff --git a/spec/lib/activitypub/activity/follow_spec.rb b/spec/lib/activitypub/activity/follow_spec.rb index fd4ede82b..eb8b17d61 100644 --- a/spec/lib/activitypub/activity/follow_spec.rb +++ b/spec/lib/activitypub/activity/follow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Follow do diff --git a/spec/lib/activitypub/activity/like_spec.rb b/spec/lib/activitypub/activity/like_spec.rb index b69615a9d..640d61ab3 100644 --- a/spec/lib/activitypub/activity/like_spec.rb +++ b/spec/lib/activitypub/activity/like_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Like do diff --git a/spec/lib/activitypub/activity/move_spec.rb b/spec/lib/activitypub/activity/move_spec.rb index c468fdeff..8bd23aa7b 100644 --- a/spec/lib/activitypub/activity/move_spec.rb +++ b/spec/lib/activitypub/activity/move_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Move do diff --git a/spec/lib/activitypub/activity/reject_spec.rb b/spec/lib/activitypub/activity/reject_spec.rb index 7f04db4e6..5e0f09bfe 100644 --- a/spec/lib/activitypub/activity/reject_spec.rb +++ b/spec/lib/activitypub/activity/reject_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Reject do diff --git a/spec/lib/activitypub/activity/remove_spec.rb b/spec/lib/activitypub/activity/remove_spec.rb index 4209dfde2..fc12aec8c 100644 --- a/spec/lib/activitypub/activity/remove_spec.rb +++ b/spec/lib/activitypub/activity/remove_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Remove do diff --git a/spec/lib/activitypub/activity/undo_spec.rb b/spec/lib/activitypub/activity/undo_spec.rb index 0bd1f17d3..b4cbc7196 100644 --- a/spec/lib/activitypub/activity/undo_spec.rb +++ b/spec/lib/activitypub/activity/undo_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Undo do diff --git a/spec/lib/activitypub/activity/update_spec.rb b/spec/lib/activitypub/activity/update_spec.rb index d2a1edd7a..f77279c02 100644 --- a/spec/lib/activitypub/activity/update_spec.rb +++ b/spec/lib/activitypub/activity/update_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Activity::Update do diff --git a/spec/lib/activitypub/adapter_spec.rb b/spec/lib/activitypub/adapter_spec.rb index e4c403abb..b981ea9c6 100644 --- a/spec/lib/activitypub/adapter_spec.rb +++ b/spec/lib/activitypub/adapter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Adapter do diff --git a/spec/lib/activitypub/dereferencer_spec.rb b/spec/lib/activitypub/dereferencer_spec.rb index 800473a7c..11078de86 100644 --- a/spec/lib/activitypub/dereferencer_spec.rb +++ b/spec/lib/activitypub/dereferencer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::Dereferencer do diff --git a/spec/lib/activitypub/linked_data_signature_spec.rb b/spec/lib/activitypub/linked_data_signature_spec.rb index ecb1e16db..619d6df12 100644 --- a/spec/lib/activitypub/linked_data_signature_spec.rb +++ b/spec/lib/activitypub/linked_data_signature_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::LinkedDataSignature do diff --git a/spec/lib/activitypub/tag_manager_spec.rb b/spec/lib/activitypub/tag_manager_spec.rb index 606a1de2e..596e91e95 100644 --- a/spec/lib/activitypub/tag_manager_spec.rb +++ b/spec/lib/activitypub/tag_manager_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::TagManager do diff --git a/spec/lib/emoji_formatter_spec.rb b/spec/lib/emoji_formatter_spec.rb index c6fe8cf37..b73d5be4b 100644 --- a/spec/lib/emoji_formatter_spec.rb +++ b/spec/lib/emoji_formatter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe EmojiFormatter do diff --git a/spec/lib/entity_cache_spec.rb b/spec/lib/entity_cache_spec.rb index bd622e626..c750cddf3 100644 --- a/spec/lib/entity_cache_spec.rb +++ b/spec/lib/entity_cache_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe EntityCache do diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index d54050f8f..418bdf089 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FeedManager do diff --git a/spec/lib/html_aware_formatter_spec.rb b/spec/lib/html_aware_formatter_spec.rb index 3d3149b8f..315035957 100644 --- a/spec/lib/html_aware_formatter_spec.rb +++ b/spec/lib/html_aware_formatter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe HtmlAwareFormatter do diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb index fcc265474..a46dd743a 100644 --- a/spec/lib/link_details_extractor_spec.rb +++ b/spec/lib/link_details_extractor_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe LinkDetailsExtractor do diff --git a/spec/lib/plain_text_formatter_spec.rb b/spec/lib/plain_text_formatter_spec.rb index 0e5f39031..4a0519aaf 100644 --- a/spec/lib/plain_text_formatter_spec.rb +++ b/spec/lib/plain_text_formatter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe PlainTextFormatter do diff --git a/spec/lib/suspicious_sign_in_detector_spec.rb b/spec/lib/suspicious_sign_in_detector_spec.rb index 05aadfd8f..c61b1ef1e 100644 --- a/spec/lib/suspicious_sign_in_detector_spec.rb +++ b/spec/lib/suspicious_sign_in_detector_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe SuspiciousSignInDetector do diff --git a/spec/lib/tag_manager_spec.rb b/spec/lib/tag_manager_spec.rb index d2bb24c0f..8de290541 100644 --- a/spec/lib/tag_manager_spec.rb +++ b/spec/lib/tag_manager_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe TagManager do diff --git a/spec/lib/text_formatter_spec.rb b/spec/lib/text_formatter_spec.rb index 04ae4e02c..3417b450c 100644 --- a/spec/lib/text_formatter_spec.rb +++ b/spec/lib/text_formatter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe TextFormatter do diff --git a/spec/lib/vacuum/access_tokens_vacuum_spec.rb b/spec/lib/vacuum/access_tokens_vacuum_spec.rb index 0244c3449..6b7234065 100644 --- a/spec/lib/vacuum/access_tokens_vacuum_spec.rb +++ b/spec/lib/vacuum/access_tokens_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::AccessTokensVacuum do diff --git a/spec/lib/vacuum/backups_vacuum_spec.rb b/spec/lib/vacuum/backups_vacuum_spec.rb index c505a3e1a..867dbe402 100644 --- a/spec/lib/vacuum/backups_vacuum_spec.rb +++ b/spec/lib/vacuum/backups_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::BackupsVacuum do diff --git a/spec/lib/vacuum/feeds_vacuum_spec.rb b/spec/lib/vacuum/feeds_vacuum_spec.rb index 0aec26740..ede1e3c36 100644 --- a/spec/lib/vacuum/feeds_vacuum_spec.rb +++ b/spec/lib/vacuum/feeds_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::FeedsVacuum do diff --git a/spec/lib/vacuum/media_attachments_vacuum_spec.rb b/spec/lib/vacuum/media_attachments_vacuum_spec.rb index afcb6f878..3c17ecb00 100644 --- a/spec/lib/vacuum/media_attachments_vacuum_spec.rb +++ b/spec/lib/vacuum/media_attachments_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::MediaAttachmentsVacuum do diff --git a/spec/lib/vacuum/preview_cards_vacuum_spec.rb b/spec/lib/vacuum/preview_cards_vacuum_spec.rb index 524f4c927..c1b7f7e9c 100644 --- a/spec/lib/vacuum/preview_cards_vacuum_spec.rb +++ b/spec/lib/vacuum/preview_cards_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::PreviewCardsVacuum do diff --git a/spec/lib/vacuum/statuses_vacuum_spec.rb b/spec/lib/vacuum/statuses_vacuum_spec.rb index 9583376b7..d5c013950 100644 --- a/spec/lib/vacuum/statuses_vacuum_spec.rb +++ b/spec/lib/vacuum/statuses_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::StatusesVacuum do diff --git a/spec/lib/vacuum/system_keys_vacuum_spec.rb b/spec/lib/vacuum/system_keys_vacuum_spec.rb index 565892f02..84cae3041 100644 --- a/spec/lib/vacuum/system_keys_vacuum_spec.rb +++ b/spec/lib/vacuum/system_keys_vacuum_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Vacuum::SystemKeysVacuum do diff --git a/spec/lib/webfinger_resource_spec.rb b/spec/lib/webfinger_resource_spec.rb index ee007da70..8ec6dd205 100644 --- a/spec/lib/webfinger_resource_spec.rb +++ b/spec/lib/webfinger_resource_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe WebfingerResource do diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 6746871a3..a6db08d85 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe NotificationMailer, type: :mailer do diff --git a/spec/mailers/previews/admin_mailer_preview.rb b/spec/mailers/previews/admin_mailer_preview.rb index 0ec9e9882..9572768cd 100644 --- a/spec/mailers/previews/admin_mailer_preview.rb +++ b/spec/mailers/previews/admin_mailer_preview.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Preview all emails at http://localhost:3000/rails/mailers/admin_mailer class AdminMailerPreview < ActionMailer::Preview diff --git a/spec/mailers/previews/notification_mailer_preview.rb b/spec/mailers/previews/notification_mailer_preview.rb index e31445c36..bc41662a1 100644 --- a/spec/mailers/previews/notification_mailer_preview.rb +++ b/spec/mailers/previews/notification_mailer_preview.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Preview all emails at http://localhost:3000/rails/mailers/notification_mailer class NotificationMailerPreview < ActionMailer::Preview diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb index 95712e6cf..098c9cd90 100644 --- a/spec/mailers/previews/user_mailer_preview.rb +++ b/spec/mailers/previews/user_mailer_preview.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Preview all emails at http://localhost:3000/rails/mailers/user_mailer class UserMailerPreview < ActionMailer::Preview diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index 36e1a8595..6745fbb26 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Account::Field, type: :model do diff --git a/spec/models/account_alias_spec.rb b/spec/models/account_alias_spec.rb index c48b804b2..08c3eaff4 100644 --- a/spec/models/account_alias_spec.rb +++ b/spec/models/account_alias_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountAlias, type: :model do diff --git a/spec/models/account_conversation_spec.rb b/spec/models/account_conversation_spec.rb index 70a76281e..c4e8918ad 100644 --- a/spec/models/account_conversation_spec.rb +++ b/spec/models/account_conversation_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountConversation, type: :model do diff --git a/spec/models/account_deletion_request_spec.rb b/spec/models/account_deletion_request_spec.rb index afaecbe22..db332f14c 100644 --- a/spec/models/account_deletion_request_spec.rb +++ b/spec/models/account_deletion_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountDeletionRequest, type: :model do diff --git a/spec/models/account_domain_block_spec.rb b/spec/models/account_domain_block_spec.rb index a170abcd2..bc46f44ba 100644 --- a/spec/models/account_domain_block_spec.rb +++ b/spec/models/account_domain_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountDomainBlock, type: :model do diff --git a/spec/models/account_filter_spec.rb b/spec/models/account_filter_spec.rb index c2bd8c220..853d20a0c 100644 --- a/spec/models/account_filter_spec.rb +++ b/spec/models/account_filter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AccountFilter do diff --git a/spec/models/account_migration_spec.rb b/spec/models/account_migration_spec.rb index 5f66fe8da..a91ba5dc5 100644 --- a/spec/models/account_migration_spec.rb +++ b/spec/models/account_migration_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountMigration, type: :model do diff --git a/spec/models/account_moderation_note_spec.rb b/spec/models/account_moderation_note_spec.rb index 69bd5500a..b7f5701e6 100644 --- a/spec/models/account_moderation_note_spec.rb +++ b/spec/models/account_moderation_note_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountModerationNote, type: :model do diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index f3ad19877..1e5a80963 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Account, type: :model do diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index d170050fc..1b7857547 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AccountStatusesCleanupPolicy, type: :model do diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index 7248356e5..9f41b7c8e 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Admin::AccountAction, type: :model do diff --git a/spec/models/announcement_mute_spec.rb b/spec/models/announcement_mute_spec.rb index 9d0e4c903..f4a7a5dc9 100644 --- a/spec/models/announcement_mute_spec.rb +++ b/spec/models/announcement_mute_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AnnouncementMute, type: :model do diff --git a/spec/models/announcement_reaction_spec.rb b/spec/models/announcement_reaction_spec.rb index f6e151584..38095b015 100644 --- a/spec/models/announcement_reaction_spec.rb +++ b/spec/models/announcement_reaction_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AnnouncementReaction, type: :model do diff --git a/spec/models/announcement_spec.rb b/spec/models/announcement_spec.rb index 7f7b647a9..024fa2888 100644 --- a/spec/models/announcement_spec.rb +++ b/spec/models/announcement_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Announcement, type: :model do diff --git a/spec/models/appeal_spec.rb b/spec/models/appeal_spec.rb index 14062dc4f..6aa013aba 100644 --- a/spec/models/appeal_spec.rb +++ b/spec/models/appeal_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Appeal, type: :model do diff --git a/spec/models/backup_spec.rb b/spec/models/backup_spec.rb index 45230986d..239e7aef7 100644 --- a/spec/models/backup_spec.rb +++ b/spec/models/backup_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Backup, type: :model do diff --git a/spec/models/block_spec.rb b/spec/models/block_spec.rb index 1fd60c29d..64c39fce6 100644 --- a/spec/models/block_spec.rb +++ b/spec/models/block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Block, type: :model do diff --git a/spec/models/canonical_email_block_spec.rb b/spec/models/canonical_email_block_spec.rb index 8e0050d65..2b3fd6d6a 100644 --- a/spec/models/canonical_email_block_spec.rb +++ b/spec/models/canonical_email_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe CanonicalEmailBlock, type: :model do diff --git a/spec/models/concerns/account_counters_spec.rb b/spec/models/concerns/account_counters_spec.rb index 4350496e7..fb02d79f1 100644 --- a/spec/models/concerns/account_counters_spec.rb +++ b/spec/models/concerns/account_counters_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AccountCounters do diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 50ff0b149..7396af6df 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AccountInteractions do diff --git a/spec/models/conversation_mute_spec.rb b/spec/models/conversation_mute_spec.rb index 3fc2915d4..6439b0ecd 100644 --- a/spec/models/conversation_mute_spec.rb +++ b/spec/models/conversation_mute_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ConversationMute, type: :model do diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 8b5e4fdaf..9d58ad0ac 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Conversation, type: :model do diff --git a/spec/models/custom_emoji_category_spec.rb b/spec/models/custom_emoji_category_spec.rb index 160033f4d..74881b26c 100644 --- a/spec/models/custom_emoji_category_spec.rb +++ b/spec/models/custom_emoji_category_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe CustomEmojiCategory, type: :model do diff --git a/spec/models/custom_emoji_spec.rb b/spec/models/custom_emoji_spec.rb index f6fcd468b..ef5f39aca 100644 --- a/spec/models/custom_emoji_spec.rb +++ b/spec/models/custom_emoji_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe CustomEmoji, type: :model do diff --git a/spec/models/custom_filter_keyword_spec.rb b/spec/models/custom_filter_keyword_spec.rb index e15b9dad5..bbc4b9c2e 100644 --- a/spec/models/custom_filter_keyword_spec.rb +++ b/spec/models/custom_filter_keyword_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe CustomFilterKeyword, type: :model do diff --git a/spec/models/custom_filter_spec.rb b/spec/models/custom_filter_spec.rb index 3943dd5f1..d2bc090ab 100644 --- a/spec/models/custom_filter_spec.rb +++ b/spec/models/custom_filter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe CustomFilter, type: :model do diff --git a/spec/models/device_spec.rb b/spec/models/device_spec.rb index 307552e91..cb214b9cb 100644 --- a/spec/models/device_spec.rb +++ b/spec/models/device_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Device, type: :model do diff --git a/spec/models/domain_allow_spec.rb b/spec/models/domain_allow_spec.rb index e65435127..18cf5fe4c 100644 --- a/spec/models/domain_allow_spec.rb +++ b/spec/models/domain_allow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe DomainAllow, type: :model do diff --git a/spec/models/domain_block_spec.rb b/spec/models/domain_block_spec.rb index d1d57c167..6a5925b89 100644 --- a/spec/models/domain_block_spec.rb +++ b/spec/models/domain_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe DomainBlock, type: :model do diff --git a/spec/models/email_domain_block_spec.rb b/spec/models/email_domain_block_spec.rb index e23116888..01a7a0f0e 100644 --- a/spec/models/email_domain_block_spec.rb +++ b/spec/models/email_domain_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe EmailDomainBlock, type: :model do diff --git a/spec/models/encrypted_message_spec.rb b/spec/models/encrypted_message_spec.rb index 64f9c6912..bf7a406ff 100644 --- a/spec/models/encrypted_message_spec.rb +++ b/spec/models/encrypted_message_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe EncryptedMessage, type: :model do diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 5202ae9e1..3fb5fc3a5 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Export do diff --git a/spec/models/favourite_spec.rb b/spec/models/favourite_spec.rb index f755590ee..f7e2812a6 100644 --- a/spec/models/favourite_spec.rb +++ b/spec/models/favourite_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Favourite, type: :model do diff --git a/spec/models/featured_tag_spec.rb b/spec/models/featured_tag_spec.rb index 07533e0b9..4bf087c82 100644 --- a/spec/models/featured_tag_spec.rb +++ b/spec/models/featured_tag_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FeaturedTag, type: :model do diff --git a/spec/models/follow_recommendation_suppression_spec.rb b/spec/models/follow_recommendation_suppression_spec.rb index 39107a2b0..4c1d8281b 100644 --- a/spec/models/follow_recommendation_suppression_spec.rb +++ b/spec/models/follow_recommendation_suppression_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FollowRecommendationSuppression, type: :model do diff --git a/spec/models/follow_request_spec.rb b/spec/models/follow_request_spec.rb index 901eabc9d..569c160ae 100644 --- a/spec/models/follow_request_spec.rb +++ b/spec/models/follow_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FollowRequest, type: :model do diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index e723a1ef2..f49d58532 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Follow, type: :model do diff --git a/spec/models/home_feed_spec.rb b/spec/models/home_feed_spec.rb index 196bef1e4..d7034f3f0 100644 --- a/spec/models/home_feed_spec.rb +++ b/spec/models/home_feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe HomeFeed, type: :model do diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb index 689c9b797..6eab5a2e1 100644 --- a/spec/models/identity_spec.rb +++ b/spec/models/identity_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Identity, type: :model do diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 4280b3237..81c75a964 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Import, type: :model do diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index b0596c561..dac4b6431 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Invite, type: :model do diff --git a/spec/models/ip_block_spec.rb b/spec/models/ip_block_spec.rb index 6603c6417..4c4028576 100644 --- a/spec/models/ip_block_spec.rb +++ b/spec/models/ip_block_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe IpBlock, type: :model do diff --git a/spec/models/list_account_spec.rb b/spec/models/list_account_spec.rb index a0cf02efe..8312defac 100644 --- a/spec/models/list_account_spec.rb +++ b/spec/models/list_account_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ListAccount, type: :model do diff --git a/spec/models/list_spec.rb b/spec/models/list_spec.rb index b780bb1de..8167f8a7e 100644 --- a/spec/models/list_spec.rb +++ b/spec/models/list_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe List, type: :model do diff --git a/spec/models/login_activity_spec.rb b/spec/models/login_activity_spec.rb index 12d8c4363..1c3111a20 100644 --- a/spec/models/login_activity_spec.rb +++ b/spec/models/login_activity_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe LoginActivity, type: :model do diff --git a/spec/models/marker_spec.rb b/spec/models/marker_spec.rb index d716aa75c..e8561c4c6 100644 --- a/spec/models/marker_spec.rb +++ b/spec/models/marker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Marker, type: :model do diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 097c76f31..63edfc152 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe MediaAttachment, type: :model do diff --git a/spec/models/mention_spec.rb b/spec/models/mention_spec.rb index dbcf6a32c..3de2b4a07 100644 --- a/spec/models/mention_spec.rb +++ b/spec/models/mention_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Mention, type: :model do diff --git a/spec/models/mute_spec.rb b/spec/models/mute_spec.rb index 38a87bdf4..48b5a37ab 100644 --- a/spec/models/mute_spec.rb +++ b/spec/models/mute_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Mute, type: :model do diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index a8fb77639..64527e3d7 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Notification, type: :model do diff --git a/spec/models/one_time_key_spec.rb b/spec/models/one_time_key_spec.rb index 4b231c600..2a5fe8a9d 100644 --- a/spec/models/one_time_key_spec.rb +++ b/spec/models/one_time_key_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe OneTimeKey, type: :model do diff --git a/spec/models/poll_spec.rb b/spec/models/poll_spec.rb index 666f8ca68..474399bf6 100644 --- a/spec/models/poll_spec.rb +++ b/spec/models/poll_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Poll, type: :model do diff --git a/spec/models/preview_card_spec.rb b/spec/models/preview_card_spec.rb index 45233d1d4..1858644c9 100644 --- a/spec/models/preview_card_spec.rb +++ b/spec/models/preview_card_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe PreviewCard, type: :model do diff --git a/spec/models/preview_card_trend_spec.rb b/spec/models/preview_card_trend_spec.rb index c7ab6ed14..97ad05e75 100644 --- a/spec/models/preview_card_trend_spec.rb +++ b/spec/models/preview_card_trend_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe PreviewCardTrend, type: :model do diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index 59c81dd95..5653aee18 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe PublicFeed, type: :model do diff --git a/spec/models/relay_spec.rb b/spec/models/relay_spec.rb index 12dc0f20f..86c1762c1 100644 --- a/spec/models/relay_spec.rb +++ b/spec/models/relay_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Relay, type: :model do diff --git a/spec/models/report_filter_spec.rb b/spec/models/report_filter_spec.rb index 099c0731d..8269c4579 100644 --- a/spec/models/report_filter_spec.rb +++ b/spec/models/report_filter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ReportFilter do diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 317851297..d5d40a34f 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Report do diff --git a/spec/models/rule_spec.rb b/spec/models/rule_spec.rb index 8666bda71..d5ec13ddf 100644 --- a/spec/models/rule_spec.rb +++ b/spec/models/rule_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Rule, type: :model do diff --git a/spec/models/scheduled_status_spec.rb b/spec/models/scheduled_status_spec.rb index f8c9d8b81..294fa9f36 100644 --- a/spec/models/scheduled_status_spec.rb +++ b/spec/models/scheduled_status_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ScheduledStatus, type: :model do diff --git a/spec/models/status_edit_spec.rb b/spec/models/status_edit_spec.rb index 2ecafef73..0b9fa7087 100644 --- a/spec/models/status_edit_spec.rb +++ b/spec/models/status_edit_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe StatusEdit, type: :model do diff --git a/spec/models/status_pin_spec.rb b/spec/models/status_pin_spec.rb index c18faca78..c4ebf96da 100644 --- a/spec/models/status_pin_spec.rb +++ b/spec/models/status_pin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe StatusPin, type: :model do diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 442f14ddf..1e58c6d0d 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Status, type: :model do diff --git a/spec/models/status_stat_spec.rb b/spec/models/status_stat_spec.rb index af1a6f288..749ca097d 100644 --- a/spec/models/status_stat_spec.rb +++ b/spec/models/status_stat_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe StatusStat, type: :model do diff --git a/spec/models/status_trend_spec.rb b/spec/models/status_trend_spec.rb index 6b82204a6..9678b838a 100644 --- a/spec/models/status_trend_spec.rb +++ b/spec/models/status_trend_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe StatusTrend, type: :model do diff --git a/spec/models/system_key_spec.rb b/spec/models/system_key_spec.rb index 86f07f964..a4e8b7784 100644 --- a/spec/models/system_key_spec.rb +++ b/spec/models/system_key_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe SystemKey, type: :model do diff --git a/spec/models/tag_feed_spec.rb b/spec/models/tag_feed_spec.rb index 819fe3765..a498bcf46 100644 --- a/spec/models/tag_feed_spec.rb +++ b/spec/models/tag_feed_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe TagFeed, type: :service do diff --git a/spec/models/tag_follow_spec.rb b/spec/models/tag_follow_spec.rb index 50c04d2e4..88409bb28 100644 --- a/spec/models/tag_follow_spec.rb +++ b/spec/models/tag_follow_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe TagFollow, type: :model do diff --git a/spec/models/trends/statuses_spec.rb b/spec/models/trends/statuses_spec.rb index 98a8c7264..29a20a595 100644 --- a/spec/models/trends/statuses_spec.rb +++ b/spec/models/trends/statuses_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Trends::Statuses do diff --git a/spec/models/trends/tags_spec.rb b/spec/models/trends/tags_spec.rb index f48c73503..a9473e15c 100644 --- a/spec/models/trends/tags_spec.rb +++ b/spec/models/trends/tags_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Trends::Tags do diff --git a/spec/models/unavailable_domain_spec.rb b/spec/models/unavailable_domain_spec.rb index 3f2621034..5469ff693 100644 --- a/spec/models/unavailable_domain_spec.rb +++ b/spec/models/unavailable_domain_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UnavailableDomain, type: :model do diff --git a/spec/models/user_invite_request_spec.rb b/spec/models/user_invite_request_spec.rb index 1be38d8a4..95e128439 100644 --- a/spec/models/user_invite_request_spec.rb +++ b/spec/models/user_invite_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UserInviteRequest, type: :model do diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 52a8622f9..97456c106 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UserRole, type: :model do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9dfd6678a..3e7b59f17 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' require 'devise_two_factor/spec_helpers' diff --git a/spec/models/web/push_subscription_spec.rb b/spec/models/web/push_subscription_spec.rb index a5c34f4ed..e925e4c4c 100644 --- a/spec/models/web/push_subscription_spec.rb +++ b/spec/models/web/push_subscription_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Web::PushSubscription, type: :model do diff --git a/spec/models/web/setting_spec.rb b/spec/models/web/setting_spec.rb index 6657d4030..b7ff3c868 100644 --- a/spec/models/web/setting_spec.rb +++ b/spec/models/web/setting_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Web::Setting, type: :model do diff --git a/spec/models/webauthn_credentials_spec.rb b/spec/models/webauthn_credentials_spec.rb index e070a6b60..1a2a2f909 100644 --- a/spec/models/webauthn_credentials_spec.rb +++ b/spec/models/webauthn_credentials_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe WebauthnCredential, type: :model do diff --git a/spec/models/webhook_spec.rb b/spec/models/webhook_spec.rb index 60c3d9524..fcf3dd14f 100644 --- a/spec/models/webhook_spec.rb +++ b/spec/models/webhook_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Webhook, type: :model do diff --git a/spec/presenters/instance_presenter_spec.rb b/spec/presenters/instance_presenter_spec.rb index a451b5cba..29170a79a 100644 --- a/spec/presenters/instance_presenter_spec.rb +++ b/spec/presenters/instance_presenter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe InstancePresenter do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 9a14fc3b1..faae02df0 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../config/environment', __dir__) diff --git a/spec/requests/catch_all_route_request_spec.rb b/spec/requests/catch_all_route_request_spec.rb index dcfc1bf4b..e600bedfe 100644 --- a/spec/requests/catch_all_route_request_spec.rb +++ b/spec/requests/catch_all_route_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'The catch all route' do diff --git a/spec/requests/host_meta_request_spec.rb b/spec/requests/host_meta_request_spec.rb index 60153ba8c..ec26ecba7 100644 --- a/spec/requests/host_meta_request_spec.rb +++ b/spec/requests/host_meta_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'The host_meta route' do diff --git a/spec/requests/webfinger_request_spec.rb b/spec/requests/webfinger_request_spec.rb index 209fda72a..68a1478be 100644 --- a/spec/requests/webfinger_request_spec.rb +++ b/spec/requests/webfinger_request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'The webfinger route' do diff --git a/spec/routing/accounts_routing_spec.rb b/spec/routing/accounts_routing_spec.rb index 3f0e9b3e9..8b2c124fd 100644 --- a/spec/routing/accounts_routing_spec.rb +++ b/spec/routing/accounts_routing_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Routes under accounts/' do diff --git a/spec/routing/well_known_routes_spec.rb b/spec/routing/well_known_routes_spec.rb index 747463351..8cf08c13c 100644 --- a/spec/routing/well_known_routes_spec.rb +++ b/spec/routing/well_known_routes_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Well Known routes' do diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index 45e19d1ef..bb819bb6c 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AccountSearchService, type: :service do diff --git a/spec/services/account_statuses_cleanup_service_spec.rb b/spec/services/account_statuses_cleanup_service_spec.rb index a30e14ab6..e83063f73 100644 --- a/spec/services/account_statuses_cleanup_service_spec.rb +++ b/spec/services/account_statuses_cleanup_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe AccountStatusesCleanupService, type: :service do diff --git a/spec/services/activitypub/fetch_featured_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_collection_service_spec.rb index d9266ffc2..59d332599 100644 --- a/spec/services/activitypub/fetch_featured_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_collection_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do diff --git a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb index 4f828bacc..071e4d92d 100644 --- a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do diff --git a/spec/services/activitypub/fetch_remote_account_service_spec.rb b/spec/services/activitypub/fetch_remote_account_service_spec.rb index ec6f1f41d..868bc2a58 100644 --- a/spec/services/activitypub/fetch_remote_account_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do diff --git a/spec/services/activitypub/fetch_remote_actor_service_spec.rb b/spec/services/activitypub/fetch_remote_actor_service_spec.rb index 20117c66d..a72c6941e 100644 --- a/spec/services/activitypub/fetch_remote_actor_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_actor_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do diff --git a/spec/services/activitypub/fetch_remote_key_service_spec.rb b/spec/services/activitypub/fetch_remote_key_service_spec.rb index 3186c4270..0ec0c2736 100644 --- a/spec/services/activitypub/fetch_remote_key_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_key_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteKeyService, type: :service do diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index 6e47392b3..1c39db21f 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do diff --git a/spec/services/activitypub/fetch_replies_service_spec.rb b/spec/services/activitypub/fetch_replies_service_spec.rb index 0231a5e9a..bf8e29676 100644 --- a/spec/services/activitypub/fetch_replies_service_spec.rb +++ b/spec/services/activitypub/fetch_replies_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::FetchRepliesService, type: :service do diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 78282e453..491b8ed5a 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::ProcessAccountService, type: :service do diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index c7d0bb92a..1433d0c50 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::ProcessCollectionService, type: :service do diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index c8aa56def..e9f23b9cf 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' def poll_option_json(name, votes) diff --git a/spec/services/activitypub/synchronize_followers_service_spec.rb b/spec/services/activitypub/synchronize_followers_service_spec.rb index 0e829a302..c9a513e24 100644 --- a/spec/services/activitypub/synchronize_followers_service_spec.rb +++ b/spec/services/activitypub/synchronize_followers_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do diff --git a/spec/services/after_block_domain_from_account_service_spec.rb b/spec/services/after_block_domain_from_account_service_spec.rb index 9cca82bff..b75f92372 100644 --- a/spec/services/after_block_domain_from_account_service_spec.rb +++ b/spec/services/after_block_domain_from_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AfterBlockDomainFromAccountService, type: :service do diff --git a/spec/services/after_block_service_spec.rb b/spec/services/after_block_service_spec.rb index 337766d06..d81bba1d8 100644 --- a/spec/services/after_block_service_spec.rb +++ b/spec/services/after_block_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AfterBlockService, type: :service do diff --git a/spec/services/app_sign_up_service_spec.rb b/spec/services/app_sign_up_service_spec.rb index 10da07dcf..253230496 100644 --- a/spec/services/app_sign_up_service_spec.rb +++ b/spec/services/app_sign_up_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AppSignUpService, type: :service do diff --git a/spec/services/authorize_follow_service_spec.rb b/spec/services/authorize_follow_service_spec.rb index 8f8e44ec7..63d9e2a0f 100644 --- a/spec/services/authorize_follow_service_spec.rb +++ b/spec/services/authorize_follow_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AuthorizeFollowService, type: :service do diff --git a/spec/services/batched_remove_status_service_spec.rb b/spec/services/batched_remove_status_service_spec.rb index 920edeb13..9bedf3744 100644 --- a/spec/services/batched_remove_status_service_spec.rb +++ b/spec/services/batched_remove_status_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe BatchedRemoveStatusService, type: :service do diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index 56b3a5ad1..0ab97b8ce 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe BlockDomainService, type: :service do diff --git a/spec/services/block_service_spec.rb b/spec/services/block_service_spec.rb index 049644dbc..75f07f5ad 100644 --- a/spec/services/block_service_spec.rb +++ b/spec/services/block_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe BlockService, type: :service do diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb index 149f6e6df..670ac652f 100644 --- a/spec/services/bootstrap_timeline_service_spec.rb +++ b/spec/services/bootstrap_timeline_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe BootstrapTimelineService, type: :service do diff --git a/spec/services/clear_domain_media_service_spec.rb b/spec/services/clear_domain_media_service_spec.rb index 993ba789e..987507579 100644 --- a/spec/services/clear_domain_media_service_spec.rb +++ b/spec/services/clear_domain_media_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ClearDomainMediaService, type: :service do diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index e5bfdd679..61e5c3c9b 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe DeleteAccountService, type: :service do diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index d09750dd2..3b554f9ea 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FanOutOnWriteService, type: :service do diff --git a/spec/services/favourite_service_spec.rb b/spec/services/favourite_service_spec.rb index 4f621200a..613ae203e 100644 --- a/spec/services/favourite_service_spec.rb +++ b/spec/services/favourite_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FavouriteService, type: :service do diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb index 458473c39..d79ab7a43 100644 --- a/spec/services/fetch_link_card_service_spec.rb +++ b/spec/services/fetch_link_card_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FetchLinkCardService, type: :service do diff --git a/spec/services/fetch_remote_status_service_spec.rb b/spec/services/fetch_remote_status_service_spec.rb index ace520b8f..694a75dc2 100644 --- a/spec/services/fetch_remote_status_service_spec.rb +++ b/spec/services/fetch_remote_status_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FetchRemoteStatusService, type: :service do diff --git a/spec/services/fetch_resource_service_spec.rb b/spec/services/fetch_resource_service_spec.rb index 226c98d70..da7e42351 100644 --- a/spec/services/fetch_resource_service_spec.rb +++ b/spec/services/fetch_resource_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FetchResourceService, type: :service do diff --git a/spec/services/follow_service_spec.rb b/spec/services/follow_service_spec.rb index f95d59440..67a8b2c54 100644 --- a/spec/services/follow_service_spec.rb +++ b/spec/services/follow_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe FollowService, type: :service do diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index 4a517fb93..f081f2d9d 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ImportService, type: :service do diff --git a/spec/services/mute_service_spec.rb b/spec/services/mute_service_spec.rb index 57d8c41de..50f74ff27 100644 --- a/spec/services/mute_service_spec.rb +++ b/spec/services/mute_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe MuteService, type: :service do diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb index 294c31b04..c58cebbfb 100644 --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe NotifyService, type: :service do diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index c34f2393a..33153c3d0 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe PostStatusService, type: :service do diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index 79ccfa322..adc45c60a 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ProcessMentionsService, type: :service do diff --git a/spec/services/purge_domain_service_spec.rb b/spec/services/purge_domain_service_spec.rb index 7d8969ee8..310affa5e 100644 --- a/spec/services/purge_domain_service_spec.rb +++ b/spec/services/purge_domain_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe PurgeDomainService, type: :service do diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index e2ac0154c..c00472229 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ReblogService, type: :service do diff --git a/spec/services/reject_follow_service_spec.rb b/spec/services/reject_follow_service_spec.rb index 97b7412b9..be9363d84 100644 --- a/spec/services/reject_follow_service_spec.rb +++ b/spec/services/reject_follow_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe RejectFollowService, type: :service do diff --git a/spec/services/remove_from_follwers_service_spec.rb b/spec/services/remove_from_follwers_service_spec.rb index 782f859e2..21cea2e4f 100644 --- a/spec/services/remove_from_follwers_service_spec.rb +++ b/spec/services/remove_from_follwers_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe RemoveFromFollowersService, type: :service do diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index e253052f3..a836109a0 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe RemoveStatusService, type: :service do diff --git a/spec/services/report_service_spec.rb b/spec/services/report_service_spec.rb index c3a3fddf8..9d81bd971 100644 --- a/spec/services/report_service_spec.rb +++ b/spec/services/report_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ReportService, type: :service do diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 02869f8c8..3ce1f7f2b 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe ResolveAccountService, type: :service do diff --git a/spec/services/suspend_account_service_spec.rb b/spec/services/suspend_account_service_spec.rb index 5701090b3..4489bfed5 100644 --- a/spec/services/suspend_account_service_spec.rb +++ b/spec/services/suspend_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe SuspendAccountService, type: :service do diff --git a/spec/services/unallow_domain_service_spec.rb b/spec/services/unallow_domain_service_spec.rb index ae7d00c7d..48e310a9d 100644 --- a/spec/services/unallow_domain_service_spec.rb +++ b/spec/services/unallow_domain_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UnallowDomainService, type: :service do diff --git a/spec/services/unblock_service_spec.rb b/spec/services/unblock_service_spec.rb index bd24005f6..8098d7e6d 100644 --- a/spec/services/unblock_service_spec.rb +++ b/spec/services/unblock_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UnblockService, type: :service do diff --git a/spec/services/unfollow_service_spec.rb b/spec/services/unfollow_service_spec.rb index 55969bef9..a12f01fa5 100644 --- a/spec/services/unfollow_service_spec.rb +++ b/spec/services/unfollow_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UnfollowService, type: :service do diff --git a/spec/services/unmute_service_spec.rb b/spec/services/unmute_service_spec.rb index 8463eb283..2edb6cfc2 100644 --- a/spec/services/unmute_service_spec.rb +++ b/spec/services/unmute_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UnmuteService, type: :service do diff --git a/spec/services/unsuspend_account_service_spec.rb b/spec/services/unsuspend_account_service_spec.rb index 667507469..5d7012093 100644 --- a/spec/services/unsuspend_account_service_spec.rb +++ b/spec/services/unsuspend_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UnsuspendAccountService, type: :service do diff --git a/spec/services/update_account_service_spec.rb b/spec/services/update_account_service_spec.rb index c2dc791e4..a711a8ae7 100644 --- a/spec/services/update_account_service_spec.rb +++ b/spec/services/update_account_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UpdateAccountService, type: :service do diff --git a/spec/services/update_status_service_spec.rb b/spec/services/update_status_service_spec.rb index a7364ca8b..e52a0e52b 100644 --- a/spec/services/update_status_service_spec.rb +++ b/spec/services/update_status_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe UpdateStatusService, type: :service do diff --git a/spec/services/verify_link_service_spec.rb b/spec/services/verify_link_service_spec.rb index 8f65f3a84..ea9ccc3fc 100644 --- a/spec/services/verify_link_service_spec.rb +++ b/spec/services/verify_link_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe VerifyLinkService, type: :service do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 97b8d83c5..ddc872fc8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + GC.disable if ENV['DISABLE_SIMPLECOV'] != 'true' diff --git a/spec/support/matchers/json/match_json_schema.rb b/spec/support/matchers/json/match_json_schema.rb index 5d9c9a618..3a275199e 100644 --- a/spec/support/matchers/json/match_json_schema.rb +++ b/spec/support/matchers/json/match_json_schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec::Matchers.define :match_json_schema do |schema| match do |input_json| schema_path = Rails.root.join('spec', 'support', 'schema', "#{schema}.json").to_s diff --git a/spec/support/matchers/model/model_have_error_on_field.rb b/spec/support/matchers/model/model_have_error_on_field.rb index d85db2fca..21632b574 100644 --- a/spec/support/matchers/model/model_have_error_on_field.rb +++ b/spec/support/matchers/model/model_have_error_on_field.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec::Matchers.define :model_have_error_on_field do |expected| match do |record| record.valid? if record.errors.empty? diff --git a/spec/workers/activitypub/distribute_poll_update_worker_spec.rb b/spec/workers/activitypub/distribute_poll_update_worker_spec.rb index d68a695b7..947acab3b 100644 --- a/spec/workers/activitypub/distribute_poll_update_worker_spec.rb +++ b/spec/workers/activitypub/distribute_poll_update_worker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ActivityPub::DistributePollUpdateWorker do diff --git a/spec/workers/activitypub/distribution_worker_spec.rb b/spec/workers/activitypub/distribution_worker_spec.rb index 7f63e197b..06d6ac738 100644 --- a/spec/workers/activitypub/distribution_worker_spec.rb +++ b/spec/workers/activitypub/distribution_worker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ActivityPub::DistributionWorker do diff --git a/spec/workers/activitypub/move_distribution_worker_spec.rb b/spec/workers/activitypub/move_distribution_worker_spec.rb index 482fa9db4..4df6b2f16 100644 --- a/spec/workers/activitypub/move_distribution_worker_spec.rb +++ b/spec/workers/activitypub/move_distribution_worker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ActivityPub::MoveDistributionWorker do diff --git a/spec/workers/activitypub/processing_worker_spec.rb b/spec/workers/activitypub/processing_worker_spec.rb index b42c0bdbc..6b57f16a9 100644 --- a/spec/workers/activitypub/processing_worker_spec.rb +++ b/spec/workers/activitypub/processing_worker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ActivityPub::ProcessingWorker do diff --git a/spec/workers/activitypub/status_update_distribution_worker_spec.rb b/spec/workers/activitypub/status_update_distribution_worker_spec.rb index c014c6790..cf55a461d 100644 --- a/spec/workers/activitypub/status_update_distribution_worker_spec.rb +++ b/spec/workers/activitypub/status_update_distribution_worker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ActivityPub::StatusUpdateDistributionWorker do diff --git a/spec/workers/activitypub/update_distribution_worker_spec.rb b/spec/workers/activitypub/update_distribution_worker_spec.rb index 0e057fd0b..7b1e6ff54 100644 --- a/spec/workers/activitypub/update_distribution_worker_spec.rb +++ b/spec/workers/activitypub/update_distribution_worker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe ActivityPub::UpdateDistributionWorker do diff --git a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb index a5dfed369..b977bc1fb 100644 --- a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb +++ b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Scheduler::AccountsStatusesCleanupScheduler do diff --git a/spec/workers/scheduler/user_cleanup_scheduler_spec.rb b/spec/workers/scheduler/user_cleanup_scheduler_spec.rb index da99f10f9..990979500 100644 --- a/spec/workers/scheduler/user_cleanup_scheduler_spec.rb +++ b/spec/workers/scheduler/user_cleanup_scheduler_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Scheduler::UserCleanupScheduler do -- cgit From ad585fb1959abe38839c30137cf3343737f1d247 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 4 Mar 2023 11:12:54 -0500 Subject: Specs api v1 controllers (#23930) --- .../accounts/familiar_followers_controller_spec.rb | 23 ++++++++++++++++ .../v1/accounts/featured_tags_controller_spec.rb | 23 ++++++++++++++++ .../v1/accounts/identity_proofs_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/accounts/lookup_controller_spec.rb | 23 ++++++++++++++++ .../canonical_email_blocks_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/admin/dimensions_controller_spec.rb | 23 ++++++++++++++++ .../admin/email_domain_blocks_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/admin/ip_blocks_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/admin/measures_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/admin/retention_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/admin/trends/links_controller_spec.rb | 23 ++++++++++++++++ .../v1/admin/trends/statuses_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/admin/trends/tags_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/directories_controller_spec.rb | 23 ++++++++++++++++ .../featured_tags/suggestions_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/featured_tags_controller_spec.rb | 23 ++++++++++++++++ .../v1/instances/domain_blocks_controller_spec.rb | 16 +++++++++++ .../extended_descriptions_controller_spec.rb | 15 ++++++++++ .../instances/privacy_policies_controller_spec.rb | 15 ++++++++++ .../api/v1/instances/rules_controller_spec.rb | 15 ++++++++++ .../api/v1/preferences_controller_spec.rb | 23 ++++++++++++++++ .../api/v1/scheduled_statuses_controller_spec.rb | 23 ++++++++++++++++ .../v1/statuses/translations_controller_spec.rb | 32 ++++++++++++++++++++++ .../api/v1/trends/links_controller_spec.rb | 15 ++++++++++ .../api/v1/trends/statuses_controller_spec.rb | 15 ++++++++++ 25 files changed, 537 insertions(+) create mode 100644 spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb create mode 100644 spec/controllers/api/v1/accounts/featured_tags_controller_spec.rb create mode 100644 spec/controllers/api/v1/accounts/identity_proofs_controller_spec.rb create mode 100644 spec/controllers/api/v1/accounts/lookup_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/canonical_email_blocks_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/dimensions_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/email_domain_blocks_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/ip_blocks_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/measures_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/retention_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/trends/links_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/trends/statuses_controller_spec.rb create mode 100644 spec/controllers/api/v1/admin/trends/tags_controller_spec.rb create mode 100644 spec/controllers/api/v1/directories_controller_spec.rb create mode 100644 spec/controllers/api/v1/featured_tags/suggestions_controller_spec.rb create mode 100644 spec/controllers/api/v1/featured_tags_controller_spec.rb create mode 100644 spec/controllers/api/v1/instances/domain_blocks_controller_spec.rb create mode 100644 spec/controllers/api/v1/instances/extended_descriptions_controller_spec.rb create mode 100644 spec/controllers/api/v1/instances/privacy_policies_controller_spec.rb create mode 100644 spec/controllers/api/v1/instances/rules_controller_spec.rb create mode 100644 spec/controllers/api/v1/preferences_controller_spec.rb create mode 100644 spec/controllers/api/v1/scheduled_statuses_controller_spec.rb create mode 100644 spec/controllers/api/v1/statuses/translations_controller_spec.rb create mode 100644 spec/controllers/api/v1/trends/links_controller_spec.rb create mode 100644 spec/controllers/api/v1/trends/statuses_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb b/spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb new file mode 100644 index 000000000..bb075261f --- /dev/null +++ b/spec/controllers/api/v1/accounts/familiar_followers_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Accounts::FamiliarFollowersController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/accounts/featured_tags_controller_spec.rb b/spec/controllers/api/v1/accounts/featured_tags_controller_spec.rb new file mode 100644 index 000000000..53ac1e2a7 --- /dev/null +++ b/spec/controllers/api/v1/accounts/featured_tags_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Accounts::FeaturedTagsController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/accounts/identity_proofs_controller_spec.rb b/spec/controllers/api/v1/accounts/identity_proofs_controller_spec.rb new file mode 100644 index 000000000..6351de761 --- /dev/null +++ b/spec/controllers/api/v1/accounts/identity_proofs_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Accounts::IdentityProofsController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/accounts/lookup_controller_spec.rb b/spec/controllers/api/v1/accounts/lookup_controller_spec.rb new file mode 100644 index 000000000..37407766f --- /dev/null +++ b/spec/controllers/api/v1/accounts/lookup_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Accounts::LookupController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #show' do + it 'returns http success' do + get :show, params: { account_id: account.id, acct: account.acct } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/canonical_email_blocks_controller_spec.rb b/spec/controllers/api/v1/admin/canonical_email_blocks_controller_spec.rb new file mode 100644 index 000000000..3acae843a --- /dev/null +++ b/spec/controllers/api/v1/admin/canonical_email_blocks_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::CanonicalEmailBlocksController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/dimensions_controller_spec.rb b/spec/controllers/api/v1/admin/dimensions_controller_spec.rb new file mode 100644 index 000000000..ea18efe38 --- /dev/null +++ b/spec/controllers/api/v1/admin/dimensions_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::DimensionsController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + it 'returns http success' do + post :create, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/email_domain_blocks_controller_spec.rb b/spec/controllers/api/v1/admin/email_domain_blocks_controller_spec.rb new file mode 100644 index 000000000..a92a29869 --- /dev/null +++ b/spec/controllers/api/v1/admin/email_domain_blocks_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::EmailDomainBlocksController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/ip_blocks_controller_spec.rb b/spec/controllers/api/v1/admin/ip_blocks_controller_spec.rb new file mode 100644 index 000000000..50e2ae968 --- /dev/null +++ b/spec/controllers/api/v1/admin/ip_blocks_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::IpBlocksController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/measures_controller_spec.rb b/spec/controllers/api/v1/admin/measures_controller_spec.rb new file mode 100644 index 000000000..03727a632 --- /dev/null +++ b/spec/controllers/api/v1/admin/measures_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::MeasuresController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + it 'returns http success' do + post :create, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/retention_controller_spec.rb b/spec/controllers/api/v1/admin/retention_controller_spec.rb new file mode 100644 index 000000000..2381dbcb4 --- /dev/null +++ b/spec/controllers/api/v1/admin/retention_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::RetentionController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + it 'returns http success' do + post :create, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/trends/links_controller_spec.rb b/spec/controllers/api/v1/admin/trends/links_controller_spec.rb new file mode 100644 index 000000000..a64292f06 --- /dev/null +++ b/spec/controllers/api/v1/admin/trends/links_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::Trends::LinksController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/trends/statuses_controller_spec.rb b/spec/controllers/api/v1/admin/trends/statuses_controller_spec.rb new file mode 100644 index 000000000..821cc499f --- /dev/null +++ b/spec/controllers/api/v1/admin/trends/statuses_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::Trends::StatusesController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/admin/trends/tags_controller_spec.rb b/spec/controllers/api/v1/admin/trends/tags_controller_spec.rb new file mode 100644 index 000000000..480306ce7 --- /dev/null +++ b/spec/controllers/api/v1/admin/trends/tags_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Admin::Trends::TagsController do + render_views + + let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/directories_controller_spec.rb b/spec/controllers/api/v1/directories_controller_spec.rb new file mode 100644 index 000000000..b18aedc4d --- /dev/null +++ b/spec/controllers/api/v1/directories_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::DirectoriesController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #show' do + it 'returns http success' do + get :show + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/featured_tags/suggestions_controller_spec.rb b/spec/controllers/api/v1/featured_tags/suggestions_controller_spec.rb new file mode 100644 index 000000000..54c63dcc6 --- /dev/null +++ b/spec/controllers/api/v1/featured_tags/suggestions_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::FeaturedTags::SuggestionsController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/featured_tags_controller_spec.rb b/spec/controllers/api/v1/featured_tags_controller_spec.rb new file mode 100644 index 000000000..aac942901 --- /dev/null +++ b/spec/controllers/api/v1/featured_tags_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::FeaturedTagsController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index, params: { account_id: account.id, limit: 2 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/instances/domain_blocks_controller_spec.rb b/spec/controllers/api/v1/instances/domain_blocks_controller_spec.rb new file mode 100644 index 000000000..08f505c3d --- /dev/null +++ b/spec/controllers/api/v1/instances/domain_blocks_controller_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Instances::DomainBlocksController do + render_views + + describe 'GET #index' do + it 'returns http success' do + Setting.show_domain_blocks = 'all' + get :index + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/instances/extended_descriptions_controller_spec.rb b/spec/controllers/api/v1/instances/extended_descriptions_controller_spec.rb new file mode 100644 index 000000000..58c0d4b8f --- /dev/null +++ b/spec/controllers/api/v1/instances/extended_descriptions_controller_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Instances::ExtendedDescriptionsController do + render_views + + describe 'GET #show' do + it 'returns http success' do + get :show + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/instances/privacy_policies_controller_spec.rb b/spec/controllers/api/v1/instances/privacy_policies_controller_spec.rb new file mode 100644 index 000000000..ac0bed9dc --- /dev/null +++ b/spec/controllers/api/v1/instances/privacy_policies_controller_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Instances::PrivacyPoliciesController do + render_views + + describe 'GET #show' do + it 'returns http success' do + get :show + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/instances/rules_controller_spec.rb b/spec/controllers/api/v1/instances/rules_controller_spec.rb new file mode 100644 index 000000000..5af50239b --- /dev/null +++ b/spec/controllers/api/v1/instances/rules_controller_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Instances::RulesController do + render_views + + describe 'GET #index' do + it 'returns http success' do + get :index + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/preferences_controller_spec.rb b/spec/controllers/api/v1/preferences_controller_spec.rb new file mode 100644 index 000000000..79cc3066e --- /dev/null +++ b/spec/controllers/api/v1/preferences_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::PreferencesController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/scheduled_statuses_controller_spec.rb b/spec/controllers/api/v1/scheduled_statuses_controller_spec.rb new file mode 100644 index 000000000..256c4b272 --- /dev/null +++ b/spec/controllers/api/v1/scheduled_statuses_controller_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::ScheduledStatusesController do + render_views + + let(:user) { Fabricate(:user) } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses') } + let(:account) { Fabricate(:account) } + + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'GET #index' do + it 'returns http success' do + get :index + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/statuses/translations_controller_spec.rb b/spec/controllers/api/v1/statuses/translations_controller_spec.rb new file mode 100644 index 000000000..9575ac448 --- /dev/null +++ b/spec/controllers/api/v1/statuses/translations_controller_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Statuses::TranslationsController do + render_views + + let(:user) { Fabricate(:user) } + let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') } + let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses', application: app) } + + context 'with an oauth token' do + before do + allow(controller).to receive(:doorkeeper_token) { token } + end + + describe 'POST #create' do + let(:status) { Fabricate(:status, account: user.account) } + + before do + translation = TranslationService::Translation.new(text: 'Hello') + service = instance_double(TranslationService::DeepL, translate: translation) + allow(TranslationService).to receive(:configured).and_return(service) + post :create, params: { status_id: status.id } + end + + it 'returns http success' do + expect(response).to have_http_status(200) + end + end + end +end diff --git a/spec/controllers/api/v1/trends/links_controller_spec.rb b/spec/controllers/api/v1/trends/links_controller_spec.rb new file mode 100644 index 000000000..71a7e2e47 --- /dev/null +++ b/spec/controllers/api/v1/trends/links_controller_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Trends::LinksController do + render_views + + describe 'GET #index' do + it 'returns http success' do + get :index + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/api/v1/trends/statuses_controller_spec.rb b/spec/controllers/api/v1/trends/statuses_controller_spec.rb new file mode 100644 index 000000000..e9892bb14 --- /dev/null +++ b/spec/controllers/api/v1/trends/statuses_controller_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Trends::StatusesController do + render_views + + describe 'GET #index' do + it 'returns http success' do + get :index + + expect(response).to have_http_status(200) + end + end +end -- cgit From c599e289d806f6d13e3383879750db053a654821 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 4 Mar 2023 17:17:46 -0500 Subject: Fix spec for api/v1/statuses/translations (#23956) --- spec/controllers/api/v1/statuses/translations_controller_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/statuses/translations_controller_spec.rb b/spec/controllers/api/v1/statuses/translations_controller_spec.rb index 9575ac448..2deea9fc0 100644 --- a/spec/controllers/api/v1/statuses/translations_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/translations_controller_spec.rb @@ -15,11 +15,12 @@ describe Api::V1::Statuses::TranslationsController do end describe 'POST #create' do - let(:status) { Fabricate(:status, account: user.account) } + let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') } before do translation = TranslationService::Translation.new(text: 'Hello') - service = instance_double(TranslationService::DeepL, translate: translation) + service = instance_double(TranslationService::DeepL, translate: translation, supported?: true) + allow(TranslationService).to receive(:configured?).and_return(true) allow(TranslationService).to receive(:configured).and_return(service) post :create, params: { status_id: status.id } end -- cgit From bd047acc356671727c112336bb237f979bba517d Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Thu, 16 Mar 2023 11:07:24 +0100 Subject: Replace `Status#translatable?` with language matrix in separate endpoint (#24037) --- .rubocop_todo.yml | 1 - .../instances/translation_languages_controller.rb | 23 +++++++ app/javascript/mastodon/actions/server.js | 27 ++++++++ .../mastodon/components/status_content.jsx | 13 +++- app/javascript/mastodon/features/ui/index.jsx | 3 +- app/javascript/mastodon/reducers/server.js | 9 +++ app/lib/translation_service.rb | 4 +- app/lib/translation_service/deepl.rb | 30 ++++---- app/lib/translation_service/libre_translate.rb | 18 ++--- app/models/status.rb | 10 --- app/serializers/rest/status_serializer.rb | 6 +- app/services/translate_status_service.rb | 16 ++++- config/routes.rb | 1 + .../translation_languages_controller_spec.rb | 31 +++++++++ .../v1/statuses/translations_controller_spec.rb | 3 +- spec/lib/translation_service/deepl_spec.rb | 36 +++------- .../translation_service/libre_translate_spec.rb | 31 ++------- spec/models/status_spec.rb | 79 ---------------------- spec/presenters/instance_presenter_spec.rb | 2 +- 19 files changed, 164 insertions(+), 179 deletions(-) create mode 100644 app/controllers/api/v1/instances/translation_languages_controller.rb create mode 100644 spec/controllers/api/v1/instances/translation_languages_controller_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e79f4f8e9..85f078dcf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -484,7 +484,6 @@ RSpec/DescribedClass: - 'spec/models/user_spec.rb' - 'spec/policies/account_moderation_note_policy_spec.rb' - 'spec/presenters/account_relationships_presenter_spec.rb' - - 'spec/presenters/instance_presenter_spec.rb' - 'spec/presenters/status_relationships_presenter_spec.rb' - 'spec/serializers/activitypub/note_serializer_spec.rb' - 'spec/serializers/activitypub/update_poll_serializer_spec.rb' diff --git a/app/controllers/api/v1/instances/translation_languages_controller.rb b/app/controllers/api/v1/instances/translation_languages_controller.rb new file mode 100644 index 000000000..3910a499e --- /dev/null +++ b/app/controllers/api/v1/instances/translation_languages_controller.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class Api::V1::Instances::TranslationLanguagesController < Api::BaseController + skip_before_action :require_authenticated_user!, unless: :whitelist_mode? + + before_action :set_languages + + def show + expires_in 1.day, public: true + render json: @languages + end + + private + + def set_languages + if TranslationService.configured? + @languages = Rails.cache.fetch('translation_service/languages', expires_in: 7.days, race_condition_ttl: 1.hour) { TranslationService.configured.languages } + @languages['und'] = @languages.delete(nil) if @languages.key?(nil) + else + @languages = {} + end + end +end diff --git a/app/javascript/mastodon/actions/server.js b/app/javascript/mastodon/actions/server.js index 31d4aea10..091af0f0f 100644 --- a/app/javascript/mastodon/actions/server.js +++ b/app/javascript/mastodon/actions/server.js @@ -5,6 +5,10 @@ export const SERVER_FETCH_REQUEST = 'Server_FETCH_REQUEST'; export const SERVER_FETCH_SUCCESS = 'Server_FETCH_SUCCESS'; export const SERVER_FETCH_FAIL = 'Server_FETCH_FAIL'; +export const SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST = 'SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST'; +export const SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS = 'SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS'; +export const SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL = 'SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL'; + export const EXTENDED_DESCRIPTION_REQUEST = 'EXTENDED_DESCRIPTION_REQUEST'; export const EXTENDED_DESCRIPTION_SUCCESS = 'EXTENDED_DESCRIPTION_SUCCESS'; export const EXTENDED_DESCRIPTION_FAIL = 'EXTENDED_DESCRIPTION_FAIL'; @@ -37,6 +41,29 @@ const fetchServerFail = error => ({ error, }); +export const fetchServerTranslationLanguages = () => (dispatch, getState) => { + dispatch(fetchServerTranslationLanguagesRequest()); + + api(getState) + .get('/api/v1/instance/translation_languages').then(({ data }) => { + dispatch(fetchServerTranslationLanguagesSuccess(data)); + }).catch(err => dispatch(fetchServerTranslationLanguagesFail(err))); +}; + +const fetchServerTranslationLanguagesRequest = () => ({ + type: SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST, +}); + +const fetchServerTranslationLanguagesSuccess = translationLanguages => ({ + type: SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS, + translationLanguages, +}); + +const fetchServerTranslationLanguagesFail = error => ({ + type: SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL, + error, +}); + export const fetchExtendedDescription = () => (dispatch, getState) => { dispatch(fetchExtendedDescriptionRequest()); diff --git a/app/javascript/mastodon/components/status_content.jsx b/app/javascript/mastodon/components/status_content.jsx index f9c9fe079..67a487b00 100644 --- a/app/javascript/mastodon/components/status_content.jsx +++ b/app/javascript/mastodon/components/status_content.jsx @@ -3,6 +3,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import { FormattedMessage, injectIntl } from 'react-intl'; import { Link } from 'react-router-dom'; +import { connect } from 'react-redux'; import classnames from 'classnames'; import PollContainer from 'mastodon/containers/poll_container'; import Icon from 'mastodon/components/icon'; @@ -47,7 +48,12 @@ class TranslateButton extends React.PureComponent { } -export default @injectIntl +const mapStateToProps = state => ({ + languages: state.getIn(['server', 'translationLanguages', 'items']), +}); + +export default @connect(mapStateToProps) +@injectIntl class StatusContent extends React.PureComponent { static contextTypes = { @@ -63,6 +69,7 @@ class StatusContent extends React.PureComponent { onClick: PropTypes.func, collapsable: PropTypes.bool, onCollapsedToggle: PropTypes.func, + languages: ImmutablePropTypes.map, intl: PropTypes.object, }; @@ -220,7 +227,9 @@ class StatusContent extends React.PureComponent { const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden; const renderReadMore = this.props.onClick && status.get('collapsed'); - const renderTranslate = this.props.onTranslate && status.get('translatable'); + const contentLocale = intl.locale.replace(/[_-].*/, ''); + const targetLanguages = this.props.languages?.get(status.get('language') || 'und'); + const renderTranslate = this.props.onTranslate && this.context.identity.signedIn && ['public', 'unlisted'].includes(status.get('visibility')) && status.get('contentHtml').length > 0 && targetLanguages?.includes(contentLocale); const content = { __html: status.get('translation') ? status.getIn(['translation', 'content']) : status.get('contentHtml') }; const spoilerContent = { __html: status.get('spoilerHtml') }; diff --git a/app/javascript/mastodon/features/ui/index.jsx b/app/javascript/mastodon/features/ui/index.jsx index 2dd59f95d..083707220 100644 --- a/app/javascript/mastodon/features/ui/index.jsx +++ b/app/javascript/mastodon/features/ui/index.jsx @@ -13,7 +13,7 @@ import { debounce } from 'lodash'; import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose'; import { expandHomeTimeline } from '../../actions/timelines'; import { expandNotifications } from '../../actions/notifications'; -import { fetchServer } from '../../actions/server'; +import { fetchServer, fetchServerTranslationLanguages } from '../../actions/server'; import { clearHeight } from '../../actions/height_cache'; import { focusApp, unfocusApp, changeLayout } from 'mastodon/actions/app'; import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'mastodon/actions/markers'; @@ -399,6 +399,7 @@ class UI extends React.PureComponent { this.props.dispatch(fetchMarkers()); this.props.dispatch(expandHomeTimeline()); this.props.dispatch(expandNotifications()); + this.props.dispatch(fetchServerTranslationLanguages()); setTimeout(() => this.props.dispatch(fetchServer()), 3000); } diff --git a/app/javascript/mastodon/reducers/server.js b/app/javascript/mastodon/reducers/server.js index db9f2b5e6..909ab2a66 100644 --- a/app/javascript/mastodon/reducers/server.js +++ b/app/javascript/mastodon/reducers/server.js @@ -2,6 +2,9 @@ import { SERVER_FETCH_REQUEST, SERVER_FETCH_SUCCESS, SERVER_FETCH_FAIL, + SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST, + SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS, + SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL, EXTENDED_DESCRIPTION_REQUEST, EXTENDED_DESCRIPTION_SUCCESS, EXTENDED_DESCRIPTION_FAIL, @@ -35,6 +38,12 @@ export default function server(state = initialState, action) { return state.set('server', fromJS(action.server)).setIn(['server', 'isLoading'], false); case SERVER_FETCH_FAIL: return state.setIn(['server', 'isLoading'], false); + case SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST: + return state.setIn(['translationLanguages', 'isLoading'], true); + case SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS: + return state.setIn(['translationLanguages', 'items'], fromJS(action.translationLanguages)).setIn(['translationLanguages', 'isLoading'], false); + case SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL: + return state.setIn(['translationLanguages', 'isLoading'], false); case EXTENDED_DESCRIPTION_REQUEST: return state.setIn(['extendedDescription', 'isLoading'], true); case EXTENDED_DESCRIPTION_SUCCESS: diff --git a/app/lib/translation_service.rb b/app/lib/translation_service.rb index 5ff93674a..bfe5de44f 100644 --- a/app/lib/translation_service.rb +++ b/app/lib/translation_service.rb @@ -21,8 +21,8 @@ class TranslationService ENV['DEEPL_API_KEY'].present? || ENV['LIBRE_TRANSLATE_ENDPOINT'].present? end - def supported?(_source_language, _target_language) - false + def languages + {} end def translate(_text, _source_language, _target_language) diff --git a/app/lib/translation_service/deepl.rb b/app/lib/translation_service/deepl.rb index deff95a1d..afcb7ecb2 100644 --- a/app/lib/translation_service/deepl.rb +++ b/app/lib/translation_service/deepl.rb @@ -17,25 +17,31 @@ class TranslationService::DeepL < TranslationService end end - def supported?(source_language, target_language) - source_language.in?(languages('source')) && target_language.in?(languages('target')) + def languages + source_languages = [nil] + fetch_languages('source') + + # In DeepL, EN and PT are deprecated in favor of EN-GB/EN-US and PT-BR/PT-PT, so + # they are supported but not returned by the API. + target_languages = %w(en pt) + fetch_languages('target') + + source_languages.index_with { |language| target_languages.without(nil, language) } end private - def languages(type) - Rails.cache.fetch("translation_service/deepl/languages/#{type}", expires_in: 7.days, race_condition_ttl: 1.minute) do - request(:get, "/v2/languages?type=#{type}") do |res| - # In DeepL, EN and PT are deprecated in favor of EN-GB/EN-US and PT-BR/PT-PT, so - # they are supported but not returned by the API. - extra = type == 'source' ? [nil] : %w(en pt) - languages = Oj.load(res.body_with_limit).map { |language| language['language'].downcase } - - languages + extra - end + def fetch_languages(type) + request(:get, "/v2/languages?type=#{type}") do |res| + Oj.load(res.body_with_limit).map { |language| normalize_language(language['language']) } end end + def normalize_language(language) + subtags = language.split(/[_-]/) + subtags[0].downcase! + subtags[1]&.upcase! + subtags.join('-') + end + def request(verb, path, **options) req = Request.new(verb, "#{base_url}#{path}", **options) req.add_headers(Authorization: "DeepL-Auth-Key #{@api_key}") diff --git a/app/lib/translation_service/libre_translate.rb b/app/lib/translation_service/libre_translate.rb index 743e4d77f..8bb194a9c 100644 --- a/app/lib/translation_service/libre_translate.rb +++ b/app/lib/translation_service/libre_translate.rb @@ -15,22 +15,18 @@ class TranslationService::LibreTranslate < TranslationService end end - def supported?(source_language, target_language) - languages.key?(source_language) && languages[source_language].include?(target_language) - end - - private - def languages - Rails.cache.fetch('translation_service/libre_translate/languages', expires_in: 7.days, race_condition_ttl: 1.minute) do - request(:get, '/languages') do |res| - languages = Oj.load(res.body_with_limit).to_h { |language| [language['code'], language['targets']] } - languages[nil] = languages.values.flatten.uniq - languages + request(:get, '/languages') do |res| + languages = Oj.load(res.body_with_limit).to_h do |language| + [language['code'], language['targets'].without(language['code'])] end + languages[nil] = languages.values.flatten.uniq.sort + languages end end + private + def request(verb, path, **options) req = Request.new(verb, "#{@base_url}#{path}", allow_local: true, **options) req.add_headers('Content-Type': 'application/json') diff --git a/app/models/status.rb b/app/models/status.rb index dd7ac2edb..e7ea191a8 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -232,16 +232,6 @@ class Status < ApplicationRecord public_visibility? || unlisted_visibility? end - def translatable? - translate_target_locale = I18n.locale.to_s.split(/[_-]/).first - - distributable? && - content.present? && - language != translate_target_locale && - TranslationService.configured? && - TranslationService.configured.supported?(language, translate_target_locale) - end - alias sign? distributable? def with_media? diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index a422f5b25..e0b8f32a6 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -4,7 +4,7 @@ class REST::StatusSerializer < ActiveModel::Serializer include FormattingHelper attributes :id, :created_at, :in_reply_to_id, :in_reply_to_account_id, - :sensitive, :spoiler_text, :visibility, :language, :translatable, + :sensitive, :spoiler_text, :visibility, :language, :uri, :url, :replies_count, :reblogs_count, :favourites_count, :edited_at @@ -50,10 +50,6 @@ class REST::StatusSerializer < ActiveModel::Serializer object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id) end - def translatable - current_user? && object.translatable? - end - def visibility # This visibility is masked behind "private" # to avoid API changes because there are no diff --git a/app/services/translate_status_service.rb b/app/services/translate_status_service.rb index 92d8b62a0..796f13a0d 100644 --- a/app/services/translate_status_service.rb +++ b/app/services/translate_status_service.rb @@ -6,19 +6,29 @@ class TranslateStatusService < BaseService include FormattingHelper def call(status, target_language) - raise Mastodon::NotPermittedError unless status.translatable? - @status = status @content = status_content_format(@status) @target_language = target_language + raise Mastodon::NotPermittedError unless permitted? + Rails.cache.fetch("translations/#{@status.language}/#{@target_language}/#{content_hash}", expires_in: CACHE_TTL) { translation_backend.translate(@content, @status.language, @target_language) } end private def translation_backend - TranslationService.configured + @translation_backend ||= TranslationService.configured + end + + def permitted? + return false unless @status.distributable? && @status.content.present? && TranslationService.configured? + + languages[@status.language]&.include?(@target_language) + end + + def languages + Rails.cache.fetch('translation_service/languages', expires_in: 7.days, race_condition_ttl: 1.hour) { TranslationService.configured.languages } end def content_hash diff --git a/config/routes.rb b/config/routes.rb index 530b46a5a..ea595e1e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -546,6 +546,7 @@ Rails.application.routes.draw do resources :domain_blocks, only: [:index], controller: 'instances/domain_blocks' resource :privacy_policy, only: [:show], controller: 'instances/privacy_policies' resource :extended_description, only: [:show], controller: 'instances/extended_descriptions' + resource :translation_languages, only: [:show], controller: 'instances/translation_languages' resource :activity, only: [:show], controller: 'instances/activity' end diff --git a/spec/controllers/api/v1/instances/translation_languages_controller_spec.rb b/spec/controllers/api/v1/instances/translation_languages_controller_spec.rb new file mode 100644 index 000000000..5b7e4abb6 --- /dev/null +++ b/spec/controllers/api/v1/instances/translation_languages_controller_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Api::V1::Instances::TranslationLanguagesController do + describe 'GET #show' do + context 'when no translation service is configured' do + it 'returns empty language matrix' do + get :show + + expect(response).to have_http_status(200) + expect(body_as_json).to eq({}) + end + end + + context 'when a translation service is configured' do + before do + service = instance_double(TranslationService::DeepL, languages: { nil => %w(en de), 'en' => ['de'] }) + allow(TranslationService).to receive(:configured?).and_return(true) + allow(TranslationService).to receive(:configured).and_return(service) + end + + it 'returns language matrix' do + get :show + + expect(response).to have_http_status(200) + expect(body_as_json).to eq({ und: %w(en de), en: ['de'] }) + end + end + end +end diff --git a/spec/controllers/api/v1/statuses/translations_controller_spec.rb b/spec/controllers/api/v1/statuses/translations_controller_spec.rb index 2deea9fc0..8495779bf 100644 --- a/spec/controllers/api/v1/statuses/translations_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/translations_controller_spec.rb @@ -19,9 +19,10 @@ describe Api::V1::Statuses::TranslationsController do before do translation = TranslationService::Translation.new(text: 'Hello') - service = instance_double(TranslationService::DeepL, translate: translation, supported?: true) + service = instance_double(TranslationService::DeepL, translate: translation) allow(TranslationService).to receive(:configured?).and_return(true) allow(TranslationService).to receive(:configured).and_return(service) + Rails.cache.write('translation_service/languages', { 'es' => ['en'] }) post :create, params: { status_id: status.id } end diff --git a/spec/lib/translation_service/deepl_spec.rb b/spec/lib/translation_service/deepl_spec.rb index aa2473186..2363f8f13 100644 --- a/spec/lib/translation_service/deepl_spec.rb +++ b/spec/lib/translation_service/deepl_spec.rb @@ -16,29 +16,6 @@ RSpec.describe TranslationService::DeepL do ) end - describe '#supported?' do - it 'supports included languages as source and target languages' do - expect(service.supported?('uk', 'en')).to be true - end - - it 'supports auto-detecting source language' do - expect(service.supported?(nil, 'en')).to be true - end - - it 'supports "en" and "pt" as target languages though not included in language list' do - expect(service.supported?('uk', 'en')).to be true - expect(service.supported?('uk', 'pt')).to be true - end - - it 'does not support non-included language as target language' do - expect(service.supported?('uk', 'nl')).to be false - end - - it 'does not support non-included language as source language' do - expect(service.supported?('da', 'en')).to be false - end - end - describe '#translate' do it 'returns translation with specified source language' do stub_request(:post, 'https://api.deepl.com/v2/translate') @@ -63,13 +40,18 @@ RSpec.describe TranslationService::DeepL do end end - describe '#languages?' do + describe '#languages' do it 'returns source languages' do - expect(service.send(:languages, 'source')).to eq ['en', 'uk', nil] + expect(service.languages.keys).to eq [nil, 'en', 'uk'] + end + + it 'returns target languages for each source language' do + expect(service.languages['en']).to eq %w(pt en-GB zh) + expect(service.languages['uk']).to eq %w(en pt en-GB zh) end - it 'returns target languages' do - expect(service.send(:languages, 'target')).to eq %w(en-gb zh en pt) + it 'returns target languages for auto-detection' do + expect(service.languages[nil]).to eq %w(en pt en-GB zh) end end diff --git a/spec/lib/translation_service/libre_translate_spec.rb b/spec/lib/translation_service/libre_translate_spec.rb index a6cb01884..fbd726a7e 100644 --- a/spec/lib/translation_service/libre_translate_spec.rb +++ b/spec/lib/translation_service/libre_translate_spec.rb @@ -7,41 +7,24 @@ RSpec.describe TranslationService::LibreTranslate do before do stub_request(:get, 'https://libretranslate.example.com/languages').to_return( - body: '[{"code": "en","name": "English","targets": ["de","es"]},{"code": "da","name": "Danish","targets": ["en","de"]}]' + body: '[{"code": "en","name": "English","targets": ["de","en","es"]},{"code": "da","name": "Danish","targets": ["en","pt"]}]' ) end - describe '#supported?' do - it 'supports included language pair' do - expect(service.supported?('en', 'de')).to be true - end - - it 'does not support reversed language pair' do - expect(service.supported?('de', 'en')).to be false - end - - it 'supports auto-detecting source language' do - expect(service.supported?(nil, 'de')).to be true - end - - it 'does not support auto-detecting for unsupported target language' do - expect(service.supported?(nil, 'pt')).to be false - end - end - describe '#languages' do - subject(:languages) { service.send(:languages) } + subject(:languages) { service.languages } - it 'includes supported source languages' do + it 'returns source languages' do expect(languages.keys).to eq ['en', 'da', nil] end - it 'includes supported target languages for source language' do + it 'returns target languages for each source language' do expect(languages['en']).to eq %w(de es) + expect(languages['da']).to eq %w(en pt) end - it 'includes supported target languages for auto-detected language' do - expect(languages[nil]).to eq %w(de es en) + it 'returns target languages for auto-detected language' do + expect(languages[nil]).to eq %w(de en es pt) end end diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 1f6cfc796..1e58c6d0d 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -114,85 +114,6 @@ RSpec.describe Status, type: :model do end end - describe '#translatable?' do - before do - allow(TranslationService).to receive(:configured?).and_return(true) - allow(TranslationService).to receive(:configured).and_return(TranslationService.new) - allow(TranslationService.configured).to receive(:supported?).with('es', 'en').and_return(true) - - subject.language = 'es' - subject.visibility = :public - end - - context 'all conditions are satisfied' do - it 'returns true' do - expect(subject.translatable?).to be true - end - end - - context 'translation service is not configured' do - it 'returns false' do - allow(TranslationService).to receive(:configured?).and_return(false) - allow(TranslationService).to receive(:configured).and_raise(TranslationService::NotConfiguredError) - expect(subject.translatable?).to be false - end - end - - context 'status language is nil' do - it 'returns true' do - subject.language = nil - allow(TranslationService.configured).to receive(:supported?).with(nil, 'en').and_return(true) - expect(subject.translatable?).to be true - end - end - - context 'status language is same as default locale' do - it 'returns false' do - subject.language = I18n.locale - expect(subject.translatable?).to be false - end - end - - context 'status language is unsupported' do - it 'returns false' do - subject.language = 'af' - allow(TranslationService.configured).to receive(:supported?).with('af', 'en').and_return(false) - expect(subject.translatable?).to be false - end - end - - context 'default locale is unsupported' do - it 'returns false' do - allow(TranslationService.configured).to receive(:supported?).with('es', 'af').and_return(false) - I18n.with_locale('af') do - expect(subject.translatable?).to be false - end - end - end - - context 'default locale has region' do - it 'returns true' do - I18n.with_locale('en-GB') do - expect(subject.translatable?).to be true - end - end - end - - context 'status text is blank' do - it 'returns false' do - subject.text = ' ' - expect(subject.translatable?).to be false - end - end - - context 'status visiblity is hidden' do - it 'returns false' do - subject.visibility = 'limited' - expect(subject.translatable?).to be false - end - end - end - describe '#content' do it 'returns the text of the status if it is not a reblog' do expect(subject.content).to eql subject.text diff --git a/spec/presenters/instance_presenter_spec.rb b/spec/presenters/instance_presenter_spec.rb index 795abd8b4..2a1d668ce 100644 --- a/spec/presenters/instance_presenter_spec.rb +++ b/spec/presenters/instance_presenter_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe InstancePresenter do - let(:instance_presenter) { InstancePresenter.new } + let(:instance_presenter) { described_class.new } describe '#description' do around do |example| -- cgit From a9b5598c97fc4d3302b61b260097ef41c2ebe377 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 30 Mar 2023 14:44:00 +0200 Subject: Change user settings to be stored in a more optimal way (#23630) Co-authored-by: Claire --- .rubocop.yml | 8 ++ .rubocop_todo.yml | 1 + .../api/v1/accounts/credentials_controller.rb | 12 +- app/controllers/settings/preferences_controller.rb | 40 +----- app/lib/user_settings_decorator.rb | 155 --------------------- app/lib/user_settings_serializer.rb | 19 +++ app/models/concerns/has_user_settings.rb | 141 +++++++++++++++++++ app/models/user.rb | 59 +------- app/models/user_settings.rb | 99 +++++++++++++ app/models/user_settings/dsl.rb | 37 +++++ app/models/user_settings/glue.rb | 23 +++ app/models/user_settings/namespace.rb | 21 +++ app/models/user_settings/setting.rb | 48 +++++++ app/services/notify_service.rb | 13 +- .../settings/preferences/appearance/show.html.haml | 65 ++++----- .../preferences/notifications/show.html.haml | 36 ++--- .../settings/preferences/other/show.html.haml | 29 ++-- config/initializers/inflections.rb | 1 + config/settings.yml | 34 ----- db/migrate/20230215074327_add_settings_to_users.rb | 7 + db/migrate/20230215074423_move_user_settings.rb | 84 +++++++++++ db/schema.rb | 3 +- lib/tasks/tests.rake | 2 +- .../api/v1/accounts/credentials_controller_spec.rb | 1 + spec/controllers/application_controller_spec.rb | 10 +- .../preferences/notifications_controller_spec.rb | 14 +- .../settings/preferences/other_controller_spec.rb | 14 +- spec/lib/settings/extend_spec.rb | 16 --- spec/lib/settings/scoped_settings_spec.rb | 35 ----- spec/lib/user_settings_decorator_spec.rb | 84 ----------- spec/models/user_settings/namespace_spec.rb | 25 ++++ spec/models/user_settings/setting_spec.rb | 74 ++++++++++ spec/models/user_settings_spec.rb | 110 +++++++++++++++ spec/models/user_spec.rb | 14 +- spec/services/notify_service_spec.rb | 7 +- spec/services/report_service_spec.rb | 3 +- 36 files changed, 818 insertions(+), 526 deletions(-) delete mode 100644 app/lib/user_settings_decorator.rb create mode 100644 app/lib/user_settings_serializer.rb create mode 100644 app/models/concerns/has_user_settings.rb create mode 100644 app/models/user_settings.rb create mode 100644 app/models/user_settings/dsl.rb create mode 100644 app/models/user_settings/glue.rb create mode 100644 app/models/user_settings/namespace.rb create mode 100644 app/models/user_settings/setting.rb create mode 100644 db/migrate/20230215074327_add_settings_to_users.rb create mode 100644 db/migrate/20230215074423_move_user_settings.rb delete mode 100644 spec/lib/settings/extend_spec.rb delete mode 100644 spec/lib/settings/scoped_settings_spec.rb delete mode 100644 spec/lib/user_settings_decorator_spec.rb create mode 100644 spec/models/user_settings/namespace_spec.rb create mode 100644 spec/models/user_settings/setting_spec.rb create mode 100644 spec/models/user_settings_spec.rb (limited to 'spec/controllers/api/v1') diff --git a/.rubocop.yml b/.rubocop.yml index 1033db92d..b5598b65a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -185,3 +185,11 @@ Style/TrailingCommaInHashLiteral: Style/SymbolArray: Enabled: false + +# Reason: Prefer less intendation in conditional assignments +# https://docs.rubocop.org/rubocop/cops_style.html#styleredundantbegin +Style/RedundantBegin: + Enabled: false + +RSpec/NamedSubject: + EnforcedStyle: named_only diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 64a6b6b33..4ad266c8c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -259,6 +259,7 @@ Metrics/ModuleLength: - 'app/helpers/jsonld_helper.rb' - 'app/helpers/statuses_helper.rb' - 'app/models/concerns/account_interactions.rb' + - 'app/models/concerns/has_user_settings.rb' # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: diff --git a/app/controllers/api/v1/accounts/credentials_controller.rb b/app/controllers/api/v1/accounts/credentials_controller.rb index 94b707771..7c7d70fd3 100644 --- a/app/controllers/api/v1/accounts/credentials_controller.rb +++ b/app/controllers/api/v1/accounts/credentials_controller.rb @@ -13,7 +13,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController def update @account = current_account UpdateAccountService.new.call(@account, account_params, raise_error: true) - UserSettingsDecorator.new(current_user).update(user_settings_params) if user_settings_params + current_user.update(user_params) if user_params ActivityPub::UpdateDistributionWorker.perform_async(@account.id) render json: @account, serializer: REST::CredentialAccountSerializer end @@ -34,15 +34,17 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController ) end - def user_settings_params + def user_params return nil if params[:source].blank? source_params = params.require(:source) { - 'setting_default_privacy' => source_params.fetch(:privacy, @account.user.setting_default_privacy), - 'setting_default_sensitive' => source_params.fetch(:sensitive, @account.user.setting_default_sensitive), - 'setting_default_language' => source_params.fetch(:language, @account.user.setting_default_language), + settings_attributes: { + default_privacy: source_params.fetch(:privacy, @account.user.setting_default_privacy), + default_sensitive: source_params.fetch(:sensitive, @account.user.setting_default_sensitive), + default_language: source_params.fetch(:language, @account.user.setting_default_language), + }, } end end diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index f5d5c1244..281deb64d 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -4,8 +4,6 @@ class Settings::PreferencesController < Settings::BaseController def show; end def update - user_settings.update(user_settings_params.to_h) - if current_user.update(user_params) I18n.locale = current_user.locale redirect_to after_update_redirect_path, notice: I18n.t('generic.changes_saved_msg') @@ -20,43 +18,7 @@ class Settings::PreferencesController < Settings::BaseController settings_preferences_path end - def user_settings - UserSettingsDecorator.new(current_user) - end - def user_params - params.require(:user).permit( - :locale, - chosen_languages: [] - ) - end - - def user_settings_params - params.require(:user).permit( - :setting_default_privacy, - :setting_default_sensitive, - :setting_default_language, - :setting_unfollow_modal, - :setting_boost_modal, - :setting_delete_modal, - :setting_auto_play_gif, - :setting_display_media, - :setting_expand_spoilers, - :setting_reduce_motion, - :setting_disable_swiping, - :setting_system_font_ui, - :setting_noindex, - :setting_theme, - :setting_aggregate_reblogs, - :setting_show_application, - :setting_advanced_layout, - :setting_use_blurhash, - :setting_use_pending_items, - :setting_trends, - :setting_crop_images, - :setting_always_send_emails, - notification_emails: %i(follow follow_request reblog favourite mention report pending_account trending_tag appeal), - interactions: %i(must_be_follower must_be_following must_be_following_dm) - ) + params.require(:user).permit(:locale, chosen_languages: [], settings_attributes: UserSettings.keys) end end diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb deleted file mode 100644 index 5fb7655a9..000000000 --- a/app/lib/user_settings_decorator.rb +++ /dev/null @@ -1,155 +0,0 @@ -# frozen_string_literal: true - -class UserSettingsDecorator - attr_reader :user, :settings - - def initialize(user) - @user = user - end - - def update(settings) - @settings = settings - process_update - end - - private - - def process_update - user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails') - user.settings['interactions'] = merged_interactions if change?('interactions') - user.settings['default_privacy'] = default_privacy_preference if change?('setting_default_privacy') - user.settings['default_sensitive'] = default_sensitive_preference if change?('setting_default_sensitive') - user.settings['default_language'] = default_language_preference if change?('setting_default_language') - user.settings['unfollow_modal'] = unfollow_modal_preference if change?('setting_unfollow_modal') - user.settings['boost_modal'] = boost_modal_preference if change?('setting_boost_modal') - user.settings['delete_modal'] = delete_modal_preference if change?('setting_delete_modal') - user.settings['auto_play_gif'] = auto_play_gif_preference if change?('setting_auto_play_gif') - user.settings['display_media'] = display_media_preference if change?('setting_display_media') - user.settings['expand_spoilers'] = expand_spoilers_preference if change?('setting_expand_spoilers') - user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion') - user.settings['disable_swiping'] = disable_swiping_preference if change?('setting_disable_swiping') - user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui') - user.settings['noindex'] = noindex_preference if change?('setting_noindex') - user.settings['theme'] = theme_preference if change?('setting_theme') - user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs') - user.settings['show_application'] = show_application_preference if change?('setting_show_application') - user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout') - user.settings['use_blurhash'] = use_blurhash_preference if change?('setting_use_blurhash') - user.settings['use_pending_items'] = use_pending_items_preference if change?('setting_use_pending_items') - user.settings['trends'] = trends_preference if change?('setting_trends') - user.settings['crop_images'] = crop_images_preference if change?('setting_crop_images') - user.settings['always_send_emails'] = always_send_emails_preference if change?('setting_always_send_emails') - end - - def merged_notification_emails - user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h - end - - def merged_interactions - user.settings['interactions'].merge coerced_settings('interactions').to_h - end - - def default_privacy_preference - settings['setting_default_privacy'] - end - - def default_sensitive_preference - boolean_cast_setting 'setting_default_sensitive' - end - - def unfollow_modal_preference - boolean_cast_setting 'setting_unfollow_modal' - end - - def boost_modal_preference - boolean_cast_setting 'setting_boost_modal' - end - - def delete_modal_preference - boolean_cast_setting 'setting_delete_modal' - end - - def system_font_ui_preference - boolean_cast_setting 'setting_system_font_ui' - end - - def auto_play_gif_preference - boolean_cast_setting 'setting_auto_play_gif' - end - - def display_media_preference - settings['setting_display_media'] - end - - def expand_spoilers_preference - boolean_cast_setting 'setting_expand_spoilers' - end - - def reduce_motion_preference - boolean_cast_setting 'setting_reduce_motion' - end - - def disable_swiping_preference - boolean_cast_setting 'setting_disable_swiping' - end - - def noindex_preference - boolean_cast_setting 'setting_noindex' - end - - def show_application_preference - boolean_cast_setting 'setting_show_application' - end - - def theme_preference - settings['setting_theme'] - end - - def default_language_preference - settings['setting_default_language'] - end - - def aggregate_reblogs_preference - boolean_cast_setting 'setting_aggregate_reblogs' - end - - def advanced_layout_preference - boolean_cast_setting 'setting_advanced_layout' - end - - def use_blurhash_preference - boolean_cast_setting 'setting_use_blurhash' - end - - def use_pending_items_preference - boolean_cast_setting 'setting_use_pending_items' - end - - def trends_preference - boolean_cast_setting 'setting_trends' - end - - def crop_images_preference - boolean_cast_setting 'setting_crop_images' - end - - def always_send_emails_preference - boolean_cast_setting 'setting_always_send_emails' - end - - def boolean_cast_setting(key) - ActiveModel::Type::Boolean.new.cast(settings[key]) - end - - def coerced_settings(key) - coerce_values settings.fetch(key, {}) - end - - def coerce_values(params_hash) - params_hash.transform_values { |x| ActiveModel::Type::Boolean.new.cast(x) } - end - - def change?(key) - !settings[key].nil? - end -end diff --git a/app/lib/user_settings_serializer.rb b/app/lib/user_settings_serializer.rb new file mode 100644 index 000000000..10d1be04d --- /dev/null +++ b/app/lib/user_settings_serializer.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class UserSettingsSerializer + def self.load(value) + json = begin + if value.blank? + {} + else + Oj.load(value, symbol_keys: true) + end + end + + UserSettings.new(json) + end + + def self.dump(value) + Oj.dump(value.as_json) + end +end diff --git a/app/models/concerns/has_user_settings.rb b/app/models/concerns/has_user_settings.rb new file mode 100644 index 000000000..b3fa1f683 --- /dev/null +++ b/app/models/concerns/has_user_settings.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +module HasUserSettings + extend ActiveSupport::Concern + + included do + serialize :settings, UserSettingsSerializer + end + + def settings_attributes=(attributes) + settings.update(attributes) + end + + def prefers_noindex? + settings['noindex'] + end + + def preferred_posting_language + valid_locale_cascade(settings['default_language'], locale, I18n.locale) + end + + def setting_auto_play_gif + settings['web.auto_play'] + end + + def setting_default_sensitive + settings['default_sensitive'] + end + + def setting_unfollow_modal + settings['web.unfollow_modal'] + end + + def setting_boost_modal + settings['web.reblog_modal'] + end + + def setting_delete_modal + settings['web.delete_modal'] + end + + def setting_reduce_motion + settings['web.reduce_motion'] + end + + def setting_system_font_ui + settings['web.use_system_font'] + end + + def setting_noindex + settings['noindex'] + end + + def setting_theme + settings['theme'] + end + + def setting_display_media + settings['web.display_media'] + end + + def setting_expand_spoilers + settings['web.expand_content_warnings'] + end + + def setting_default_language + settings['default_language'] + end + + def setting_aggregate_reblogs + settings['aggregate_reblogs'] + end + + def setting_show_application + settings['show_application'] + end + + def setting_advanced_layout + settings['web.advanced_layout'] + end + + def setting_use_blurhash + settings['web.use_blurhash'] + end + + def setting_use_pending_items + settings['web.use_pending_items'] + end + + def setting_trends + settings['web.trends'] + end + + def setting_crop_images + settings['web.crop_images'] + end + + def setting_disable_swiping + settings['web.disable_swiping'] + end + + def setting_always_send_emails + settings['always_send_emails'] + end + + def setting_default_privacy + settings['default_privacy'] || (account.locked? ? 'private' : 'public') + end + + def allows_report_emails? + settings['notification_emails.report'] + end + + def allows_pending_account_emails? + settings['notification_emails.pending_account'] + end + + def allows_appeal_emails? + settings['notification_emails.appeal'] + end + + def allows_trends_review_emails? + settings['notification_emails.trends'] + end + + def aggregates_reblogs? + settings['aggregate_reblogs'] + end + + def shows_application? + settings['show_application'] + end + + def show_all_media? + settings['web.display_media'] == 'show_all' + end + + def hide_all_media? + settings['web.display_media'] == 'hide_all' + end +end diff --git a/app/models/user.rb b/app/models/user.rb index d56a9b9ca..9b225d75f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,10 +39,11 @@ # webauthn_id :string # sign_up_ip :inet # role_id :bigint(8) +# settings :text # class User < ApplicationRecord - self.ignored_columns = %w( + self.ignored_columns += %w( remember_created_at remember_token current_sign_in_ip @@ -51,9 +52,9 @@ class User < ApplicationRecord filtered_languages ) - include Settings::Extend include Redisable include LanguagesHelper + include HasUserSettings # The home and list feeds will be stored in Redis for this amount # of time, and status fan-out to followers will include only people @@ -132,13 +133,6 @@ class User < ApplicationRecord has_many :session_activations, dependent: :destroy - delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal, - :reduce_motion, :system_font_ui, :noindex, :theme, :display_media, - :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, - :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images, - :disable_swiping, :always_send_emails, - to: :settings, prefix: :setting, allow_nil: false - delegate :can?, to: :role attr_reader :invite_code @@ -302,42 +296,6 @@ class User < ApplicationRecord save! end - def prefers_noindex? - setting_noindex - end - - def preferred_posting_language - valid_locale_cascade(settings.default_language, locale, I18n.locale) - end - - def setting_default_privacy - settings.default_privacy || (account.locked? ? 'private' : 'public') - end - - def allows_report_emails? - settings.notification_emails['report'] - end - - def allows_pending_account_emails? - settings.notification_emails['pending_account'] - end - - def allows_appeal_emails? - settings.notification_emails['appeal'] - end - - def allows_trends_review_emails? - settings.notification_emails['trending_tag'] - end - - def aggregates_reblogs? - @aggregates_reblogs ||= settings.aggregate_reblogs - end - - def shows_application? - @shows_application ||= settings.show_application - end - def token_for_app(app) return nil if app.nil? || app.owner != self @@ -417,14 +375,6 @@ class User < ApplicationRecord send_reset_password_instructions end - def show_all_media? - setting_display_media == 'show_all' - end - - def hide_all_media? - setting_display_media == 'hide_all' - end - protected def send_devise_notification(notification, *args, **kwargs) @@ -494,7 +444,8 @@ class User < ApplicationRecord def sanitize_languages return if chosen_languages.nil? - chosen_languages.reject!(&:blank?) + chosen_languages.compact_blank! + self.chosen_languages = nil if chosen_languages.empty? end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb new file mode 100644 index 000000000..2c025d6c5 --- /dev/null +++ b/app/models/user_settings.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +class UserSettings + class Error < StandardError; end + class KeyError < Error; end + + include UserSettings::DSL + include UserSettings::Glue + + setting :always_send_emails, default: false + setting :aggregate_reblogs, default: true + setting :theme, default: -> { ::Setting.theme } + setting :noindex, default: -> { ::Setting.noindex } + setting :show_application, default: true + setting :default_language, default: nil + setting :default_sensitive, default: false + setting :default_privacy, default: nil + + namespace :web do + setting :crop_images, default: true + setting :advanced_layout, default: false + setting :trends, default: true + setting :use_blurhash, default: true + setting :use_pending_items, default: false + setting :use_system_font, default: false + setting :disable_swiping, default: false + setting :delete_modal, default: true + setting :reblog_modal, default: false + setting :unfollow_modal, default: true + setting :reduce_motion, default: false + setting :expand_content_warnings, default: false + setting :display_media, default: 'default', in: %w(default show_all hide_all) + setting :auto_play, default: false + end + + namespace :notification_emails do + setting :follow, default: true + setting :reblog, default: false + setting :favourite, default: false + setting :mention, default: true + setting :follow_request, default: true + setting :report, default: true + setting :pending_account, default: true + setting :trends, default: true + setting :appeal, default: true + end + + namespace :interactions do + setting :must_be_follower, default: false + setting :must_be_following, default: false + setting :must_be_following_dm, default: false + end + + def initialize(original_hash) + @original_hash = original_hash || {} + end + + def [](key) + key = key.to_sym + + raise KeyError, "Undefined setting: #{key}" unless self.class.definition_for?(key) + + if @original_hash.key?(key) + @original_hash[key] + else + self.class.definition_for(key).default_value + end + end + + def []=(key, value) + key = key.to_sym + + raise KeyError, "Undefined setting: #{key}" unless self.class.definition_for?(key) + + typecast_value = self.class.definition_for(key).type_cast(value) + + if typecast_value.nil? + @original_hash.delete(key) + else + @original_hash[key] = typecast_value + end + end + + def update(params) + params.each do |k, v| + self[k] = v unless v.nil? + end + end + + keys.each do |key| + define_method(key) do + self[key] + end + end + + def as_json + @original_hash + end +end diff --git a/app/models/user_settings/dsl.rb b/app/models/user_settings/dsl.rb new file mode 100644 index 000000000..26238bbbe --- /dev/null +++ b/app/models/user_settings/dsl.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module UserSettings::DSL + module ClassMethods + def setting(key, options = {}) + @definitions ||= {} + + UserSettings::Setting.new(key, options).tap do |s| + @definitions[s.key] = s + end + end + + def namespace(key, &block) + @definitions ||= {} + + UserSettings::Namespace.new(key).configure(&block).tap do |n| + @definitions.merge!(n.definitions) + end + end + + def keys + @definitions.keys + end + + def definition_for(key) + @definitions[key.to_sym] + end + + def definition_for?(key) + @definitions.key?(key.to_sym) + end + end + + def self.included(base) + base.extend ClassMethods + end +end diff --git a/app/models/user_settings/glue.rb b/app/models/user_settings/glue.rb new file mode 100644 index 000000000..02066a411 --- /dev/null +++ b/app/models/user_settings/glue.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module UserSettings::Glue + def to_model + self + end + + def to_key + '' + end + + def persisted? + false + end + + def type_for_attribute(key) + self.class.definition_for(key)&.type + end + + def has_attribute?(key) # rubocop:disable Naming/PredicateName + self.class.definition_for?(key) + end +end diff --git a/app/models/user_settings/namespace.rb b/app/models/user_settings/namespace.rb new file mode 100644 index 000000000..b8f7e092e --- /dev/null +++ b/app/models/user_settings/namespace.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class UserSettings::Namespace + attr_reader :name, :definitions + + def initialize(name) + @name = name.to_sym + @definitions = {} + end + + def configure(&block) + instance_eval(&block) + self + end + + def setting(key, options = {}) + UserSettings::Setting.new(key, options.merge(namespace: name)).tap do |s| + @definitions[s.key] = s + end + end +end diff --git a/app/models/user_settings/setting.rb b/app/models/user_settings/setting.rb new file mode 100644 index 000000000..c359c593b --- /dev/null +++ b/app/models/user_settings/setting.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +class UserSettings::Setting + attr_reader :name, :namespace, :in + + def initialize(name, options = {}) + @name = name.to_sym + @default_value = options[:default] + @namespace = options[:namespace] + @in = options[:in] + end + + def default_value + if @default_value.respond_to?(:call) + @default_value.call + else + @default_value + end + end + + def type + if @default_value.is_a?(TrueClass) || @default_value.is_a?(FalseClass) + ActiveModel::Type::Boolean.new + else + ActiveModel::Type::String.new + end + end + + def type_cast(value) + if type.respond_to?(:cast) + type.cast(value) + else + value + end + end + + def to_a + [key, default_value] + end + + def key + if namespace + "#{namespace}.#{name}".to_sym + else + name + end + end +end diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index 4c7acbcac..994ca588a 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -3,6 +3,11 @@ class NotifyService < BaseService include Redisable + NON_EMAIL_TYPES = %i( + admin.report + admin.sign_up + ).freeze + def call(recipient, type, activity) @recipient = recipient @activity = activity @@ -36,11 +41,11 @@ class NotifyService < BaseService end def optional_non_follower? - @recipient.user.settings.interactions['must_be_follower'] && !@notification.from_account.following?(@recipient) + @recipient.user.settings['interactions.must_be_follower'] && !@notification.from_account.following?(@recipient) end def optional_non_following? - @recipient.user.settings.interactions['must_be_following'] && !following_sender? + @recipient.user.settings['interactions.must_be_following'] && !following_sender? end def message? @@ -82,7 +87,7 @@ class NotifyService < BaseService def optional_non_following_and_direct? direct_message? && - @recipient.user.settings.interactions['must_be_following_dm'] && + @recipient.user.settings['interactions.must_be_following_dm'] && !following_sender? && !response_to_recipient? end @@ -171,6 +176,6 @@ class NotifyService < BaseService end def send_email_for_notification_type? - @recipient.user.settings.notification_emails[@notification.type.to_s] + NON_EMAIL_TYPES.exclude?(@notification.type) && @recipient.user.settings["notification_emails.#{@notification.type}"] end end diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index bc23df647..5358310e5 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -9,57 +9,58 @@ .fields-group.fields-row__column.fields-row__column-6 = f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| native_locale_name(locale) }, selected: I18n.locale, hint: false .fields-group.fields-row__column.fields-row__column-6 - = f.input :setting_theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, include_blank: false, hint: false + = f.simple_fields_for :settings, current_user.settings do |ff| + = ff.input :theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, include_blank: false, hint: false - unless I18n.locale == :en .flash-message.translation-prompt #{t 'appearance.localization.body'} #{content_tag(:a, t('appearance.localization.guide_link_text'), href: t('appearance.localization.guide_link'), target: '_blank', rel: 'noopener')} - %h4= t 'appearance.advanced_web_interface' + = f.simple_fields_for :settings, current_user.settings do |ff| + %h4= t 'appearance.advanced_web_interface' - %p.hint= t 'appearance.advanced_web_interface_hint' + %p.hint= t 'appearance.advanced_web_interface_hint' - .fields-group - = f.input :setting_advanced_layout, as: :boolean, wrapper: :with_label, hint: false + .fields-group + = ff.input :'web.advanced_layout', wrapper: :with_label, hint: false, label: I18n.t('simple_form.labels.defaults.setting_advanced_layout') + %h4= t 'appearance.animations_and_accessibility' - %h4= t 'appearance.animations_and_accessibility' + .fields-group + = ff.input :'web.use_pending_items', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_use_pending_items'), hint: I18n.t('simple_form.hints.defaults.setting_use_pending_items') - .fields-group - = f.input :setting_use_pending_items, as: :boolean, wrapper: :with_label + .fields-group + = ff.input :'web.auto_play', wrapper: :with_label, recommended: true, label: I18n.t('simple_form.labels.defaults.setting_auto_play_gif') + = ff.input :'web.reduce_motion', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_reduce_motion') + = ff.input :'web.disable_swiping', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_disable_swiping') + = ff.input :'web.use_system_font', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_system_font_ui') - .fields-group - = f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label, recommended: true - = f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label - = f.input :setting_disable_swiping, as: :boolean, wrapper: :with_label - = f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label + %h4= t 'appearance.toot_layout' - %h4= t 'appearance.toot_layout' + .fields-group + = ff.input :'web.crop_images', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_crop_images') - .fields-group - = f.input :setting_crop_images, as: :boolean, wrapper: :with_label + %h4= t 'appearance.discovery' - %h4= t 'appearance.discovery' + .fields-group + = ff.input :'web.trends', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_trends') - .fields-group - = f.input :setting_trends, as: :boolean, wrapper: :with_label + %h4= t 'appearance.confirmation_dialogs' - %h4= t 'appearance.confirmation_dialogs' + .fields-group + = ff.input :'web.unfollow_modal', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_unfollow_modal') + = ff.input :'web.reblog_modal', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_boost_modal') + = ff.input :'web.delete_modal', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_delete_modal') - .fields-group - = f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label - = f.input :setting_boost_modal, as: :boolean, wrapper: :with_label - = f.input :setting_delete_modal, as: :boolean, wrapper: :with_label + %h4= t 'appearance.sensitive_content' - %h4= t 'appearance.sensitive_content' + .fields-group + = ff.input :'web.display_media', collection: ['default', 'show_all', 'hide_all'],label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label, label: I18n.t('simple_form.labels.defaults.setting_display_media') - .fields-group - = f.input :setting_display_media, collection: ['default', 'show_all', 'hide_all'], label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label + .fields-group + = ff.input :'web.use_blurhash', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_use_blurhash'), hint: I18n.t('simple_form.hints.defaults.setting_use_blurhash') - .fields-group - = f.input :setting_use_blurhash, as: :boolean, wrapper: :with_label - - .fields-group - = f.input :setting_expand_spoilers, as: :boolean, wrapper: :with_label + .fields-group + = ff.input :'web.expand_content_warnings', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_expand_spoilers') .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index f00dbadd4..cb1ad0886 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -11,25 +11,25 @@ %p.hint= t 'notifications.email_events_hint' - .fields-group - = f.simple_fields_for :notification_emails, hash_to_object(current_user.settings.notification_emails) do |ff| - = ff.input :follow, as: :boolean, wrapper: :with_label - = ff.input :follow_request, as: :boolean, wrapper: :with_label - = ff.input :reblog, as: :boolean, wrapper: :with_label - = ff.input :favourite, as: :boolean, wrapper: :with_label - = ff.input :mention, as: :boolean, wrapper: :with_label - = ff.input :report, as: :boolean, wrapper: :with_label if current_user.can?(:manage_reports) - = ff.input :appeal, as: :boolean, wrapper: :with_label if current_user.can?(:manage_appeals) - = ff.input :pending_account, as: :boolean, wrapper: :with_label if current_user.can?(:manage_users) - = ff.input :trending_tag, as: :boolean, wrapper: :with_label if current_user.can?(:manage_taxonomies) - - .fields-group - = f.input :setting_always_send_emails, as: :boolean, wrapper: :with_label + = f.simple_fields_for :settings, current_user.settings do |ff| + .fields-group + = ff.input :'notification_emails.follow', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.follow') + = ff.input :'notification_emails.follow_request', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.follow_request') + = ff.input :'notification_emails.reblog', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.reblog') + = ff.input :'notification_emails.favourite', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.favourite') + = ff.input :'notification_emails.mention', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.mention') + = ff.input :'notification_emails.report', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.report') if current_user.can?(:manage_reports) + = ff.input :'notification_emails.appeal', as: :boolean, wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.appeal') if current_user.can?(:manage_appeals) + = ff.input :'notification_emails.pending_account', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.pending_account') if current_user.can?(:manage_users) + = ff.input :'notification_emails.trends', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.trending_tag') if current_user.can?(:manage_taxonomies) + + .fields-group + = ff.input :always_send_emails, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_always_send_emails'), hint: I18n.t('simple_form.hints.defaults.setting_always_send_emails') %h4= t 'notifications.other_settings' .fields-group - = f.simple_fields_for :interactions, hash_to_object(current_user.settings.interactions) do |ff| - = ff.input :must_be_follower, as: :boolean, wrapper: :with_label - = ff.input :must_be_following, as: :boolean, wrapper: :with_label - = ff.input :must_be_following_dm, as: :boolean, wrapper: :with_label + = f.simple_fields_for :settings, current_user.settings do |ff| + = ff.input :'interactions.must_be_follower', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_follower') + = ff.input :'interactions.must_be_following', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_following') + = ff.input :'interactions.must_be_following_dm', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_following_dm') diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index 44f4af2eb..6590ec7c2 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -7,26 +7,27 @@ = simple_form_for current_user, url: settings_preferences_other_path, html: { method: :put, id: 'edit_preferences' } do |f| = render 'shared/error_messages', object: current_user - .fields-group - = f.input :setting_noindex, as: :boolean, wrapper: :with_label + = f.simple_fields_for :settings, current_user.settings do |ff| + .fields-group + = ff.input :noindex, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_noindex'), hint: I18n.t('simple_form.hints.defaults.setting_noindex') - .fields-group - = f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label, recommended: true + .fields-group + = ff.input :aggregate_reblogs, wrapper: :with_label, recommended: true, label: I18n.t('simple_form.labels.defaults.setting_aggregate_reblogs'), hint: I18n.t('simple_form.hints.defaults.setting_aggregate_reblogs') - %h4= t 'preferences.posting_defaults' + %h4= t 'preferences.posting_defaults' - .fields-row - .fields-group.fields-row__column.fields-row__column-6 - = f.input :setting_default_privacy, collection: Status.selectable_visibilities, wrapper: :with_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, required: false, hint: false + .fields-row + .fields-group.fields-row__column.fields-row__column-6 + = ff.input :default_privacy, collection: Status.selectable_visibilities, wrapper: :with_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, required: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_privacy') - .fields-group.fields-row__column.fields-row__column-6 - = f.input :setting_default_language, collection: [nil] + filterable_languages, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, required: false, include_blank: false, hint: false + .fields-group.fields-row__column.fields-row__column-6 + = ff.input :default_language, collection: [nil] + filterable_languages, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) }, required: false, include_blank: false, hint: false, label: I18n.t('simple_form.labels.defaults.setting_default_language') - .fields-group - = f.input :setting_default_sensitive, as: :boolean, wrapper: :with_label + .fields-group + = ff.input :default_sensitive, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'), hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive') - .fields-group - = f.input :setting_show_application, as: :boolean, wrapper: :with_label, recommended: true + .fields-group + = ff.input :show_application, wrapper: :with_label, recommended: true, label: I18n.t('simple_form.labels.defaults.setting_show_application'), hint: I18n.t('simple_form.hints.defaults.setting_show_application') %h4= t 'preferences.public_timelines' diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index a361cb0ec..95f0b5788 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -26,6 +26,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'URL' inflect.acronym 'ASCII' inflect.acronym 'DeepL' + inflect.acronym 'DSL' inflect.singular 'data', 'data' end diff --git a/config/settings.yml b/config/settings.yml index f0b09dd5c..4ac521a4b 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -12,48 +12,14 @@ defaults: &defaults registrations_mode: 'open' profile_directory: true closed_registrations_message: '' - open_deletion: true - min_invite_role: 'admin' timeline_preview: true show_staff_badge: true - default_sensitive: false - unfollow_modal: false - boost_modal: false - delete_modal: true - auto_play_gif: false - display_media: 'default' - expand_spoilers: false preview_sensitive_media: false - reduce_motion: false - disable_swiping: false - show_application: true - system_font_ui: false noindex: false theme: 'default' - aggregate_reblogs: true - advanced_layout: false - use_blurhash: true - use_pending_items: false trends: true trends_as_landing_page: true trendable_by_default: false - crop_images: true - notification_emails: - follow: true - reblog: false - favourite: false - mention: true - follow_request: true - digest: true - report: true - pending_account: true - trending_tag: true - appeal: true - always_send_emails: false - interactions: - must_be_follower: false - must_be_following: false - must_be_following_dm: false reserved_usernames: - admin - support diff --git a/db/migrate/20230215074327_add_settings_to_users.rb b/db/migrate/20230215074327_add_settings_to_users.rb new file mode 100644 index 000000000..ff5308f42 --- /dev/null +++ b/db/migrate/20230215074327_add_settings_to_users.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSettingsToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :settings, :text + end +end diff --git a/db/migrate/20230215074423_move_user_settings.rb b/db/migrate/20230215074423_move_user_settings.rb new file mode 100644 index 000000000..351a8b61d --- /dev/null +++ b/db/migrate/20230215074423_move_user_settings.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +class MoveUserSettings < ActiveRecord::Migration[6.1] + class User < ApplicationRecord; end + + MAPPING = { + default_privacy: 'default_privacy', + default_sensitive: 'web.default_sensitive', + default_language: 'default_language', + noindex: 'noindex', + theme: 'theme', + trends: 'web.trends', + unfollow_modal: 'web.unfollow_modal', + boost_modal: 'web.reblog_modal', + delete_modal: 'web.delete_modal', + auto_play_gif: 'web.auto_play', + display_media: 'web.display_media', + expand_spoilers: 'web.expand_content_warnings', + reduce_motion: 'web.reduce_motion', + disable_swiping: 'web.disable_swiping', + show_application: 'show_application', + system_font_ui: 'web.use_system_font', + aggregate_reblogs: 'aggregate_reblogs', + advanced_layout: 'web.advanced_layout', + use_blurhash: 'web.use_blurhash', + use_pending_items: 'web.use_pending_items', + crop_images: 'web.crop_images', + notification_emails: { + follow: 'notification_emails.follow', + reblog: 'notification_emails.reblog', + favourite: 'notification_emails.favourite', + mention: 'notification_emails.mention', + follow_request: 'notification_emails.follow_request', + report: 'notification_emails.report', + pending_account: 'notification_emails.pending_account', + trending_tag: 'notification_emails.trends', + appeal: 'notification_emails.appeal', + }.freeze, + always_send_emails: 'always_send_emails', + interactions: { + must_be_follower: 'interactions.must_be_follower', + must_be_following: 'interactions.must_be_following', + must_be_following_dm: 'interactions.must_be_following_dm', + }.freeze, + }.freeze + + class LegacySetting < ApplicationRecord + self.table_name = 'settings' + + def var + self[:var]&.to_sym + end + + def value + YAML.safe_load(self[:value], permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) if self[:value].present? + end + end + + def up + User.find_each do |user| + previous_settings = LegacySetting.where(thing_type: 'User', thing_id: user.id).index_by(&:var) + + user_settings = {} + + MAPPING.each do |legacy_key, new_key| + value = previous_settings[legacy_key]&.value + + next if value.blank? + + if value.is_a?(Hash) + value.each do |nested_key, nested_value| + user_settings[MAPPING[legacy_key][nested_key.to_sym]] = nested_value + end + else + user_settings[new_key] = value + end + end + + user.update_column('settings', Oj.dump(user_settings)) # rubocop:disable Rails/SkipsModelValidations + end + end + + def down; end +end diff --git a/db/schema.rb b/db/schema.rb index 704cef122..620bed2bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_12_06_114142) do +ActiveRecord::Schema.define(version: 2023_02_15_074423) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1060,6 +1060,7 @@ ActiveRecord::Schema.define(version: 2022_12_06_114142) do t.inet "sign_up_ip" t.boolean "skip_sign_in_token" t.bigint "role_id" + t.text "settings" t.index ["account_id"], name: "index_users_on_account_id" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id", where: "(created_by_application_id IS NOT NULL)" diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake index 51a6ee0d7..35073b78b 100644 --- a/lib/tasks/tests.rake +++ b/lib/tasks/tests.rake @@ -54,7 +54,7 @@ namespace :tests do exit(1) end - unless User.find(1).settings.notification_emails['favourite'] == true && User.find(1).settings.notification_emails['mention'] == false + unless User.find(1).settings['notification_emails.favourite'] == true && User.find(1).settings['notification_emails.mention'] == false puts 'User settings not kept as expected' exit(1) end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index 57fe0aee6..b5d5c37a9 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -46,6 +46,7 @@ describe Api::V1::Accounts::CredentialsController do end it 'updates account info' do + user.reload user.account.reload expect(user.account.display_name).to eq("Alice Isn't Dead") diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 35c7326cb..bc6c6c0c5 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -88,21 +88,19 @@ describe ApplicationController, type: :controller do it 'returns instances\'s default theme when user didn\'t set theme' do current_user = Fabricate(:user) + current_user.settings.update(theme: 'contrast', noindex: false) + current_user.save sign_in current_user - allow(Setting).to receive(:[]).with('theme').and_return 'contrast' - allow(Setting).to receive(:[]).with('noindex').and_return false - expect(controller.view_context.current_theme).to eq 'contrast' end it 'returns user\'s theme when it is set' do current_user = Fabricate(:user) - current_user.settings['theme'] = 'mastodon-light' + current_user.settings.update(theme: 'mastodon-light') + current_user.save sign_in current_user - allow(Setting).to receive(:[]).with('theme').and_return 'contrast' - expect(controller.view_context.current_theme).to eq 'mastodon-light' end end diff --git a/spec/controllers/settings/preferences/notifications_controller_spec.rb b/spec/controllers/settings/preferences/notifications_controller_spec.rb index 66fb8c5eb..29b7b6aec 100644 --- a/spec/controllers/settings/preferences/notifications_controller_spec.rb +++ b/spec/controllers/settings/preferences/notifications_controller_spec.rb @@ -20,20 +20,22 @@ describe Settings::Preferences::NotificationsController do describe 'PUT #update' do it 'updates notifications settings' do - user.settings['notification_emails'] = user.settings['notification_emails'].merge('follow' => false) - user.settings['interactions'] = user.settings['interactions'].merge('must_be_follower' => true) + user.settings.update('notification_emails.follow': false, 'interactions.must_be_follower': true) + user.save put :update, params: { user: { - notification_emails: { follow: '1' }, - interactions: { must_be_follower: '0' }, + settings_attributes: { + 'notification_emails.follow': '1', + 'interactions.must_be_follower': '0', + }, }, } expect(response).to redirect_to(settings_preferences_notifications_path) user.reload - expect(user.settings['notification_emails']['follow']).to be true - expect(user.settings['interactions']['must_be_follower']).to be false + expect(user.settings['notification_emails.follow']).to be true + expect(user.settings['interactions.must_be_follower']).to be false end end end diff --git a/spec/controllers/settings/preferences/other_controller_spec.rb b/spec/controllers/settings/preferences/other_controller_spec.rb index 63eeefaf0..249d1b5b5 100644 --- a/spec/controllers/settings/preferences/other_controller_spec.rb +++ b/spec/controllers/settings/preferences/other_controller_spec.rb @@ -29,20 +29,22 @@ describe Settings::Preferences::OtherController do end it 'updates user settings' do - user.settings['boost_modal'] = false - user.settings['delete_modal'] = true + user.settings.update('web.reblog_modal': false, 'web.delete_modal': true) + user.save put :update, params: { user: { - setting_boost_modal: '1', - setting_delete_modal: '0', + settings_attributes: { + 'web.reblog_modal': '1', + 'web.delete_modal': '0', + }, }, } expect(response).to redirect_to(settings_preferences_other_path) user.reload - expect(user.settings['boost_modal']).to be true - expect(user.settings['delete_modal']).to be false + expect(user.settings['web.reblog_modal']).to be true + expect(user.settings['web.delete_modal']).to be false end end end diff --git a/spec/lib/settings/extend_spec.rb b/spec/lib/settings/extend_spec.rb deleted file mode 100644 index ea623137b..000000000 --- a/spec/lib/settings/extend_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Settings::Extend do - class User - include Settings::Extend - end - - describe '#settings' do - it 'sets @settings as an instance of Settings::ScopedSettings' do - user = Fabricate(:user) - expect(user.settings).to be_a Settings::ScopedSettings - end - end -end diff --git a/spec/lib/settings/scoped_settings_spec.rb b/spec/lib/settings/scoped_settings_spec.rb deleted file mode 100644 index 7566685b4..000000000 --- a/spec/lib/settings/scoped_settings_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Settings::ScopedSettings do - let(:object) { Fabricate(:user) } - let(:scoped_setting) { described_class.new(object) } - let(:val) { 'whatever' } - let(:methods) { %i(auto_play_gif default_sensitive unfollow_modal boost_modal delete_modal reduce_motion system_font_ui noindex theme) } - - describe '.initialize' do - it 'sets @object' do - scoped_setting = described_class.new(object) - expect(scoped_setting.instance_variable_get(:@object)).to be object - end - end - - describe '#method_missing' do - it 'sets scoped_setting.method_name = val' do - methods.each do |key| - scoped_setting.send("#{key}=", val) - expect(scoped_setting.send(key)).to eq val - end - end - end - - describe '#[]= and #[]' do - it 'sets [key] = val' do - methods.each do |key| - scoped_setting[key] = val - expect(scoped_setting[key]).to eq val - end - end - end -end diff --git a/spec/lib/user_settings_decorator_spec.rb b/spec/lib/user_settings_decorator_spec.rb deleted file mode 100644 index 3b9b7ee2b..000000000 --- a/spec/lib/user_settings_decorator_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe UserSettingsDecorator do - describe 'update' do - let(:user) { Fabricate(:user) } - let(:settings) { described_class.new(user) } - - it 'updates the user settings value for email notifications' do - values = { 'notification_emails' => { 'follow' => '1' } } - - settings.update(values) - expect(user.settings['notification_emails']['follow']).to be true - end - - it 'updates the user settings value for interactions' do - values = { 'interactions' => { 'must_be_follower' => '0' } } - - settings.update(values) - expect(user.settings['interactions']['must_be_follower']).to be false - end - - it 'updates the user settings value for privacy' do - values = { 'setting_default_privacy' => 'public' } - - settings.update(values) - expect(user.settings['default_privacy']).to eq 'public' - end - - it 'updates the user settings value for sensitive' do - values = { 'setting_default_sensitive' => '1' } - - settings.update(values) - expect(user.settings['default_sensitive']).to be true - end - - it 'updates the user settings value for unfollow modal' do - values = { 'setting_unfollow_modal' => '0' } - - settings.update(values) - expect(user.settings['unfollow_modal']).to be false - end - - it 'updates the user settings value for boost modal' do - values = { 'setting_boost_modal' => '1' } - - settings.update(values) - expect(user.settings['boost_modal']).to be true - end - - it 'updates the user settings value for delete toot modal' do - values = { 'setting_delete_modal' => '0' } - - settings.update(values) - expect(user.settings['delete_modal']).to be false - end - - it 'updates the user settings value for gif auto play' do - values = { 'setting_auto_play_gif' => '0' } - - settings.update(values) - expect(user.settings['auto_play_gif']).to be false - end - - it 'updates the user settings value for system font in UI' do - values = { 'setting_system_font_ui' => '0' } - - settings.update(values) - expect(user.settings['system_font_ui']).to be false - end - - it 'decoerces setting values before applying' do - values = { - 'setting_delete_modal' => 'false', - 'setting_boost_modal' => 'true', - } - - settings.update(values) - expect(user.settings['delete_modal']).to be false - expect(user.settings['boost_modal']).to be true - end - end -end diff --git a/spec/models/user_settings/namespace_spec.rb b/spec/models/user_settings/namespace_spec.rb new file mode 100644 index 000000000..ae2fa7b48 --- /dev/null +++ b/spec/models/user_settings/namespace_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe UserSettings::Namespace do + subject { described_class.new(name) } + + let(:name) { :foo } + + describe '#setting' do + before do + subject.setting :bar, default: 'baz' + end + + it 'adds setting to definitions' do + expect(subject.definitions[:'foo.bar']).to have_attributes(name: :bar, namespace: :foo, default_value: 'baz') + end + end + + describe '#definitions' do + it 'returns a hash' do + expect(subject.definitions).to be_a Hash + end + end +end diff --git a/spec/models/user_settings/setting_spec.rb b/spec/models/user_settings/setting_spec.rb new file mode 100644 index 000000000..6e4ec6789 --- /dev/null +++ b/spec/models/user_settings/setting_spec.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe UserSettings::Setting do + subject { described_class.new(name, options) } + + let(:name) { :foo } + let(:options) { { default: default, namespace: namespace } } + let(:default) { false } + let(:namespace) { nil } + + describe '#default_value' do + context 'when default value is a primitive value' do + it 'returns default value' do + expect(subject.default_value).to eq default + end + end + + context 'when default value is a proc' do + let(:default) { -> { 'bar' } } + + it 'returns value from proc' do + expect(subject.default_value).to eq 'bar' + end + end + end + + describe '#type' do + it 'returns a type' do + expect(subject.type).to be_a ActiveModel::Type::Value + end + end + + describe '#type_cast' do + context 'when default value is a boolean' do + let(:default) { false } + + it 'returns boolean' do + expect(subject.type_cast('1')).to be true + end + end + + context 'when default value is a string' do + let(:default) { '' } + + it 'returns string' do + expect(subject.type_cast(1)).to eq '1' + end + end + end + + describe '#to_a' do + it 'returns an array' do + expect(subject.to_a).to eq [name, default] + end + end + + describe '#key' do + context 'when there is no namespace' do + it 'returnsn a symbol' do + expect(subject.key).to eq :foo + end + end + + context 'when there is a namespace' do + let(:namespace) { :bar } + + it 'returns a symbol' do + expect(subject.key).to eq :'bar.foo' + end + end + end +end diff --git a/spec/models/user_settings_spec.rb b/spec/models/user_settings_spec.rb new file mode 100644 index 000000000..f0e4272fd --- /dev/null +++ b/spec/models/user_settings_spec.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe UserSettings do + subject { described_class.new(json) } + + let(:json) { {} } + + describe '#[]' do + context 'when setting is not set' do + it 'returns default value' do + expect(subject[:always_send_emails]).to be false + end + end + + context 'when setting is set' do + let(:json) { { default_language: 'fr' } } + + it 'returns value' do + expect(subject[:default_language]).to eq 'fr' + end + end + + context 'when setting was not defined' do + it 'raises error' do + expect { subject[:foo] }.to raise_error UserSettings::KeyError + end + end + end + + describe '#[]=' do + context 'when value matches type' do + before do + subject[:always_send_emails] = true + end + + it 'updates value' do + expect(subject[:always_send_emails]).to be true + end + end + + context 'when value needs to be type-cast' do + before do + subject[:always_send_emails] = '1' + end + + it 'updates value with a type-cast' do + expect(subject[:always_send_emails]).to be true + end + end + end + + describe '#update' do + before do + subject.update(always_send_emails: true, default_language: 'fr', default_privacy: nil) + end + + it 'updates values' do + expect(subject[:always_send_emails]).to be true + expect(subject[:default_language]).to eq 'fr' + end + + it 'does not set values that are nil' do + expect(subject.as_json).to_not include(default_privacy: nil) + end + end + + describe '#as_json' do + let(:json) { { default_language: 'fr' } } + + it 'returns hash' do + expect(subject.as_json).to eq json + end + end + + describe '.keys' do + it 'returns an array' do + expect(described_class.keys).to be_a Array + end + end + + describe '.definition_for' do + context 'when key is defined' do + it 'returns a setting' do + expect(described_class.definition_for(:always_send_emails)).to be_a UserSettings::Setting + end + end + + context 'when key is not defined' do + it 'returns nil' do + expect(described_class.definition_for(:foo)).to be_nil + end + end + end + + describe '.definition_for?' do + context 'when key is defined' do + it 'returns true' do + expect(described_class.definition_for?(:always_send_emails)).to be true + end + end + + context 'when key is not defined' do + it 'returns false' do + expect(described_class.definition_for?(:foo)).to be false + end + end + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3e7b59f17..ab883927a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -313,9 +313,9 @@ RSpec.describe User, type: :model do end describe 'settings' do - it 'is instance of Settings::ScopedSettings' do + it 'is instance of UserSettings' do user = Fabricate(:user) - expect(user.settings).to be_a Settings::ScopedSettings + expect(user.settings).to be_a UserSettings end end @@ -379,16 +379,6 @@ RSpec.describe User, type: :model do end end - it_behaves_like 'Settings-extended' do - def create! - User.create!(account: Fabricate(:account, user: nil), email: 'foo@mastodon.space', password: 'abcd1234', agreement: true) - end - - def fabricate - Fabricate(:user) - end - end - describe 'token_for_app' do let(:user) { Fabricate(:user) } let(:app) { Fabricate(:application, owner: user) } diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb index c58cebbfb..616a7aa20 100644 --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@ -54,7 +54,8 @@ RSpec.describe NotifyService, type: :service do let(:type) { :mention } before do - user.settings.interactions = user.settings.interactions.merge('must_be_following_dm' => enabled) + user.settings.update('interactions.must_be_following_dm': enabled) + user.save end context 'if recipient is supposed to be following sender' do @@ -155,8 +156,8 @@ RSpec.describe NotifyService, type: :service do before do ActionMailer::Base.deliveries.clear - notification_emails = user.settings.notification_emails - user.settings.notification_emails = notification_emails.merge('follow' => enabled) + user.settings.update('notification_emails.follow': enabled) + user.save end context 'when email notification is enabled' do diff --git a/spec/services/report_service_spec.rb b/spec/services/report_service_spec.rb index 9d81bd971..452400f72 100644 --- a/spec/services/report_service_spec.rb +++ b/spec/services/report_service_spec.rb @@ -96,7 +96,8 @@ RSpec.describe ReportService, type: :service do before do ActionMailer::Base.deliveries.clear - source_account.user.settings.notification_emails['report'] = true + source_account.user.settings['notification_emails.report'] = true + source_account.user.save end it 'does not send an e-mail' do -- cgit From ff168ef2024626f37fa776fde5739dcd58ecb9f2 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 9 Apr 2023 11:25:30 +0200 Subject: Fix most rubocop issues (#2165) * Run rubocop --autocorrect on app/, config/ and lib/, also manually fix some remaining style issues * Run rubocop --autocorrect-all on db/ * Run rubocop --autocorrect-all on `spec/` and fix remaining issues --- .rubocop_todo.yml | 2 + .../api/v1/timelines/public_controller.rb | 2 +- app/controllers/auth/confirmations_controller.rb | 13 ++-- app/controllers/settings/flavours_controller.rb | 4 +- app/helpers/accounts_helper.rb | 2 +- app/lib/advanced_text_formatter.rb | 1 + app/lib/feed_manager.rb | 2 + app/lib/themes.rb | 45 ++++++------ app/models/direct_feed.rb | 9 +-- app/models/status.rb | 19 ++--- app/models/user.rb | 1 - app/serializers/activitypub/note_serializer.rb | 1 + app/serializers/rest/account_serializer.rb | 2 +- app/serializers/rest/mute_serializer.rb | 4 +- app/serializers/rest/status_serializer.rb | 4 +- app/services/backup_service.rb | 2 +- app/services/fan_out_on_write_service.rb | 2 +- app/services/post_status_service.rb | 25 ++++--- app/validators/status_pin_validator.rb | 2 +- config/initializers/0_duplicate_migrations.rb | 24 ++++--- config/initializers/simple_form.rb | 1 + db/migrate/20171009222537_create_keyword_mutes.rb | 2 + ...900_move_keyword_mutes_into_glitch_namespace.rb | 2 + ...171210213213_add_local_only_flag_to_statuses.rb | 2 + db/migrate/20180410220657_create_bookmarks.rb | 2 + ..._add_apply_to_mentions_flag_to_keyword_mutes.rb | 2 + db/migrate/20180707193142_migrate_filters.rb | 12 ++-- .../20190512200918_add_content_type_to_statuses.rb | 2 + ...20209175231_add_content_type_to_status_edits.rb | 2 + .../20180813160548_post_migrate_filters.rb | 6 +- lib/sanitize_ext/sanitize_config.rb | 8 +-- lib/tasks/assets.rake | 12 ++-- lib/tasks/glitchsoc.rake | 8 ++- .../api/v1/accounts/credentials_controller_spec.rb | 4 +- .../api/v1/timelines/direct_controller_spec.rb | 2 +- spec/controllers/application_controller_spec.rb | 4 +- .../settings/flavours_controller_spec.rb | 3 +- spec/lib/advanced_text_formatter_spec.rb | 82 +++++++++++----------- spec/models/concerns/account_interactions_spec.rb | 39 +--------- spec/models/public_feed_spec.rb | 12 ++-- spec/models/status_spec.rb | 42 +++++------ spec/models/tag_feed_spec.rb | 2 +- spec/policies/status_policy_spec.rb | 4 +- spec/services/notify_service_spec.rb | 2 +- spec/validators/status_length_validator_spec.rb | 2 +- 45 files changed, 210 insertions(+), 215 deletions(-) (limited to 'spec/controllers/api/v1') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2e4801a55..dc7e21dc5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -473,6 +473,7 @@ RSpec/ContextWording: - 'spec/lib/activitypub/activity/create_spec.rb' - 'spec/lib/activitypub/activity/follow_spec.rb' - 'spec/lib/activitypub/activity/reject_spec.rb' + - 'spec/lib/advanced_text_formatter_spec.rb' - 'spec/lib/emoji_formatter_spec.rb' - 'spec/lib/entity_cache_spec.rb' - 'spec/lib/feed_manager_spec.rb' @@ -1321,6 +1322,7 @@ Rails/FilePath: - 'app/models/setting.rb' - 'app/validators/reaction_validator.rb' - 'config/environments/test.rb' + - 'config/initializers/locale.rb' - 'db/migrate/20170716191202_add_hide_notifications_to_mute.rb' - 'db/migrate/20171005171936_add_disabled_to_custom_emojis.rb' - 'db/migrate/20171028221157_add_reblogs_to_follows.rb' diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb index 493fe4776..4675af921 100644 --- a/app/controllers/api/v1/timelines/public_controller.rb +++ b/app/controllers/api/v1/timelines/public_controller.rb @@ -40,7 +40,7 @@ class Api::V1::Timelines::PublicController < Api::BaseController only_media: truthy_param?(:only_media), allow_local_only: truthy_param?(:allow_local_only), with_replies: Setting.show_replies_in_public_timelines, - with_reblogs: Setting.show_reblogs_in_public_timelines, + with_reblogs: Setting.show_reblogs_in_public_timelines ) end diff --git a/app/controllers/auth/confirmations_controller.rb b/app/controllers/auth/confirmations_controller.rb index 0817a905c..620fb621d 100644 --- a/app/controllers/auth/confirmations_controller.rb +++ b/app/controllers/auth/confirmations_controller.rb @@ -15,12 +15,6 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController skip_before_action :require_functional! - def new - super - - resource.email = current_user.unconfirmed_email || current_user.email if user_signed_in? - end - def show old_session_values = session.to_hash reset_session @@ -29,6 +23,12 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController super end + def new + super + + resource.email = current_user.unconfirmed_email || current_user.email if user_signed_in? + end + def confirm_captcha check_captcha! do |message| flash.now[:alert] = message @@ -51,6 +51,7 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController # step. confirmation_token = params[:confirmation_token] return if confirmation_token.nil? + @confirmation_user = User.find_first_by_auth_conditions(confirmation_token: confirmation_token) end diff --git a/app/controllers/settings/flavours_controller.rb b/app/controllers/settings/flavours_controller.rb index c1172598b..b179b9429 100644 --- a/app/controllers/settings/flavours_controller.rb +++ b/app/controllers/settings/flavours_controller.rb @@ -12,9 +12,7 @@ class Settings::FlavoursController < Settings::BaseController end def show - unless Themes.instance.flavours.include?(params[:flavour]) || (params[:flavour] == current_flavour) - redirect_to action: 'show', flavour: current_flavour - end + redirect_to action: 'show', flavour: current_flavour unless Themes.instance.flavours.include?(params[:flavour]) || (params[:flavour] == current_flavour) @listing = Themes.instance.flavours @selected = params[:flavour] diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index 91c3a116b..b8277ee17 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -28,7 +28,7 @@ module AccountsHelper end def hide_followers_count?(account) - Setting.hide_followers_count || account.user&.settings['hide_followers_count'] + Setting.hide_followers_count || account.user&.settings&.[]('hide_followers_count') end def account_description(account) diff --git a/app/lib/advanced_text_formatter.rb b/app/lib/advanced_text_formatter.rb index 21e81d4d1..cdf1e2d9c 100644 --- a/app/lib/advanced_text_formatter.rb +++ b/app/lib/advanced_text_formatter.rb @@ -15,6 +15,7 @@ class AdvancedTextFormatter < TextFormatter def autolink(link, link_type) return link if link_type == :email + @format_link.call(link) end end diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 4ce888fc9..15ff6d15f 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -306,6 +306,7 @@ class FeedManager statuses.each do |status| next if filter_from_direct?(status, account) + added += 1 if add_to_feed(:direct, account.id, status) end @@ -459,6 +460,7 @@ class FeedManager # @return [Boolean] def filter_from_direct?(status, receiver_id) return false if receiver_id == status.account_id + filter_from_mentions?(status, receiver_id) end diff --git a/app/lib/themes.rb b/app/lib/themes.rb index 81e016d4a..45ba47780 100644 --- a/app/lib/themes.rb +++ b/app/lib/themes.rb @@ -7,24 +7,23 @@ class Themes include Singleton def initialize - core = YAML.load_file(Rails.root.join('app', 'javascript', 'core', 'theme.yml')) - core['pack'] = Hash.new unless core['pack'] + core['pack'] = {} unless core['pack'] - result = Hash.new - Dir.glob(Rails.root.join('app', 'javascript', 'flavours', '*', 'theme.yml')) do |path| - data = YAML.load_file(path) + result = {} + Rails.root.glob('app/javascript/flavours/*/theme.yml') do |pathname| + data = YAML.load_file(pathname) next unless data['pack'] - dir = File.dirname(path) - name = File.basename(dir) + dir = pathname.dirname + name = dir.basename.to_s locales = [] screenshots = [] if data['locales'] Dir.glob(File.join(dir, data['locales'], '*.{js,json}')) do |locale| - localeName = File.basename(locale, File.extname(locale)) - locales.push(localeName) unless localeName.match(/defaultMessages|whitelist|index/) + locale_name = File.basename(locale, File.extname(locale)) + locales.push(locale_name) unless /defaultMessages|whitelist|index/.match?(locale_name) end end @@ -43,34 +42,30 @@ class Themes result[name] = data end - Dir.glob(Rails.root.join('app', 'javascript', 'skins', '*', '*')) do |path| - ext = File.extname(path) - skin = File.basename(path) - name = File.basename(File.dirname(path)) + Rails.root.glob('app/javascript/skins/*/*') do |pathname| + ext = pathname.extname.to_s + skin = pathname.basename.to_s + name = pathname.dirname.basename.to_s next unless result[name] - if File.directory?(path) + if pathname.directory? pack = [] - Dir.glob(File.join(path, '*.{css,scss}')) do |sheet| - pack.push(File.basename(sheet, File.extname(sheet))) + pathname.glob('*.{css,scss}') do |sheet| + pack.push(sheet.basename(sheet.extname).to_s) end - elsif ext.match(/^\.s?css$/i) - skin = File.basename(path, ext) + elsif /^\.s?css$/i.match?(ext) + skin = pathname.basename(ext).to_s pack = ['common'] end - if skin != 'default' - result[name]['skin'][skin] = pack - end + result[name]['skin'][skin] = pack if skin != 'default' end @core = core @conf = result end - def core - @core - end + attr_reader :core def flavour(name) @conf[name] @@ -86,7 +81,7 @@ class Themes def flavours_and_skins flavours.map do |flavour| - [flavour, skins_for(flavour).map{ |skin| [flavour, skin] }] + [flavour, skins_for(flavour).map { |skin| [flavour, skin] }] end end end diff --git a/app/models/direct_feed.rb b/app/models/direct_feed.rb index 1f2448070..689a735b3 100644 --- a/app/models/direct_feed.rb +++ b/app/models/direct_feed.rb @@ -4,9 +4,8 @@ class DirectFeed < Feed include Redisable def initialize(account) - @type = :direct - @id = account.id @account = account + super(:direct, account.id) end def get(limit, max_id = nil, since_id = nil, min_id = nil) @@ -19,10 +18,12 @@ class DirectFeed < Feed private - def from_database(limit, max_id, since_id, min_id) + # TODO: _min_id is not actually handled by `as_direct_timeline` + def from_database(limit, max_id, since_id, _min_id) loop do - statuses = Status.as_direct_timeline(@account, limit, max_id, since_id, min_id) + statuses = Status.as_direct_timeline(@account, limit, max_id, since_id) return statuses if statuses.empty? + max_id = statuses.last.id statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account) } return statuses unless statuses.empty? diff --git a/app/models/status.rb b/app/models/status.rb index e01ddb5c5..8a58e5d68 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -338,7 +338,7 @@ class Status < ApplicationRecord visibilities.keys - %w(direct limited) end - def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false) + def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil) # direct timeline is mix of direct message from_me and to_me. # 2 queries are executed with pagination. # constant expression using arel_table is required for partial index @@ -369,14 +369,9 @@ class Status < ApplicationRecord query_to_me = query_to_me.where('mentions.status_id > ?', since_id) end - if cache_ids - # returns array of cache_ids object that have id and updated_at - (query_from_me.cache_ids.to_a + query_to_me.cache_ids.to_a).uniq(&:id).sort_by(&:id).reverse.take(limit) - else - # returns ActiveRecord.Relation - items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit) - Status.where(id: items.map(&:id)) - end + # returns ActiveRecord.Relation + items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit) + Status.where(id: items.map(&:id)) end def favourites_map(status_ids, account_id) @@ -553,9 +548,9 @@ class Status < ApplicationRecord end def set_locality - if account.domain.nil? && !attribute_changed?(:local_only) - self.local_only = marked_local_only? - end + return unless account.domain.nil? && !attribute_changed?(:local_only) + + self.local_only = marked_local_only? end def set_conversation diff --git a/app/models/user.rb b/app/models/user.rb index 3471bb2c1..daf8768e8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -244,7 +244,6 @@ class User < ApplicationRecord end def functional? - functional_or_moved? end diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index ca067ed9b..52ffaf717 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -32,6 +32,7 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer def id raise Mastodon::NotPermittedError, 'Local-only statuses should not be serialized' if object.local_only? && !instance_options[:allow_local_only] + ActivityPub::TagManager.instance.uri_for(object) end diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index e6c8fe4b2..d4e7ac974 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -91,7 +91,7 @@ class REST::AccountSerializer < ActiveModel::Serializer end def followers_count - (Setting.hide_followers_count || object.user&.setting_hide_followers_count) ? -1 : object.followers_count + Setting.hide_followers_count || object.user&.setting_hide_followers_count ? -1 : object.followers_count end def display_name diff --git a/app/serializers/rest/mute_serializer.rb b/app/serializers/rest/mute_serializer.rb index 043a2f059..c9b55ff16 100644 --- a/app/serializers/rest/mute_serializer.rb +++ b/app/serializers/rest/mute_serializer.rb @@ -2,7 +2,7 @@ class REST::MuteSerializer < ActiveModel::Serializer include RoutingHelper - + attributes :id, :account, :target_account, :created_at, :hide_notifications def account @@ -12,4 +12,4 @@ class REST::MuteSerializer < ActiveModel::Serializer def target_account REST::AccountSerializer.new(object.target_account) end -end \ No newline at end of file +end diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 659c45b83..eb5f3c3ea 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -13,7 +13,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :muted, if: :current_user? attribute :bookmarked, if: :current_user? attribute :pinned, if: :pinnable? - attribute :local_only if :local? + attribute :local_only, if: :local? has_many :filtered, serializer: REST::FilterResultSerializer, if: :current_user? attribute :content, unless: :source_requested? @@ -32,6 +32,8 @@ class REST::StatusSerializer < ActiveModel::Serializer has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer + delegate :local?, to: :object + def id object.id.to_s end diff --git a/app/services/backup_service.rb b/app/services/backup_service.rb index a9d740211..c5e7a8e58 100644 --- a/app/services/backup_service.rb +++ b/app/services/backup_service.rb @@ -154,7 +154,7 @@ class BackupService < BaseService object, serializer: serializer, adapter: ActivityPub::Adapter, - allow_local_only: true, + allow_local_only: true ).as_json end diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 8e74e152e..3b14a6748 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -116,7 +116,7 @@ class FanOutOnWriteService < BaseService end def deliver_to_direct_timelines! - FeedInsertWorker.push_bulk(@status.mentions.includes(:account).map(&:account).select { |mentioned_account| mentioned_account.local? }) do |account| + FeedInsertWorker.push_bulk(@status.mentions.includes(:account).map(&:account).select(&:local?)) do |account| [@status.id, account.id, 'direct', { 'update' => update? }] end end diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index bca3b3ff7..74ec47a33 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -61,17 +61,22 @@ class PostStatusService < BaseService private - def preprocess_attributes! - if @text.blank? && @options[:spoiler_text].present? - @text = '.' - if @media&.find(&:video?) || @media&.find(&:gifv?) - @text = '📹' - elsif @media&.find(&:audio?) - @text = '🎵' - elsif @media&.find(&:image?) - @text = '🖼' - end + def fill_blank_text! + return unless @text.blank? && @options[:spoiler_text].present? + + if @media&.any?(&:video?) || @media&.any?(&:gifv?) + @text = '📹' + elsif @media&.any?(&:audio?) + @text = '🎵' + elsif @media&.any?(&:image?) + @text = '🖼' + else + @text = '.' end + end + + def preprocess_attributes! + fill_blank_text! @sensitive = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present? @visibility = @options[:visibility] || @account.user&.setting_default_privacy @visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced? diff --git a/app/validators/status_pin_validator.rb b/app/validators/status_pin_validator.rb index 9466a81fe..4af7bd295 100644 --- a/app/validators/status_pin_validator.rb +++ b/app/validators/status_pin_validator.rb @@ -7,6 +7,6 @@ class StatusPinValidator < ActiveModel::Validator pin.errors.add(:base, I18n.t('statuses.pin_errors.reblog')) if pin.status.reblog? pin.errors.add(:base, I18n.t('statuses.pin_errors.ownership')) if pin.account_id != pin.status.account_id pin.errors.add(:base, I18n.t('statuses.pin_errors.direct')) if pin.status.direct_visibility? - pin.errors.add(:base, I18n.t('statuses.pin_errors.limit')) if pin.account.status_pins.count >= MAX_PINNED && pin.account.local? + pin.errors.add(:base, I18n.t('statuses.pin_errors.limit')) if pin.account.status_pins.count >= MAX_PINNED && pin.account.local? end end diff --git a/config/initializers/0_duplicate_migrations.rb b/config/initializers/0_duplicate_migrations.rb index 6c45e4bd2..1b8b59025 100644 --- a/config/initializers/0_duplicate_migrations.rb +++ b/config/initializers/0_duplicate_migrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Some migrations have been present in glitch-soc for a long time and have then # been merged in upstream Mastodon, under a different version number. # @@ -12,24 +14,26 @@ # we decided monkey-patching Rails' Migrator to completely ignore the duplicate, # keeping only the one that has run, or an arbitrary one. -ALLOWED_DUPLICATES = [20180410220657, 20180831171112].freeze +ALLOWED_DUPLICATES = [2018_04_10_220657, 2018_08_31_171112].freeze module ActiveRecord class Migrator def self.new(direction, migrations, schema_migration, target_version = nil) migrated = Set.new(Base.connection.migration_context.get_all_versions) - migrations.group_by(&:name).each do |name, duplicates| - if duplicates.length > 1 && duplicates.all? { |m| ALLOWED_DUPLICATES.include?(m.version) } - # We have a set of allowed duplicates. Keep the migrated one, if any. - non_migrated = duplicates.reject { |m| migrated.include?(m.version.to_i) } + migrations.group_by(&:name).each do |_name, duplicates| + next unless duplicates.length > 1 && duplicates.all? { |m| ALLOWED_DUPLICATES.include?(m.version) } + + # We have a set of allowed duplicates. Keep the migrated one, if any. + non_migrated = duplicates.reject { |m| migrated.include?(m.version.to_i) } - if duplicates.length == non_migrated.length || non_migrated.length == 0 + migrations = begin + if duplicates.length == non_migrated.length || non_migrated.empty? # There weren't any migrated one, so we have to pick one “canonical” migration - migrations = migrations - duplicates[1..-1] + migrations - duplicates[1..] else # Just reject every duplicate which hasn't been migrated yet - migrations = migrations - non_migrated + migrations - non_migrated end end end @@ -43,10 +47,10 @@ module ActiveRecord # A set of duplicated migrations is considered migrated if at least one of # them is migrated. migrated = get_all_versions - migrations.group_by(&:name).each do |name, duplicates| + migrations.group_by(&:name).each do |_name, duplicates| return true unless duplicates.any? { |m| migrated.include?(m.version.to_i) } end - return false + false end end end diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index d167a1600..fff4f538e 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -22,6 +22,7 @@ end module GlitchOnlyComponent def glitch_only(_wrapper_options = nil) return unless options[:glitch_only] + options[:label_text] = ->(raw_label_text, _required_label_text, _label_present) { safe_join([raw_label_text, ' ', content_tag(:span, I18n.t('simple_form.glitch_only'), class: 'glitch_only')]) } nil end diff --git a/db/migrate/20171009222537_create_keyword_mutes.rb b/db/migrate/20171009222537_create_keyword_mutes.rb index 66411ba1d..77c88b0a5 100644 --- a/db/migrate/20171009222537_create_keyword_mutes.rb +++ b/db/migrate/20171009222537_create_keyword_mutes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateKeywordMutes < ActiveRecord::Migration[5.1] def change create_table :keyword_mutes do |t| diff --git a/db/migrate/20171021191900_move_keyword_mutes_into_glitch_namespace.rb b/db/migrate/20171021191900_move_keyword_mutes_into_glitch_namespace.rb index 269bb49d6..b6ea537c2 100644 --- a/db/migrate/20171021191900_move_keyword_mutes_into_glitch_namespace.rb +++ b/db/migrate/20171021191900_move_keyword_mutes_into_glitch_namespace.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MoveKeywordMutesIntoGlitchNamespace < ActiveRecord::Migration[5.1] def change safety_assured do diff --git a/db/migrate/20171210213213_add_local_only_flag_to_statuses.rb b/db/migrate/20171210213213_add_local_only_flag_to_statuses.rb index af1e29d6a..010503b10 100644 --- a/db/migrate/20171210213213_add_local_only_flag_to_statuses.rb +++ b/db/migrate/20171210213213_add_local_only_flag_to_statuses.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddLocalOnlyFlagToStatuses < ActiveRecord::Migration[5.1] def change add_column :statuses, :local_only, :boolean diff --git a/db/migrate/20180410220657_create_bookmarks.rb b/db/migrate/20180410220657_create_bookmarks.rb index bc79022e4..aba21f5ea 100644 --- a/db/migrate/20180410220657_create_bookmarks.rb +++ b/db/migrate/20180410220657_create_bookmarks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration is a duplicate of 20180831171112 and may get ignored, see # config/initializers/0_duplicate_migrations.rb diff --git a/db/migrate/20180604000556_add_apply_to_mentions_flag_to_keyword_mutes.rb b/db/migrate/20180604000556_add_apply_to_mentions_flag_to_keyword_mutes.rb index cd97d0f20..8078a07bf 100644 --- a/db/migrate/20180604000556_add_apply_to_mentions_flag_to_keyword_mutes.rb +++ b/db/migrate/20180604000556_add_apply_to_mentions_flag_to_keyword_mutes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'mastodon/migration_helpers' class AddApplyToMentionsFlagToKeywordMutes < ActiveRecord::Migration[5.2] diff --git a/db/migrate/20180707193142_migrate_filters.rb b/db/migrate/20180707193142_migrate_filters.rb index 067c53357..8f6b3e1bb 100644 --- a/db/migrate/20180707193142_migrate_filters.rb +++ b/db/migrate/20180707193142_migrate_filters.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class MigrateFilters < ActiveRecord::Migration[5.2] class GlitchKeywordMute < ApplicationRecord # Dummy class, as we removed Glitch::KeywordMute - belongs_to :account, required: true + belongs_to :account, optional: false validates_presence_of :keyword end @@ -15,7 +17,7 @@ class MigrateFilters < ActiveRecord::Migration[5.2] private def clean_up_contexts - self.context = Array(context).map(&:strip).map(&:presence).compact + self.context = Array(context).map(&:strip).filter_map(&:presence) end end @@ -27,7 +29,8 @@ class MigrateFilters < ActiveRecord::Migration[5.2] phrase: filter.keyword, context: filter.apply_to_mentions ? %w(home public notifications) : %w(home public), whole_word: filter.whole_word, - irreversible: true) + irreversible: true + ) end end @@ -48,7 +51,8 @@ class MigrateFilters < ActiveRecord::Migration[5.2] GlitchKeywordMute.where(account: filter.account).create!( keyword: filter.phrase, whole_word: filter.whole_word, - apply_to_mentions: filter.context.include?('notifications')) + apply_to_mentions: filter.context.include?('notifications') + ) end end end diff --git a/db/migrate/20190512200918_add_content_type_to_statuses.rb b/db/migrate/20190512200918_add_content_type_to_statuses.rb index efbe2caa7..31c1a4f17 100644 --- a/db/migrate/20190512200918_add_content_type_to_statuses.rb +++ b/db/migrate/20190512200918_add_content_type_to_statuses.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddContentTypeToStatuses < ActiveRecord::Migration[5.2] def change add_column :statuses, :content_type, :string diff --git a/db/migrate/20220209175231_add_content_type_to_status_edits.rb b/db/migrate/20220209175231_add_content_type_to_status_edits.rb index 0e4e52fcb..bb414535d 100644 --- a/db/migrate/20220209175231_add_content_type_to_status_edits.rb +++ b/db/migrate/20220209175231_add_content_type_to_status_edits.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddContentTypeToStatusEdits < ActiveRecord::Migration[6.1] def change add_column :status_edits, :content_type, :string diff --git a/db/post_migrate/20180813160548_post_migrate_filters.rb b/db/post_migrate/20180813160548_post_migrate_filters.rb index 588548c1d..82acf13d5 100644 --- a/db/post_migrate/20180813160548_post_migrate_filters.rb +++ b/db/post_migrate/20180813160548_post_migrate_filters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class PostMigrateFilters < ActiveRecord::Migration[5.2] disable_ddl_transaction! @@ -5,7 +7,5 @@ class PostMigrateFilters < ActiveRecord::Migration[5.2] drop_table :glitch_keyword_mutes if table_exists? :glitch_keyword_mutes end - def down - end + def down; end end - diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index dfc586561..4c0e9b858 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -48,9 +48,9 @@ class Sanitize node.content = "[🖼 #{node['alt']}]" else url = node['href'] - prefix = url.match(/\Ahttps?:\/\/(www\.)?/).to_s + prefix = url.match(%r{\Ahttps?://(www\.)?}).to_s text = url[prefix.length, 30] - text = text + "…" if url[prefix.length..-1].length > 30 + text += '…' if url.length - prefix.length > 30 node.content = "[🖼 #{text}]" end end @@ -88,7 +88,7 @@ class Sanitize }, protocols: { - 'a' => { 'href' => LINK_PROTOCOLS }, + 'a' => { 'href' => LINK_PROTOCOLS }, 'blockquote' => { 'cite' => LINK_PROTOCOLS }, }, @@ -126,7 +126,7 @@ class Sanitize node = env[:node] - rel = (node['rel'] || '').split(' ') & ['tag'] + rel = (node['rel'] || '').split & ['tag'] rel += ['nofollow', 'noopener', 'noreferrer'] unless TagManager.instance.local_url?(node['href']) if rel.empty? diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index e1102af33..76e190f70 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -3,14 +3,14 @@ namespace :assets do desc 'Generate static pages' task generate_static_pages: :environment do - class StaticApplicationController < ApplicationController - def current_user - nil + def render_static_page(action, dest:, **opts) + renderer = Class.new(ApplicationController) do + def current_user + nil + end end - end - def render_static_page(action, dest:, **opts) - html = StaticApplicationController.render(action, opts) + html = renderer.render(action, opts) File.write(dest, html) end diff --git a/lib/tasks/glitchsoc.rake b/lib/tasks/glitchsoc.rake index 79e864648..72558fa19 100644 --- a/lib/tasks/glitchsoc.rake +++ b/lib/tasks/glitchsoc.rake @@ -1,8 +1,12 @@ +# frozen_string_literal: true + namespace :glitchsoc do desc 'Backfill local-only flag on statuses table' task backfill_local_only: :environment do - Status.local.where(local_only: nil).find_each do |st| - ActiveRecord::Base.logger.silence { st.update_attribute(:local_only, st.marked_local_only?) } + Status.local.where(local_only: nil).find_each do |status| + ActiveRecord::Base.logger.silence do + status.update_attribute(:local_only, status.marked_local_only?) # rubocop:disable Rails/SkipsModelValidations + end end end end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index de08dd524..a677aaad0 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -75,10 +75,10 @@ describe Api::V1::Accounts::CredentialsController do end end - describe 'with invalid data' do + describe 'with a too long profile bio' do before do note = 'This is too long. ' - note = note + 'a' * (Account::MAX_NOTE_LENGTH - note.length + 1) + note += 'a' * (Account::MAX_NOTE_LENGTH - note.length + 1) patch :update, params: { note: note } end diff --git a/spec/controllers/api/v1/timelines/direct_controller_spec.rb b/spec/controllers/api/v1/timelines/direct_controller_spec.rb index a22c2cbea..def67a0fe 100644 --- a/spec/controllers/api/v1/timelines/direct_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/direct_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Api::V1::Timelines::DirectController, type: :controller do +RSpec.describe Api::V1::Timelines::DirectController do let(:user) { Fabricate(:user) } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses') } diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 1aabae0ea..82455d874 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -75,8 +75,8 @@ describe ApplicationController, type: :controller do describe 'helper_method :current_flavour' do it 'returns "glitch" when theme wasn\'t changed in admin settings' do - allow(Setting).to receive(:default_settings).and_return({'skin' => 'default'}) - allow(Setting).to receive(:default_settings).and_return({'flavour' => 'glitch'}) + allow(Setting).to receive(:default_settings).and_return({ 'skin' => 'default' }) + allow(Setting).to receive(:default_settings).and_return({ 'flavour' => 'glitch' }) expect(controller.view_context.current_flavour).to eq 'glitch' end diff --git a/spec/controllers/settings/flavours_controller_spec.rb b/spec/controllers/settings/flavours_controller_spec.rb index f89bde1f9..8c7d4a768 100644 --- a/spec/controllers/settings/flavours_controller_spec.rb +++ b/spec/controllers/settings/flavours_controller_spec.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true + require 'rails_helper' -RSpec.describe Settings::FlavoursController, type: :controller do +RSpec.describe Settings::FlavoursController do let(:user) { Fabricate(:user) } before do diff --git a/spec/lib/advanced_text_formatter_spec.rb b/spec/lib/advanced_text_formatter_spec.rb index c1e469606..8b27b56a1 100644 --- a/spec/lib/advanced_text_formatter_spec.rb +++ b/spec/lib/advanced_text_formatter_spec.rb @@ -1,12 +1,14 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe AdvancedTextFormatter do describe '#to_s' do + subject { described_class.new(text, preloaded_accounts: preloaded_accounts, content_type: content_type).to_s } + let(:preloaded_accounts) { nil } let(:content_type) { 'text/markdown' } - subject { described_class.new(text, preloaded_accounts: preloaded_accounts, content_type: content_type).to_s } - context 'given a markdown source' do let(:content_type) { 'text/markdown' } @@ -14,7 +16,7 @@ RSpec.describe AdvancedTextFormatter do let(:text) { 'text' } it 'paragraphizes the text' do - is_expected.to eq '

text

' + expect(subject).to eq '

text

' end end @@ -22,7 +24,7 @@ RSpec.describe AdvancedTextFormatter do let(:text) { "line\nfeed" } it 'removes line feeds' do - is_expected.not_to include "\n" + expect(subject).to_not include "\n" end end @@ -30,7 +32,7 @@ RSpec.describe AdvancedTextFormatter do let(:text) { 'test `foo` bar' } it 'formats code using ' do - is_expected.to include 'test foo bar' + expect(subject).to include 'test foo bar' end end @@ -38,15 +40,15 @@ RSpec.describe AdvancedTextFormatter do let(:text) { "test\n\n```\nint main(void) {\n return 0; // https://joinmastodon.org/foo\n}\n```\n" } it 'formats code using
 and ' do
-          is_expected.to include '
int main'
+          expect(subject).to include '
int main'
         end
 
         it 'does not strip leading spaces' do
-          is_expected.to include '>  return 0'
+          expect(subject).to include '>  return 0'
         end
 
         it 'does not format links' do
-          is_expected.to include 'return 0; // https://joinmastodon.org/foo'
+          expect(subject).to include 'return 0; // https://joinmastodon.org/foo'
         end
       end
 
@@ -54,7 +56,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'test `https://foo.bar/bar` bar' }
 
         it 'does not rewrite the link' do
-          is_expected.to include 'test https://foo.bar/bar bar'
+          expect(subject).to include 'test https://foo.bar/bar bar'
         end
       end
 
@@ -62,7 +64,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'foo https://cb6e6126.ngrok.io/about/more' }
 
         it 'creates a link' do
-          is_expected.to include '@alice'
+          expect(subject).to include '@alice'
         end
       end
 
@@ -80,7 +82,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '@alice' }
 
         it 'does not create a mention link' do
-          is_expected.to include '@alice'
+          expect(subject).to include '@alice'
         end
       end
 
@@ -88,7 +90,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4"'
+          expect(subject).to include 'href="https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4"'
         end
       end
 
@@ -96,7 +98,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://google.com' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="http://google.com"'
+          expect(subject).to include 'href="http://google.com"'
         end
       end
 
@@ -104,7 +106,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://example.gay' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="http://example.gay"'
+          expect(subject).to include 'href="http://example.gay"'
         end
       end
 
@@ -112,11 +114,11 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://nic.みんな/' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://nic.みんな/"'
+          expect(subject).to include 'href="https://nic.みんな/"'
         end
 
         it 'has display URL' do
-          is_expected.to include 'nic.みんな/'
+          expect(subject).to include 'nic.みんな/'
         end
       end
 
@@ -124,7 +126,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona. ' }
 
         it 'matches the full URL but not the period' do
-          is_expected.to include 'href="http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona"'
+          expect(subject).to include 'href="http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona"'
         end
       end
 
@@ -132,7 +134,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '(http://google.com/)' }
 
         it 'matches the full URL but not the parentheses' do
-          is_expected.to include 'href="http://google.com/"'
+          expect(subject).to include 'href="http://google.com/"'
         end
       end
 
@@ -140,7 +142,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://www.google.com!' }
 
         it 'matches the full URL but not the exclamation point' do
-          is_expected.to include 'href="http://www.google.com"'
+          expect(subject).to include 'href="http://www.google.com"'
         end
       end
 
@@ -148,7 +150,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { "http://www.google.com'" }
 
         it 'matches the full URL but not the single quote' do
-          is_expected.to include 'href="http://www.google.com"'
+          expect(subject).to include 'href="http://www.google.com"'
         end
       end
     end
@@ -157,7 +159,7 @@ RSpec.describe AdvancedTextFormatter do
       let(:text) { 'http://www.google.com>' }
 
       it 'matches the full URL but not the angle bracket' do
-        is_expected.to include 'href="http://www.google.com"'
+        expect(subject).to include 'href="http://www.google.com"'
       end
     end
 
@@ -166,7 +168,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink"'
         end
       end
 
@@ -174,7 +176,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=✓&q=autolink' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=✓&q=autolink"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=✓&q=autolink"'
         end
       end
 
@@ -182,7 +184,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=✓' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=✓"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=✓"'
         end
       end
 
@@ -190,7 +192,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&utf81=✓&q=autolink' }
 
         it 'preserves escaped unicode characters' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&utf81=✓&q=autolink"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&utf81=✓&q=autolink"'
         end
       end
 
@@ -198,7 +200,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://en.wikipedia.org/wiki/Diaspora_(software)' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://en.wikipedia.org/wiki/Diaspora_(software)"'
+          expect(subject).to include 'href="https://en.wikipedia.org/wiki/Diaspora_(software)"'
         end
       end
 
@@ -206,7 +208,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '"https://example.com/"' }
 
         it 'does not match the quotation marks' do
-          is_expected.to include 'href="https://example.com/"'
+          expect(subject).to include 'href="https://example.com/"'
         end
       end
 
@@ -214,19 +216,19 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '' }
 
         it 'does not match the angle brackets' do
-          is_expected.to include 'href="https://example.com/"'
+          expect(subject).to include 'href="https://example.com/"'
         end
       end
 
       context 'given a URL containing unsafe code (XSS attack, invisible part)' do
-        let(:text) { %q{http://example.com/blahblahblahblah/a} }
+        let(:text) { 'http://example.com/blahblahblahblah/a' }
 
         it 'does not include the HTML in the URL' do
-          is_expected.to include '"http://example.com/blahblahblahblah/a"'
+          expect(subject).to include '"http://example.com/blahblahblahblah/a"'
         end
 
         it 'does not include a script tag' do
-          is_expected.to_not include '' }
 
         it 'does not include a script tag' do
-          is_expected.to_not include '