From 6883fddb19b1319a378aa5dc2034670c3b27ce39 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 24 Jan 2023 19:40:21 +0100 Subject: Fix account activation being triggered before email confirmation (#23245) * Add tests * Fix account activation being triggered before email confirmation Fixes #23098 --- spec/models/user_spec.rb | 134 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 4 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a7da31e60..4b3d6101f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -142,10 +142,136 @@ RSpec.describe User, type: :model do end describe '#confirm' do - it 'sets email to unconfirmed_email' do - user = Fabricate.build(:user, confirmed_at: Time.now.utc, unconfirmed_email: 'new-email@example.com') - user.confirm - expect(user.email).to eq 'new-email@example.com' + let(:new_email) { 'new-email@example.com' } + + subject { user.confirm } + + before do + allow(TriggerWebhookWorker).to receive(:perform_async) + end + + context 'when the user is already confirmed' do + let!(:user) { Fabricate(:user, confirmed_at: Time.now.utc, approved: true, unconfirmed_email: new_email) } + + it 'sets email to unconfirmed_email' do + expect { subject }.to change { user.reload.email }.to(new_email) + end + + it 'does not trigger the account.approved Web Hook' do + subject + expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id) + end + end + + context 'when the user is a new user' do + let(:user) { Fabricate(:user, confirmed_at: nil, unconfirmed_email: new_email) } + + context 'when the user is already approved' do + around(:example) do |example| + registrations_mode = Setting.registrations_mode + Setting.registrations_mode = 'approved' + + example.run + + Setting.registrations_mode = registrations_mode + end + + before do + user.approve! + end + + it 'sets email to unconfirmed_email' do + expect { subject }.to change { user.reload.email }.to(new_email) + end + + it 'triggers the account.approved Web Hook' do + user.confirm + expect(TriggerWebhookWorker).to have_received(:perform_async).with('account.approved', 'Account', user.account_id).once + end + end + + context 'when the user does not require explicit approval' do + around(:example) do |example| + registrations_mode = Setting.registrations_mode + Setting.registrations_mode = 'open' + + example.run + + Setting.registrations_mode = registrations_mode + end + + it 'sets email to unconfirmed_email' do + expect { subject }.to change { user.reload.email }.to(new_email) + end + + it 'triggers the account.approved Web Hook' do + user.confirm + expect(TriggerWebhookWorker).to have_received(:perform_async).with('account.approved', 'Account', user.account_id).once + end + end + + context 'when the user requires explicit approval but is not approved' do + around(:example) do |example| + registrations_mode = Setting.registrations_mode + Setting.registrations_mode = 'approved' + + example.run + + Setting.registrations_mode = registrations_mode + end + + it 'sets email to unconfirmed_email' do + expect { subject }.to change { user.reload.email }.to(new_email) + end + + it 'does not trigger the account.approved Web Hook' do + subject + expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id) + end + end + end + end + + describe '#approve!' do + subject { user.approve! } + + around(:example) do |example| + registrations_mode = Setting.registrations_mode + Setting.registrations_mode = 'approved' + + example.run + + Setting.registrations_mode = registrations_mode + end + + before do + allow(TriggerWebhookWorker).to receive(:perform_async) + end + + context 'when the user is already confirmed' do + let(:user) { Fabricate(:user, confirmed_at: Time.now.utc, approved: false) } + + it 'sets the approved flag' do + expect { subject }.to change { user.reload.approved? }.to(true) + end + + it 'triggers the account.approved Web Hook' do + subject + expect(TriggerWebhookWorker).to have_received(:perform_async).with('account.approved', 'Account', user.account_id).once + end + end + + context 'when the user is not confirmed' do + let(:user) { Fabricate(:user, confirmed_at: nil, approved: false) } + + it 'sets the approved flag' do + expect { subject }.to change { user.reload.approved? }.to(true) + end + + it 'does not trigger the account.approved Web Hook' do + subject + expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id) + end end end -- 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/models/user_spec.rb') 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 54318dcd6d4a22a24c5d8afb7c950bed43df3964 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 21:24:16 -0500 Subject: Autofix Rubocop RSpec/ClassCheck (#23685) --- .rubocop_todo.yml | 14 --------- spec/lib/settings/extend_spec.rb | 2 +- spec/models/concerns/account_interactions_spec.rb | 36 +++++++++++------------ spec/models/custom_emoji_filter_spec.rb | 10 +++---- spec/models/session_activation_spec.rb | 4 +-- spec/models/setting_spec.rb | 6 ++-- spec/models/user_role_spec.rb | 4 +-- spec/models/user_spec.rb | 2 +- 8 files changed, 32 insertions(+), 46 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b9971a610..66890b3d7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -630,20 +630,6 @@ RSpec/Capybara/FeatureMethods: - 'spec/features/log_in_spec.rb' - 'spec/features/profile_spec.rb' -# Offense count: 32 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: be_a, be_kind_of -RSpec/ClassCheck: - Exclude: - - 'spec/lib/settings/extend_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - - 'spec/models/custom_emoji_filter_spec.rb' - - 'spec/models/session_activation_spec.rb' - - 'spec/models/setting_spec.rb' - - 'spec/models/user_role_spec.rb' - - 'spec/models/user_spec.rb' - # Offense count: 558 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without diff --git a/spec/lib/settings/extend_spec.rb b/spec/lib/settings/extend_spec.rb index 83ced4230..ea623137b 100644 --- a/spec/lib/settings/extend_spec.rb +++ b/spec/lib/settings/extend_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Settings::Extend do describe '#settings' do it 'sets @settings as an instance of Settings::ScopedSettings' do user = Fabricate(:user) - expect(user.settings).to be_kind_of Settings::ScopedSettings + expect(user.settings).to be_a Settings::ScopedSettings end end end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index e628384d0..755c71314 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -94,7 +94,7 @@ describe AccountInteractions do describe '#follow!' do it 'creates and returns Follow' do expect do - expect(account.follow!(target_account)).to be_kind_of Follow + expect(account.follow!(target_account)).to be_a Follow end.to change { account.following.count }.by 1 end end @@ -102,7 +102,7 @@ describe AccountInteractions do describe '#block' do it 'creates and returns Block' do expect do - expect(account.block!(target_account)).to be_kind_of Block + expect(account.block!(target_account)).to be_a Block end.to change { account.block_relationships.count }.by 1 end end @@ -116,7 +116,7 @@ describe AccountInteractions do it 'creates Mute, and returns Mute' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.to change { account.mute_relationships.count }.by 1 end end @@ -126,7 +126,7 @@ describe AccountInteractions do it 'creates Mute, and returns Mute' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.to change { account.mute_relationships.count }.by 1 end end @@ -136,7 +136,7 @@ describe AccountInteractions do it 'creates Mute, and returns Mute' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.to change { account.mute_relationships.count }.by 1 end end @@ -162,7 +162,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end @@ -172,7 +172,7 @@ describe AccountInteractions do it 'returns Mute, and updates mute.hide_notifications false' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end @@ -182,7 +182,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end @@ -196,7 +196,7 @@ describe AccountInteractions do it 'returns Mute, and updates mute.hide_notifications true' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end @@ -206,7 +206,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.not_to change { mute.reload.hide_notifications? }.from(false) end end @@ -216,7 +216,7 @@ describe AccountInteractions do it 'returns Mute, and updates mute.hide_notifications true' do expect do - expect(subject).to be_kind_of Mute + expect(subject).to be_a Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end @@ -231,7 +231,7 @@ describe AccountInteractions do it 'creates and returns ConversationMute' do expect do - is_expected.to be_kind_of ConversationMute + is_expected.to be_a ConversationMute end.to change { account.conversation_mutes.count }.by 1 end end @@ -243,7 +243,7 @@ describe AccountInteractions do it 'creates and returns AccountDomainBlock' do expect do - is_expected.to be_kind_of AccountDomainBlock + is_expected.to be_a AccountDomainBlock end.to change { account.domain_blocks.count }.by 1 end end @@ -254,7 +254,7 @@ describe AccountInteractions do context 'following target_account' do it 'returns destroyed Follow' do account.active_relationships.create(target_account: target_account) - is_expected.to be_kind_of Follow + is_expected.to be_a Follow expect(subject).to be_destroyed end end @@ -272,7 +272,7 @@ describe AccountInteractions do context 'blocking target_account' do it 'returns destroyed Block' do account.block_relationships.create(target_account: target_account) - is_expected.to be_kind_of Block + is_expected.to be_a Block expect(subject).to be_destroyed end end @@ -290,7 +290,7 @@ describe AccountInteractions do context 'muting target_account' do it 'returns destroyed Mute' do account.mute_relationships.create(target_account: target_account) - is_expected.to be_kind_of Mute + is_expected.to be_a Mute expect(subject).to be_destroyed end end @@ -310,7 +310,7 @@ describe AccountInteractions do context 'muting the conversation' do it 'returns destroyed ConversationMute' do account.conversation_mutes.create(conversation: conversation) - is_expected.to be_kind_of ConversationMute + is_expected.to be_a ConversationMute expect(subject).to be_destroyed end end @@ -331,7 +331,7 @@ describe AccountInteractions do it 'returns destroyed AccountDomainBlock' do account_domain_block = Fabricate(:account_domain_block, domain: domain) account.domain_blocks << account_domain_block - is_expected.to be_kind_of AccountDomainBlock + is_expected.to be_a AccountDomainBlock expect(subject).to be_destroyed end end diff --git a/spec/models/custom_emoji_filter_spec.rb b/spec/models/custom_emoji_filter_spec.rb index 2b1b5dc54..515c0a715 100644 --- a/spec/models/custom_emoji_filter_spec.rb +++ b/spec/models/custom_emoji_filter_spec.rb @@ -15,7 +15,7 @@ RSpec.describe CustomEmojiFilter do let(:params) { { local: true } } it 'returns ActiveRecord::Relation' do - expect(subject).to be_kind_of(ActiveRecord::Relation) + expect(subject).to be_a(ActiveRecord::Relation) expect(subject).to match_array([custom_emoji_2]) end end @@ -24,7 +24,7 @@ RSpec.describe CustomEmojiFilter do let(:params) { { remote: true } } it 'returns ActiveRecord::Relation' do - expect(subject).to be_kind_of(ActiveRecord::Relation) + expect(subject).to be_a(ActiveRecord::Relation) expect(subject).to match_array([custom_emoji_0, custom_emoji_1]) end end @@ -33,7 +33,7 @@ RSpec.describe CustomEmojiFilter do let(:params) { { by_domain: 'a' } } it 'returns ActiveRecord::Relation' do - expect(subject).to be_kind_of(ActiveRecord::Relation) + expect(subject).to be_a(ActiveRecord::Relation) expect(subject).to match_array([custom_emoji_0]) end end @@ -42,7 +42,7 @@ RSpec.describe CustomEmojiFilter do let(:params) { { shortcode: 'hoge' } } it 'returns ActiveRecord::Relation' do - expect(subject).to be_kind_of(ActiveRecord::Relation) + expect(subject).to be_a(ActiveRecord::Relation) expect(subject).to match_array([custom_emoji_2]) end end @@ -62,7 +62,7 @@ RSpec.describe CustomEmojiFilter do let(:params) { { hoge: nil } } it 'returns ActiveRecord::Relation' do - expect(subject).to be_kind_of(ActiveRecord::Relation) + expect(subject).to be_a(ActiveRecord::Relation) expect(subject).to match_array([custom_emoji_0, custom_emoji_1, custom_emoji_2]) end end diff --git a/spec/models/session_activation_spec.rb b/spec/models/session_activation_spec.rb index 5c3d285cb..26f2b561a 100644 --- a/spec/models/session_activation_spec.rb +++ b/spec/models/session_activation_spec.rb @@ -7,7 +7,7 @@ RSpec.describe SessionActivation, type: :model do let(:session_activation) { Fabricate(:session_activation, user_agent: 'Chrome/62.0.3202.89') } it 'sets a Browser instance as detection' do - expect(session_activation.detection).to be_kind_of Browser::Chrome + expect(session_activation.detection).to be_a Browser::Chrome end end @@ -80,7 +80,7 @@ RSpec.describe SessionActivation, type: :model do end it 'returns an instance of SessionActivation' do - expect(described_class.activate(**options)).to be_kind_of SessionActivation + expect(described_class.activate(**options)).to be_a SessionActivation end end diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 3ccc21d6c..83ba415a8 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -127,7 +127,7 @@ RSpec.describe Setting, type: :model do let(:records) { [original_setting] } it 'returns a Hash' do - expect(described_class.all_as_records).to be_kind_of Hash + expect(described_class.all_as_records).to be_a Hash end context 'records includes Setting with var as the key' do @@ -146,7 +146,7 @@ RSpec.describe Setting, type: :model do it 'includes Setting with value of default_value' do setting = described_class.all_as_records[key] - expect(setting).to be_kind_of Setting + expect(setting).to be_a Setting expect(setting).to have_attributes(var: key) expect(setting).to have_attributes(value: 'default_value') end @@ -181,7 +181,7 @@ RSpec.describe Setting, type: :model do let(:enabled) { true } it 'returns instance of RailsSettings::Default' do - is_expected.to be_kind_of RailsSettings::Default + is_expected.to be_a RailsSettings::Default end end end diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 7294d14fe..52a8622f9 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -127,7 +127,7 @@ RSpec.describe UserRole, type: :model do subject { described_class.everyone } it 'returns a role' do - expect(subject).to be_kind_of(described_class) + expect(subject).to be_a(described_class) end it 'is identified as the everyone role' do @@ -147,7 +147,7 @@ RSpec.describe UserRole, type: :model do subject { described_class.nobody } it 'returns a role' do - expect(subject).to be_kind_of(described_class) + expect(subject).to be_a(described_class) end it 'is identified as the nobody role' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 1f2ab77dc..139d8784b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -313,7 +313,7 @@ RSpec.describe User, type: :model do describe 'settings' do it 'is instance of Settings::ScopedSettings' do user = Fabricate(:user) - expect(user.settings).to be_kind_of Settings::ScopedSettings + expect(user.settings).to be_a Settings::ScopedSettings end end -- cgit From c0a645f6474749fede8371c4dd778fbc22e3c797 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 21:26:20 -0500 Subject: Autofix Rubocop RSpec/ExampleWording (#23667) --- .rubocop_todo.yml | 10 ---------- spec/controllers/settings/applications_controller_spec.rb | 4 ++-- spec/models/custom_emoji_spec.rb | 2 +- spec/models/user_spec.rb | 14 +++++++------- 4 files changed, 10 insertions(+), 20 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index aa47a05fb..b296c810e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -907,16 +907,6 @@ RSpec/EmptyLineAfterSubject: RSpec/ExampleLength: Max: 22 -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. -# DisallowedExamples: works -RSpec/ExampleWording: - Exclude: - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/models/custom_emoji_spec.rb' - - 'spec/models/user_spec.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). RSpec/ExcessiveDocstringSpacing: diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 9074574e4..b79a38ea1 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -37,7 +37,7 @@ describe Settings::ApplicationsController do end describe 'GET #new' do - it 'works' do + it 'returns http success' do get :new expect(response).to have_http_status(200) end @@ -180,7 +180,7 @@ describe Settings::ApplicationsController do post :regenerate, params: { id: app.id } end - it 'should create new token' do + it 'creates new token' do expect(user.token_for_app(app)).to_not eql(token) end end diff --git a/spec/models/custom_emoji_spec.rb b/spec/models/custom_emoji_spec.rb index 9de218b4f..f9e1099c6 100644 --- a/spec/models/custom_emoji_spec.rb +++ b/spec/models/custom_emoji_spec.rb @@ -79,7 +79,7 @@ RSpec.describe CustomEmoji, type: :model do describe 'pre_validation' do let(:custom_emoji) { Fabricate(:custom_emoji, domain: 'wWw.MaStOdOn.CoM') } - it 'should downcase' do + it 'downcases' do custom_emoji.valid? expect(custom_emoji.domain).to eq('www.mastodon.com') end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 139d8784b..368165f16 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -110,19 +110,19 @@ RSpec.describe User, type: :model do Rails.configuration.x.email_domains_blacklist = old_blacklist end - it 'should allow a non-blacklisted user to be created' do + it 'allows a non-blacklisted user to be created' do user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true) expect(user.valid?).to be_truthy end - it 'should not allow a blacklisted user to be created' do + it 'does not allow a blacklisted user to be created' do user = User.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true) expect(user.valid?).to be_falsey end - it 'should not allow a subdomain blacklisted user to be created' do + it 'does not allow a subdomain blacklisted user to be created' do user = User.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true) expect(user.valid?).to be_falsey @@ -346,17 +346,17 @@ RSpec.describe User, type: :model do Rails.configuration.x.email_domains_whitelist = old_whitelist end - it 'should not allow a user to be created unless they are whitelisted' do + it 'does not allow a user to be created unless they are whitelisted' do user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true) expect(user.valid?).to be_falsey end - it 'should allow a user to be created if they are whitelisted' do + it 'allows a user to be created if they are whitelisted' do user = User.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true) expect(user.valid?).to be_truthy end - it 'should not allow a user with a whitelisted top domain as subdomain in their email address to be created' do + it 'does not allow a user with a whitelisted top domain as subdomain in their email address to be created' do user = User.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true) expect(user.valid?).to be_falsey end @@ -368,7 +368,7 @@ RSpec.describe User, type: :model do Rails.configuration.x.email_domains_blacklist = old_blacklist end - it 'should not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do + it 'does not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space' user = User.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password) -- cgit From ac3561098e9cd1fd1ccee558295eb9f3430099d6 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sat, 18 Feb 2023 17:17:59 -0500 Subject: Autofix Rubocop RSpec/LetBeforeExamples (#23671) --- .rubocop_todo.yml | 6 ------ spec/models/user_spec.rb | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 83b2a37aa..1c22c440b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1121,12 +1121,6 @@ RSpec/LeakyConstantDeclaration: - 'spec/lib/settings/extend_spec.rb' - 'spec/models/concerns/remotable_spec.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -RSpec/LetBeforeExamples: - Exclude: - - 'spec/models/user_spec.rb' - # Offense count: 108 RSpec/LetSetup: Exclude: diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 368165f16..dde1503c0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,6 +2,9 @@ require 'rails_helper' require 'devise_two_factor/spec_helpers' RSpec.describe User, type: :model do + let(:password) { 'abcd1234' } + let(:account) { Fabricate(:account, username: 'alice') } + it_behaves_like 'two_factor_backupable' describe 'otp_secret' do @@ -96,9 +99,6 @@ RSpec.describe User, type: :model do end end - let(:account) { Fabricate(:account, username: 'alice') } - let(:password) { 'abcd1234' } - describe 'blacklist' do around(:each) do |example| old_blacklist = Rails.configuration.x.email_blacklist -- cgit From 65ba0d92ef78f82a3cf5bf04f13b3d7393da015d Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 20:33:27 -0500 Subject: Enable Rubocop RSpec/NotToNot (#23723) --- .rubocop.yml | 3 + .rubocop_todo.yml | 123 --------------------- .../activitypub/collections_controller_spec.rb | 4 +- .../activitypub/inboxes_controller_spec.rb | 6 +- .../account_moderation_notes_controller_spec.rb | 2 +- spec/controllers/admin/accounts_controller_spec.rb | 12 +- .../admin/change_email_controller_spec.rb | 2 +- .../admin/confirmations_controller_spec.rb | 2 +- .../admin/domain_blocks_controller_spec.rb | 2 +- .../admin/report_notes_controller_spec.rb | 4 +- .../settings/profiles_controller_spec.rb | 2 +- .../well_known/nodeinfo_controller_spec.rb | 2 +- spec/lib/activitypub/activity/announce_spec.rb | 2 +- spec/lib/request_spec.rb | 2 +- spec/lib/status_filter_spec.rb | 4 +- spec/lib/text_formatter_spec.rb | 2 +- spec/models/account_spec.rb | 10 +- spec/models/concerns/account_interactions_spec.rb | 6 +- spec/models/concerns/remotable_spec.rb | 4 +- spec/models/public_feed_spec.rb | 28 ++--- spec/models/setting_spec.rb | 4 +- spec/models/tag_spec.rb | 6 +- spec/models/user_spec.rb | 4 +- spec/services/account_search_service_spec.rb | 2 +- .../activitypub/process_collection_service_spec.rb | 10 +- .../process_status_update_service_spec.rb | 4 +- spec/services/block_domain_service_spec.rb | 6 +- spec/services/clear_domain_media_service_spec.rb | 6 +- spec/services/import_service_spec.rb | 2 +- spec/services/post_status_service_spec.rb | 4 +- spec/services/search_service_spec.rb | 6 +- .../validators/blacklisted_email_validator_spec.rb | 2 +- .../disallowed_hashtags_validator_spec.rb | 4 +- spec/validators/email_mx_validator_spec.rb | 2 +- spec/validators/follow_limit_validator_spec.rb | 4 +- spec/validators/poll_validator_spec.rb | 4 +- spec/validators/status_length_validator_spec.rb | 4 +- .../unreserved_username_validator_spec.rb | 4 +- spec/validators/url_validator_spec.rb | 2 +- spec/workers/feed_insert_worker_spec.rb | 6 +- 40 files changed, 94 insertions(+), 214 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/.rubocop.yml b/.rubocop.yml index 3783ccf48..fc1969a64 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -94,6 +94,9 @@ Rails/Exit: - 'lib/mastodon/cli_helper.rb' - 'lib/cli.rb' +RSpec/NotToNot: + EnforcedStyle: to_not + Style/HashSyntax: EnforcedStyle: ruby19_no_mixed_keys diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 73ebdbfd8..9076891e2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1440,129 +1440,6 @@ RSpec/NoExpectationExample: - 'spec/controllers/auth/registrations_controller_spec.rb' - 'spec/services/precompute_feed_service_spec.rb' -# Offense count: 370 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: not_to, to_not -RSpec/NotToNot: - Exclude: - - 'spec/config/initializers/rack_attack_spec.rb' - - 'spec/controllers/accounts_controller_spec.rb' - - 'spec/controllers/admin/accounts_controller_spec.rb' - - 'spec/controllers/admin/email_domain_blocks_controller_spec.rb' - - 'spec/controllers/admin/roles_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/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/filters_controller_spec.rb' - - 'spec/controllers/api/v1/media_controller_spec.rb' - - 'spec/controllers/api/v1/notifications_controller_spec.rb' - - 'spec/controllers/api/v1/polls/votes_controller_spec.rb' - - 'spec/controllers/api/v1/reports_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/mutes_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/auth/challenges_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/concerns/challengable_concern_spec.rb' - - 'spec/controllers/oauth/authorized_applications_controller_spec.rb' - - 'spec/controllers/oauth/tokens_controller_spec.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/controllers/statuses_controller_spec.rb' - - 'spec/helpers/application_helper_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/activitypub/activity/delete_spec.rb' - - 'spec/lib/activitypub/activity/flag_spec.rb' - - 'spec/lib/activitypub/dereferencer_spec.rb' - - 'spec/lib/activitypub/tag_manager_spec.rb' - - 'spec/lib/delivery_failure_tracker_spec.rb' - - 'spec/lib/feed_manager_spec.rb' - - 'spec/lib/html_aware_formatter_spec.rb' - - 'spec/lib/request_pool_spec.rb' - - 'spec/lib/status_reach_finder_spec.rb' - - 'spec/lib/vacuum/access_tokens_vacuum_spec.rb' - - 'spec/lib/vacuum/backups_vacuum_spec.rb' - - 'spec/lib/vacuum/media_attachments_vacuum_spec.rb' - - 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' - - 'spec/lib/vacuum/statuses_vacuum_spec.rb' - - 'spec/lib/vacuum/system_keys_vacuum_spec.rb' - - 'spec/models/account/field_spec.rb' - - 'spec/models/account_conversation_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/account_statuses_filter_spec.rb' - - 'spec/models/concerns/remotable_spec.rb' - - 'spec/models/concerns/status_threading_concern_spec.rb' - - 'spec/models/follow_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/status_spec.rb' - - 'spec/models/tag_feed_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/models/trends/tags_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/models/webhook_spec.rb' - - 'spec/policies/account_moderation_note_policy_spec.rb' - - 'spec/policies/account_policy_spec.rb' - - 'spec/policies/backup_policy_spec.rb' - - 'spec/policies/custom_emoji_policy_spec.rb' - - 'spec/policies/domain_block_policy_spec.rb' - - 'spec/policies/email_domain_block_policy_spec.rb' - - 'spec/policies/instance_policy_spec.rb' - - 'spec/policies/invite_policy_spec.rb' - - 'spec/policies/relay_policy_spec.rb' - - 'spec/policies/report_note_policy_spec.rb' - - 'spec/policies/report_policy_spec.rb' - - 'spec/policies/settings_policy_spec.rb' - - 'spec/policies/status_policy_spec.rb' - - 'spec/policies/tag_policy_spec.rb' - - 'spec/policies/user_policy_spec.rb' - - 'spec/presenters/familiar_followers_presenter_spec.rb' - - 'spec/serializers/activitypub/note_spec.rb' - - 'spec/services/account_statuses_cleanup_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/app_sign_up_service_spec.rb' - - 'spec/services/batched_remove_status_service_spec.rb' - - 'spec/services/block_domain_service_spec.rb' - - 'spec/services/bootstrap_timeline_service_spec.rb' - - 'spec/services/fan_out_on_write_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/mute_service_spec.rb' - - 'spec/services/notify_service_spec.rb' - - 'spec/services/remove_status_service_spec.rb' - - 'spec/services/report_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/services/search_service_spec.rb' - - 'spec/services/suspend_account_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - - 'spec/services/unsuspend_account_service_spec.rb' - - 'spec/services/update_status_service_spec.rb' - - 'spec/support/examples/models/concerns/account_avatar.rb' - - 'spec/support/examples/models/concerns/account_header.rb' - - 'spec/validators/email_mx_validator_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - - 'spec/validators/reaction_validator_spec.rb' - - 'spec/validators/status_length_validator_spec.rb' - - 'spec/validators/unique_username_validator_spec.rb' - - 'spec/workers/activitypub/fetch_replies_worker_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' - # Offense count: 3 RSpec/PendingWithoutReason: Exclude: diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index 4e35938db..bf81cdb93 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -60,7 +60,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do end it 'does not include contents of private pinned status' do - expect(response.body).not_to include(private_pinned.text) + expect(response.body).to_not include(private_pinned.text) end context 'when account is permanently suspended' do @@ -115,7 +115,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do end it 'does not include contents of private pinned status' do - expect(response.body).not_to include(private_pinned.text) + expect(response.body).to_not include(private_pinned.text) end end diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb index 2f023197b..7f4d6b2d3 100644 --- a/spec/controllers/activitypub/inboxes_controller_spec.rb +++ b/spec/controllers/activitypub/inboxes_controller_spec.rb @@ -68,7 +68,7 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do let(:synchronization_collection) { 'https://example.com/followers2' } it 'does not start a synchronization job' do - expect(ActivityPub::FollowersSynchronizationWorker).not_to have_received(:perform_async) + expect(ActivityPub::FollowersSynchronizationWorker).to_not have_received(:perform_async) end end @@ -76,13 +76,13 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do let(:synchronization_url) { 'https://example.org/followers' } it 'does not start a synchronization job' do - expect(ActivityPub::FollowersSynchronizationWorker).not_to have_received(:perform_async) + expect(ActivityPub::FollowersSynchronizationWorker).to_not have_received(:perform_async) end end context 'with matching digest' do it 'does not start a synchronization job' do - expect(ActivityPub::FollowersSynchronizationWorker).not_to have_received(:perform_async) + expect(ActivityPub::FollowersSynchronizationWorker).to_not have_received(:perform_async) end end diff --git a/spec/controllers/admin/account_moderation_notes_controller_spec.rb b/spec/controllers/admin/account_moderation_notes_controller_spec.rb index d3f3263f8..b8d606322 100644 --- a/spec/controllers/admin/account_moderation_notes_controller_spec.rb +++ b/spec/controllers/admin/account_moderation_notes_controller_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Admin::AccountModerationNotesController, type: :controller do let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: '' } } } it 'falls to create a note' do - expect { subject }.not_to change { AccountModerationNote.count } + expect { subject }.to_not change { AccountModerationNote.count } expect(subject).to render_template 'admin/accounts/show' end end diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 48204b7b6..35d79740a 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -84,7 +84,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to memorialize account' do is_expected.to have_http_status :forbidden - expect(account.reload).not_to be_memorial + expect(account.reload).to_not be_memorial end end @@ -106,7 +106,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to memorialize account' do is_expected.to have_http_status :forbidden - expect(account.reload).not_to be_memorial + expect(account.reload).to_not be_memorial end end @@ -115,7 +115,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to memorialize account' do is_expected.to have_http_status :forbidden - expect(account.reload).not_to be_memorial + expect(account.reload).to_not be_memorial end end end @@ -133,7 +133,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'succeeds in enabling account' do is_expected.to redirect_to admin_account_path(account.id) - expect(user.reload).not_to be_disabled + expect(user.reload).to_not be_disabled end end @@ -183,7 +183,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to approve account' do is_expected.to have_http_status :forbidden - expect(user.reload).not_to be_approved + expect(user.reload).to_not be_approved end end end @@ -223,7 +223,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to reject account' do is_expected.to have_http_status :forbidden - expect(user.reload).not_to be_approved + expect(user.reload).to_not be_approved end end end diff --git a/spec/controllers/admin/change_email_controller_spec.rb b/spec/controllers/admin/change_email_controller_spec.rb index 0814f327d..520842a19 100644 --- a/spec/controllers/admin/change_email_controller_spec.rb +++ b/spec/controllers/admin/change_email_controller_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do expect(user.email).to eq previous_email expect(user.unconfirmed_email).to eq 'test@example.com' - expect(user.confirmation_token).not_to be_nil + expect(user.confirmation_token).to_not be_nil expect(UserMailer).to have_received(:confirmation_instructions).with(user, user.confirmation_token, { to: 'test@example.com' }) diff --git a/spec/controllers/admin/confirmations_controller_spec.rb b/spec/controllers/admin/confirmations_controller_spec.rb index 6268903c4..7ca90f3e1 100644 --- a/spec/controllers/admin/confirmations_controller_spec.rb +++ b/spec/controllers/admin/confirmations_controller_spec.rb @@ -55,7 +55,7 @@ RSpec.describe Admin::ConfirmationsController, type: :controller do it 'does not resend confirmation mail' do expect(subject).to redirect_to admin_accounts_path expect(flash[:error]).to eq I18n.t('admin.accounts.resend_confirmation.already_confirmed') - expect(UserMailer).not_to have_received(:confirmation_instructions) + expect(UserMailer).to_not have_received(:confirmation_instructions) end end end diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index 3b2fd6c5d..92fc19efa 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -54,7 +54,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do post :create, params: { domain_block: { domain: 'example.com', severity: 'silence' } } - expect(DomainBlockWorker).not_to have_received(:perform_async) + expect(DomainBlockWorker).to_not have_received(:perform_async) expect(response).to render_template :new end diff --git a/spec/controllers/admin/report_notes_controller_spec.rb b/spec/controllers/admin/report_notes_controller_spec.rb index fa7572d18..8a2603611 100644 --- a/spec/controllers/admin/report_notes_controller_spec.rb +++ b/spec/controllers/admin/report_notes_controller_spec.rb @@ -34,7 +34,7 @@ describe Admin::ReportNotesController do it 'creates a report note and does not resolve report' do expect { subject }.to change { ReportNote.count }.by(1) - expect(report.reload).not_to be_action_taken + expect(report.reload).to_not be_action_taken expect(subject).to redirect_to admin_report_path(report) end end @@ -49,7 +49,7 @@ describe Admin::ReportNotesController do it 'creates a report note and unresolves report' do expect { subject }.to change { ReportNote.count }.by(1) - expect(report.reload).not_to be_action_taken + expect(report.reload).to_not be_action_taken expect(subject).to redirect_to admin_report_path(report) end end diff --git a/spec/controllers/settings/profiles_controller_spec.rb b/spec/controllers/settings/profiles_controller_spec.rb index fbbca8bb9..c7a6ad664 100644 --- a/spec/controllers/settings/profiles_controller_spec.rb +++ b/spec/controllers/settings/profiles_controller_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Settings::ProfilesController, type: :controller do put :update, params: { account: { avatar: fixture_file_upload('avatar.gif', 'image/gif') } } expect(response).to redirect_to(settings_profile_path) - expect(account.reload.avatar.instance.avatar_file_name).not_to be_nil + expect(account.reload.avatar.instance.avatar_file_name).to_not be_nil expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(account.id) end end diff --git a/spec/controllers/well_known/nodeinfo_controller_spec.rb b/spec/controllers/well_known/nodeinfo_controller_spec.rb index 964a14706..e9436cd26 100644 --- a/spec/controllers/well_known/nodeinfo_controller_spec.rb +++ b/spec/controllers/well_known/nodeinfo_controller_spec.rb @@ -27,7 +27,7 @@ describe WellKnown::NodeInfoController, type: :controller do json = body_as_json - expect({ 'foo' => 0 }).not_to match_json_schema('nodeinfo_2.0') + expect({ 'foo' => 0 }).to_not 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 diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index 461c3757b..adb13acc2 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -139,7 +139,7 @@ RSpec.describe ActivityPub::Activity::Announce do end it 'does not fetch the remote status' do - expect(a_request(:get, 'https://example.com/actor/hello-world')).not_to have_been_made + expect(a_request(:get, 'https://example.com/actor/hello-world')).to_not have_been_made expect(Status.find_by(uri: 'https://example.com/actor/hello-world')).to be_nil end diff --git a/spec/lib/request_spec.rb b/spec/lib/request_spec.rb index e555a8b5a..f63a836de 100644 --- a/spec/lib/request_spec.rb +++ b/spec/lib/request_spec.rb @@ -102,7 +102,7 @@ describe Request do it 'accepts body less than 1 megabyte by default' do stub_request(:any, 'http://example.com').to_return(body: SecureRandom.random_bytes(2.kilobytes)) - expect { subject.perform { |response| response.body_with_limit } }.not_to raise_error + expect { subject.perform { |response| response.body_with_limit } }.to_not raise_error end it 'rejects body by given size' do diff --git a/spec/lib/status_filter_spec.rb b/spec/lib/status_filter_spec.rb index 287fe00de..cdb482059 100644 --- a/spec/lib/status_filter_spec.rb +++ b/spec/lib/status_filter_spec.rb @@ -10,7 +10,7 @@ describe StatusFilter do subject { described_class.new(status, nil) } context 'when there are no connections' do - it { is_expected.not_to be_filtered } + it { is_expected.to_not be_filtered } end context 'when status account is silenced' do @@ -36,7 +36,7 @@ describe StatusFilter do subject { described_class.new(status, account) } context 'when there are no connections' do - it { is_expected.not_to be_filtered } + it { is_expected.to_not be_filtered } end context 'when status account is blocked' do diff --git a/spec/lib/text_formatter_spec.rb b/spec/lib/text_formatter_spec.rb index d4a3a6b59..cc742b65e 100644 --- a/spec/lib/text_formatter_spec.rb +++ b/spec/lib/text_formatter_spec.rb @@ -18,7 +18,7 @@ RSpec.describe TextFormatter do let(:text) { "line\nfeed" } it 'removes line feeds' do - is_expected.not_to include "\n" + is_expected.to_not include "\n" end end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 763835618..03ed12d78 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Account, type: :model do end it 'does not raise an error' do - expect { subject.suspend! }.not_to raise_error + expect { subject.suspend! }.to_not raise_error end end end @@ -206,7 +206,7 @@ RSpec.describe Account, type: :model do end it 'calls not ResolveAccountService#call' do - expect_any_instance_of(ResolveAccountService).not_to receive(:call).with(acct) + expect_any_instance_of(ResolveAccountService).to_not receive(:call).with(acct) account.refresh! end end @@ -811,19 +811,19 @@ RSpec.describe Account, type: :model do it 'is valid even if the username is longer than 30 characters' do account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(number: 31)) account.valid? - expect(account).not_to model_have_error_on_field(:username) + expect(account).to_not model_have_error_on_field(:username) end it 'is valid even if the display name is longer than 30 characters' do account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(number: 31)) account.valid? - expect(account).not_to model_have_error_on_field(:display_name) + expect(account).to_not model_have_error_on_field(:display_name) end it 'is valid even if the note is longer than 500 characters' do account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501)) account.valid? - expect(account).not_to model_have_error_on_field(:note) + expect(account).to_not model_have_error_on_field(:note) end end end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index b79c44594..b2d84308b 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -163,7 +163,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_a Mute - end.not_to change { mute.reload.hide_notifications? }.from(true) + end.to_not change { mute.reload.hide_notifications? }.from(true) end end @@ -183,7 +183,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_a Mute - end.not_to change { mute.reload.hide_notifications? }.from(true) + end.to_not change { mute.reload.hide_notifications? }.from(true) end end end @@ -207,7 +207,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_a Mute - end.not_to change { mute.reload.hide_notifications? }.from(false) + end.to_not change { mute.reload.hide_notifications? }.from(false) end end diff --git a/spec/models/concerns/remotable_spec.rb b/spec/models/concerns/remotable_spec.rb index ca2d65d2d..964520427 100644 --- a/spec/models/concerns/remotable_spec.rb +++ b/spec/models/concerns/remotable_spec.rb @@ -147,8 +147,8 @@ RSpec.describe Remotable do let(:code) { 500 } it 'does not assign file' do - expect(foo).not_to receive(:public_send).with("#{hoge}=", any_args) - expect(foo).not_to receive(:public_send).with("#{hoge}_file_name=", any_args) + expect(foo).to_not receive(:public_send).with("#{hoge}=", any_args) + expect(foo).to_not receive(:public_send).with("#{hoge}_file_name=", any_args) foo.hoge_remote_url = url end diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index 0ffc343f1..be46639c5 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -11,7 +11,7 @@ RSpec.describe PublicFeed, type: :model do private_status = Fabricate(:status, visibility: :private) expect(subject).to include(public_status.id) - expect(subject).not_to include(private_status.id) + expect(subject).to_not include(private_status.id) end it 'does not include replies' do @@ -19,7 +19,7 @@ RSpec.describe PublicFeed, type: :model do reply = Fabricate(:status, in_reply_to_id: status.id) expect(subject).to include(status.id) - expect(subject).not_to include(reply.id) + expect(subject).to_not include(reply.id) end it 'does not include boosts' do @@ -27,7 +27,7 @@ RSpec.describe PublicFeed, type: :model do boost = Fabricate(:status, reblog_of_id: status.id) expect(subject).to include(status.id) - expect(subject).not_to include(boost.id) + expect(subject).to_not include(boost.id) end it 'filters out silenced accounts' do @@ -36,7 +36,7 @@ RSpec.describe PublicFeed, type: :model do silenced_status = Fabricate(:status, account: silenced_account) expect(subject).to include(status.id) - expect(subject).not_to include(silenced_status.id) + expect(subject).to_not include(silenced_status.id) end context 'without local_only option' do @@ -87,7 +87,7 @@ RSpec.describe PublicFeed, type: :model do it 'does not include remote instances statuses' do expect(subject).to include(local_status.id) - expect(subject).not_to include(remote_status.id) + expect(subject).to_not include(remote_status.id) end end @@ -96,13 +96,13 @@ RSpec.describe PublicFeed, type: :model do it 'does not include remote instances statuses' do expect(subject).to include(local_status.id) - expect(subject).not_to include(remote_status.id) + expect(subject).to_not include(remote_status.id) end it 'is not affected by personal domain blocks' do viewer.block_domain!('test.com') expect(subject).to include(local_status.id) - expect(subject).not_to include(remote_status.id) + expect(subject).to_not include(remote_status.id) end end end @@ -119,7 +119,7 @@ RSpec.describe PublicFeed, type: :model do let(:viewer) { nil } it 'does not include local instances statuses' do - expect(subject).not_to include(local_status.id) + expect(subject).to_not include(local_status.id) expect(subject).to include(remote_status.id) end end @@ -128,7 +128,7 @@ RSpec.describe PublicFeed, type: :model do let(:viewer) { Fabricate(:account, username: 'viewer') } it 'does not include local instances statuses' do - expect(subject).not_to include(local_status.id) + expect(subject).to_not include(local_status.id) expect(subject).to include(remote_status.id) end end @@ -146,7 +146,7 @@ RSpec.describe PublicFeed, type: :model do @account.block!(blocked) blocked_status = Fabricate(:status, account: blocked) - expect(subject).not_to include(blocked_status.id) + expect(subject).to_not include(blocked_status.id) end it 'excludes statuses from accounts who have blocked the account' do @@ -154,7 +154,7 @@ RSpec.describe PublicFeed, type: :model do blocker.block!(@account) blocked_status = Fabricate(:status, account: blocker) - expect(subject).not_to include(blocked_status.id) + expect(subject).to_not include(blocked_status.id) end it 'excludes statuses from accounts muted by the account' do @@ -162,7 +162,7 @@ RSpec.describe PublicFeed, type: :model do @account.mute!(muted) muted_status = Fabricate(:status, account: muted) - expect(subject).not_to include(muted_status.id) + expect(subject).to_not include(muted_status.id) end it 'excludes statuses from accounts from personally blocked domains' do @@ -170,7 +170,7 @@ RSpec.describe PublicFeed, type: :model do @account.block_domain!(blocked.domain) blocked_status = Fabricate(:status, account: blocked) - expect(subject).not_to include(blocked_status.id) + expect(subject).to_not include(blocked_status.id) end context 'with language preferences' do @@ -182,7 +182,7 @@ RSpec.describe PublicFeed, type: :model do expect(subject).to include(en_status.id) expect(subject).to include(es_status.id) - expect(subject).not_to include(fr_status.id) + expect(subject).to_not include(fr_status.id) end it 'includes all languages when user does not have a setting' do diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 83ba415a8..077223094 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Setting, type: :model do let(:cache_value) { 'cache-value' } it 'calls not RailsSettings::Base#[]' do - expect(RailsSettings::Base).not_to receive(:[]).with(key) + expect(RailsSettings::Base).to_not receive(:[]).with(key) described_class[key] end @@ -104,7 +104,7 @@ RSpec.describe Setting, type: :model do ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do described_class[key] end - expect(callback).not_to have_received(:call) + expect(callback).to_not have_received(:call) end it 'returns the cached value' do diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 102d2f625..7043449c5 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -4,15 +4,15 @@ require 'rails_helper' RSpec.describe Tag do describe 'validations' do it 'invalid with #' do - expect(described_class.new(name: '#hello_world')).not_to be_valid + expect(described_class.new(name: '#hello_world')).to_not be_valid end it 'invalid with .' do - expect(described_class.new(name: '.abcdef123')).not_to be_valid + expect(described_class.new(name: '.abcdef123')).to_not be_valid end it 'invalid with spaces' do - expect(described_class.new(name: 'hello world')).not_to be_valid + expect(described_class.new(name: 'hello world')).to_not be_valid end it 'valid with aesthetic' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index dde1503c0..c2f7e99ac 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -159,7 +159,7 @@ RSpec.describe User, type: :model do it 'does not trigger the account.approved Web Hook' do subject - expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id) + expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id) end end @@ -270,7 +270,7 @@ RSpec.describe User, type: :model do it 'does not trigger the account.approved Web Hook' do subject - expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id) + expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id) end end end diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index d3b5baad6..45e19d1ef 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -63,7 +63,7 @@ describe AccountSearchService, type: :service do allow(ResolveAccountService).to receive(:new).and_return(service) results = subject.call('newuser@remote.com', nil, limit: 10, resolve: false) - expect(service).not_to have_received(:call) + expect(service).to_not have_received(:call) end end diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index fbfa6d6c6..d35d9596d 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -39,7 +39,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'does not process payload' do - expect(ActivityPub::Activity).not_to receive(:factory) + expect(ActivityPub::Activity).to_not receive(:factory) subject.call(json, actor) end end @@ -69,7 +69,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do it 'does not process payload if no signature exists' do expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil) - expect(ActivityPub::Activity).not_to receive(:factory) + expect(ActivityPub::Activity).to_not receive(:factory) subject.call(json, forwarder) end @@ -87,7 +87,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do payload['signature'] = { 'type' => 'RsaSignature2017' } expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil) - expect(ActivityPub::Activity).not_to receive(:factory) + expect(ActivityPub::Activity).to_not receive(:factory) subject.call(json, forwarder) end @@ -206,7 +206,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'does not process forged payload' do - expect(ActivityPub::Activity).not_to receive(:factory).with( + expect(ActivityPub::Activity).to_not receive(:factory).with( hash_including( 'object' => hash_including( 'id' => 'https://example.com/users/bob/fake-status' @@ -216,7 +216,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do anything ) - expect(ActivityPub::Activity).not_to receive(:factory).with( + expect(ActivityPub::Activity).to_not receive(:factory).with( hash_including( 'object' => hash_including( 'content' => '

puck was here

' diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 5d15f6ffe..ae7db88bf 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -214,11 +214,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'does not create any edits' do - expect { subject.call(status, json) }.not_to change { status.reload.edits.pluck(&:id) } + expect { subject.call(status, json) }.to_not change { status.reload.edits.pluck(&:id) } end it 'does not update the text, spoiler_text or edited_at' do - expect { subject.call(status, json) }.not_to change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] } + expect { subject.call(status, json) }.to_not change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] } end end diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index 242b02fff..e24e48d41 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -67,9 +67,9 @@ RSpec.describe BlockDomainService, type: :service do end it 'leaves the domains status and attachments, but clears media' do - expect { bad_status1.reload }.not_to raise_error - expect { bad_status2.reload }.not_to raise_error - expect { bad_attachment.reload }.not_to raise_error + expect { bad_status1.reload }.to_not raise_error + expect { bad_status2.reload }.to_not raise_error + expect { bad_attachment.reload }.to_not raise_error expect(bad_attachment.file.exists?).to be false end end diff --git a/spec/services/clear_domain_media_service_spec.rb b/spec/services/clear_domain_media_service_spec.rb index 45b92e2c9..e90faf84d 100644 --- a/spec/services/clear_domain_media_service_spec.rb +++ b/spec/services/clear_domain_media_service_spec.rb @@ -14,9 +14,9 @@ RSpec.describe ClearDomainMediaService, type: :service do end it 'leaves the domains status and attachments, but clears media' do - expect { bad_status1.reload }.not_to raise_error - expect { bad_status2.reload }.not_to raise_error - expect { bad_attachment.reload }.not_to raise_error + expect { bad_status1.reload }.to_not raise_error + expect { bad_status2.reload }.to_not raise_error + expect { bad_attachment.reload }.to_not raise_error expect(bad_attachment.file.exists?).to be false end end diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index a12148833..2b1516ff0 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -234,7 +234,7 @@ RSpec.describe ImportService, type: :service do subject.call(import) expect(account.bookmarks.map(&:status).map(&:id)).to include(local_status.id) expect(account.bookmarks.map(&:status).map(&:id)).to include(remote_status.id) - expect(account.bookmarks.map(&:status).map(&:id)).not_to include(direct_status.id) + expect(account.bookmarks.map(&:status).map(&:id)).to_not include(direct_status.id) expect(account.bookmarks.count).to eq 3 end end diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 0b72253a5..2148f1819 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -50,7 +50,7 @@ RSpec.describe PostStatusService, type: :service do end it 'does not change statuses count' do - expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.not_to change { [account.statuses_count, previous_status.replies_count] } + expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not change { [account.statuses_count, previous_status.replies_count] } end end @@ -157,7 +157,7 @@ RSpec.describe PostStatusService, type: :service do expect do subject.call(account, text: '@alice @alice @alice hey @alice') - end.not_to raise_error + end.to_not raise_error end it 'processes hashtags' do diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 6f32007e8..7ec334a56 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -13,8 +13,8 @@ describe SearchService, type: :service do results = subject.call('', nil, 10) expect(results).to eq(empty_results) - expect(AccountSearchService).not_to have_received(:new) - expect(Tag).not_to have_received(:search_for) + expect(AccountSearchService).to_not have_received(:new) + expect(Tag).to_not have_received(:search_for) end end @@ -89,7 +89,7 @@ describe SearchService, type: :service do allow(Tag).to receive(:search_for) results = subject.call(query, nil, 10) - expect(Tag).not_to have_received(:search_for) + expect(Tag).to_not have_received(:search_for) expect(results).to eq empty_results end diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb index f9ee3b932..cb807fe24 100644 --- a/spec/validators/blacklisted_email_validator_spec.rb +++ b/spec/validators/blacklisted_email_validator_spec.rb @@ -26,7 +26,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do let(:blocked_email) { false } it 'does not add errors' do - expect(subject).not_to have_received(:add).with(:email, :blocked) + expect(subject).to_not have_received(:add).with(:email, :blocked) end context 'when canonical e-mail is blocked' do diff --git a/spec/validators/disallowed_hashtags_validator_spec.rb b/spec/validators/disallowed_hashtags_validator_spec.rb index 9deec0bb9..2c4ebc4f2 100644 --- a/spec/validators/disallowed_hashtags_validator_spec.rb +++ b/spec/validators/disallowed_hashtags_validator_spec.rb @@ -19,7 +19,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do let(:reblog) { true } it 'does not add errors' do - expect(errors).not_to have_received(:add).with(:text, any_args) + expect(errors).to_not have_received(:add).with(:text, any_args) end end @@ -31,7 +31,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do let(:disallowed_tags) { [] } it 'does not add errors' do - expect(errors).not_to have_received(:add).with(:text, any_args) + expect(errors).to_not have_received(:add).with(:text, any_args) end end diff --git a/spec/validators/email_mx_validator_spec.rb b/spec/validators/email_mx_validator_spec.rb index 6640d6058..ffb6851d0 100644 --- a/spec/validators/email_mx_validator_spec.rb +++ b/spec/validators/email_mx_validator_spec.rb @@ -38,7 +38,7 @@ describe EmailMxValidator do allow(Resolv::DNS).to receive(:open).and_yield(resolver) subject.validate(user) - expect(user.errors).not_to have_received(:add) + expect(user.errors).to_not have_received(:add) end it 'adds an error if the email domain name contains empty labels' do diff --git a/spec/validators/follow_limit_validator_spec.rb b/spec/validators/follow_limit_validator_spec.rb index cc8fbb631..94ba0c47f 100644 --- a/spec/validators/follow_limit_validator_spec.rb +++ b/spec/validators/follow_limit_validator_spec.rb @@ -22,7 +22,7 @@ RSpec.describe FollowLimitValidator, type: :validator do let(:_nil) { true } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:base, any_args) + expect(errors).to_not have_received(:add).with(:base, any_args) end end @@ -43,7 +43,7 @@ RSpec.describe FollowLimitValidator, type: :validator do let(:limit_reached) { false } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:base, any_args) + expect(errors).to_not have_received(:add).with(:base, any_args) end end end diff --git a/spec/validators/poll_validator_spec.rb b/spec/validators/poll_validator_spec.rb index a76c63ccc..f3f4b1288 100644 --- a/spec/validators/poll_validator_spec.rb +++ b/spec/validators/poll_validator_spec.rb @@ -15,14 +15,14 @@ RSpec.describe PollValidator, type: :validator do let(:expires_at) { 1.day.from_now } it 'have no errors' do - expect(errors).not_to have_received(:add) + expect(errors).to_not have_received(:add) end context 'expires just 5 min ago' do let(:expires_at) { 5.minutes.from_now } it 'not calls errors add' do - expect(errors).not_to have_received(:add) + expect(errors).to_not have_received(:add) end end end diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb index db9c728a8..e132b5618 100644 --- a/spec/validators/status_length_validator_spec.rb +++ b/spec/validators/status_length_validator_spec.rb @@ -7,13 +7,13 @@ describe StatusLengthValidator do it 'does not add errors onto remote statuses' do status = double(local?: false) subject.validate(status) - expect(status).not_to receive(:errors) + expect(status).to_not receive(:errors) end it 'does not add errors onto local reblogs' do status = double(local?: false, reblog?: true) subject.validate(status) - expect(status).not_to receive(:errors) + expect(status).to_not receive(:errors) end it 'adds an error when content warning is over 500 characters' do diff --git a/spec/validators/unreserved_username_validator_spec.rb b/spec/validators/unreserved_username_validator_spec.rb index e2f051b08..3c6f71c59 100644 --- a/spec/validators/unreserved_username_validator_spec.rb +++ b/spec/validators/unreserved_username_validator_spec.rb @@ -17,7 +17,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:username) { nil } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:username, any_args) + expect(errors).to_not have_received(:add).with(:username, any_args) end end @@ -36,7 +36,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:reserved_username) { false } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:username, any_args) + expect(errors).to_not have_received(:add).with(:username, any_args) end end end diff --git a/spec/validators/url_validator_spec.rb b/spec/validators/url_validator_spec.rb index 85eadeb63..966261b50 100644 --- a/spec/validators/url_validator_spec.rb +++ b/spec/validators/url_validator_spec.rb @@ -27,7 +27,7 @@ RSpec.describe URLValidator, type: :validator do let(:compliant) { true } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(attribute, any_args) + expect(errors).to_not have_received(:add).with(attribute, any_args) end end end diff --git a/spec/workers/feed_insert_worker_spec.rb b/spec/workers/feed_insert_worker_spec.rb index fb34970fc..1a723d63a 100644 --- a/spec/workers/feed_insert_worker_spec.rb +++ b/spec/workers/feed_insert_worker_spec.rb @@ -16,7 +16,7 @@ describe FeedInsertWorker do result = subject.perform(nil, follower.id) expect(result).to eq true - expect(instance).not_to have_received(:push_to_home) + expect(instance).to_not have_received(:push_to_home) end it 'skips push with missing account' do @@ -25,7 +25,7 @@ describe FeedInsertWorker do result = subject.perform(status.id, nil) expect(result).to eq true - expect(instance).not_to have_received(:push_to_home) + expect(instance).to_not have_received(:push_to_home) end end @@ -36,7 +36,7 @@ describe FeedInsertWorker do result = subject.perform(status.id, follower.id) expect(result).to be_nil - expect(instance).not_to have_received(:push_to_home) + expect(instance).to_not have_received(:push_to_home) end it 'pushes the status onto the home timeline without filter' do -- cgit From bd1d57c2303b7a5df1af749d8851c9364a044e77 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 20:46:00 -0500 Subject: Autofix Rubocop RSpec/EmptyLineAfterSubject (#23719) --- .rubocop_todo.yml | 21 --------------------- .../activitypub/collections_controller_spec.rb | 1 + .../followers_synchronizations_controller_spec.rb | 1 + .../activitypub/outboxes_controller_spec.rb | 1 + .../activitypub/replies_controller_spec.rb | 1 + .../admin/reports/actions_controller_spec.rb | 2 ++ spec/controllers/api/web/embeds_controller_spec.rb | 1 + spec/controllers/emojis_controller_spec.rb | 1 + .../follower_accounts_controller_spec.rb | 1 + .../following_accounts_controller_spec.rb | 1 + spec/controllers/relationships_controller_spec.rb | 1 + spec/lib/activitypub/activity/delete_spec.rb | 2 ++ spec/lib/activitypub/activity/flag_spec.rb | 1 + spec/models/admin/account_action_spec.rb | 1 + spec/models/user_spec.rb | 2 ++ spec/services/fetch_remote_status_service_spec.rb | 1 + spec/workers/refollow_worker_spec.rb | 1 + 17 files changed, 19 insertions(+), 21 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e33d1d745..02f84e70f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -817,27 +817,6 @@ RSpec/EmptyExampleGroup: - 'spec/models/web/setting_spec.rb' - 'spec/services/unmute_service_spec.rb' -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterSubject: - Exclude: - - 'spec/controllers/activitypub/collections_controller_spec.rb' - - 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb' - - 'spec/controllers/activitypub/outboxes_controller_spec.rb' - - 'spec/controllers/activitypub/replies_controller_spec.rb' - - 'spec/controllers/admin/reports/actions_controller_spec.rb' - - 'spec/controllers/api/web/embeds_controller_spec.rb' - - 'spec/controllers/emojis_controller_spec.rb' - - 'spec/controllers/follower_accounts_controller_spec.rb' - - 'spec/controllers/following_accounts_controller_spec.rb' - - 'spec/controllers/relationships_controller_spec.rb' - - 'spec/lib/activitypub/activity/delete_spec.rb' - - 'spec/lib/activitypub/activity/flag_spec.rb' - - 'spec/models/admin/account_action_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/services/fetch_remote_status_service_spec.rb' - - 'spec/workers/refollow_worker_spec.rb' - # Offense count: 178 # Configuration parameters: CountAsOne. RSpec/ExampleLength: diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index bf81cdb93..19c0e0a64 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -38,6 +38,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do let(:remote_account) { nil } subject(:response) { get :show, params: { id: 'featured', account_username: account.username } } + subject(:body) { body_as_json } it 'returns http success' do diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb index c19bb8cae..893c8e14f 100644 --- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb +++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb @@ -35,6 +35,7 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } subject(:response) { get :show, params: { account_username: account.username } } + subject(:body) { body_as_json } it 'returns http success' do diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index d8d42b7ae..f84a902ea 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -36,6 +36,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do let(:remote_account) { nil } subject(:response) { get :show, params: { account_username: account.username, page: page } } + subject(:body) { body_as_json } context 'with page not requested' do diff --git a/spec/controllers/activitypub/replies_controller_spec.rb b/spec/controllers/activitypub/replies_controller_spec.rb index 394d4baab..582ef863f 100644 --- a/spec/controllers/activitypub/replies_controller_spec.rb +++ b/spec/controllers/activitypub/replies_controller_spec.rb @@ -181,6 +181,7 @@ RSpec.describe ActivityPub::RepliesController, type: :controller do describe 'GET #index' do subject(:response) { get :index, params: { account_username: status.account.username, status_id: status.id, only_other_accounts: only_other_accounts } } + let(:only_other_accounts) { nil } context 'with no signature' do diff --git a/spec/controllers/admin/reports/actions_controller_spec.rb b/spec/controllers/admin/reports/actions_controller_spec.rb index 9890ac9ce..db3a1d311 100644 --- a/spec/controllers/admin/reports/actions_controller_spec.rb +++ b/spec/controllers/admin/reports/actions_controller_spec.rb @@ -123,11 +123,13 @@ describe Admin::Reports::ActionsController do context 'action as submit button' do subject { post :create, params: { report_id: report.id, text: text, action => '' } } + it_behaves_like 'all action types' end context 'action as submit button' do subject { post :create, params: { report_id: report.id, text: text, moderation_action: action } } + it_behaves_like 'all action types' end end diff --git a/spec/controllers/api/web/embeds_controller_spec.rb b/spec/controllers/api/web/embeds_controller_spec.rb index 345c317ba..b3ef73915 100644 --- a/spec/controllers/api/web/embeds_controller_spec.rb +++ b/spec/controllers/api/web/embeds_controller_spec.rb @@ -11,6 +11,7 @@ describe Api::Web::EmbedsController do describe 'POST #create' do subject(:response) { post :create, params: { url: url } } + subject(:body) { JSON.parse(response.body, symbolize_names: true) } context 'when successfully finds status' do diff --git a/spec/controllers/emojis_controller_spec.rb b/spec/controllers/emojis_controller_spec.rb index fbbd11f64..9f6604964 100644 --- a/spec/controllers/emojis_controller_spec.rb +++ b/spec/controllers/emojis_controller_spec.rb @@ -7,6 +7,7 @@ describe EmojisController do describe 'GET #show' do subject(:response) { get :show, params: { id: emoji.id, format: :json } } + subject(:body) { JSON.parse(response.body, symbolize_names: true) } it 'returns the right response' do diff --git a/spec/controllers/follower_accounts_controller_spec.rb b/spec/controllers/follower_accounts_controller_spec.rb index ab2e82e85..43fc4203c 100644 --- a/spec/controllers/follower_accounts_controller_spec.rb +++ b/spec/controllers/follower_accounts_controller_spec.rb @@ -38,6 +38,7 @@ describe FollowerAccountsController do context 'when format is json' do subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } + subject(:body) { JSON.parse(response.body) } context 'with page' do diff --git a/spec/controllers/following_accounts_controller_spec.rb b/spec/controllers/following_accounts_controller_spec.rb index e43dbf882..b41bf0575 100644 --- a/spec/controllers/following_accounts_controller_spec.rb +++ b/spec/controllers/following_accounts_controller_spec.rb @@ -38,6 +38,7 @@ describe FollowingAccountsController do context 'when format is json' do subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } + subject(:body) { JSON.parse(response.body) } context 'with page' do diff --git a/spec/controllers/relationships_controller_spec.rb b/spec/controllers/relationships_controller_spec.rb index 2056a2ac2..cd09cf50b 100644 --- a/spec/controllers/relationships_controller_spec.rb +++ b/spec/controllers/relationships_controller_spec.rb @@ -51,6 +51,7 @@ describe RelationshipsController do context 'when select parameter is not provided' do subject { patch :update } + include_examples 'redirects back to followers page' end diff --git a/spec/lib/activitypub/activity/delete_spec.rb b/spec/lib/activitypub/activity/delete_spec.rb index 9dfb8a61b..40cd0fce9 100644 --- a/spec/lib/activitypub/activity/delete_spec.rb +++ b/spec/lib/activitypub/activity/delete_spec.rb @@ -30,6 +30,7 @@ RSpec.describe ActivityPub::Activity::Delete do context 'when the status has been reblogged' do describe '#perform' do subject { described_class.new(json, sender) } + let!(:reblogger) { Fabricate(:account) } let!(:follower) { Fabricate(:account, username: 'follower', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } let!(:reblog) { Fabricate(:status, account: reblogger, reblog: status) } @@ -53,6 +54,7 @@ RSpec.describe ActivityPub::Activity::Delete do context 'when the status has been reported' do describe '#perform' do subject { described_class.new(json, sender) } + let!(:reporter) { Fabricate(:account) } before do diff --git a/spec/lib/activitypub/activity/flag_spec.rb b/spec/lib/activitypub/activity/flag_spec.rb index 7890fd1e8..c2a505356 100644 --- a/spec/lib/activitypub/activity/flag_spec.rb +++ b/spec/lib/activitypub/activity/flag_spec.rb @@ -110,6 +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' } before do diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index b6a052b76..4516df2c2 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -5,6 +5,7 @@ RSpec.describe Admin::AccountAction, type: :model do describe '#save!' do subject { account_action.save! } + let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account } let(:target_account) { Fabricate(:account) } let(:type) { 'disable' } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c2f7e99ac..d23439f1a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -409,6 +409,7 @@ RSpec.describe User, type: :model do describe '#disable!' do subject(:user) { Fabricate(:user, disabled: false, current_sign_in_at: current_sign_in_at, last_sign_in_at: nil) } + let(:current_sign_in_at) { Time.zone.now } before do @@ -497,6 +498,7 @@ RSpec.describe User, type: :model do describe '#active_for_authentication?' do subject { user.active_for_authentication? } + let(:user) { Fabricate(:user, disabled: disabled, confirmed_at: confirmed_at) } context 'when user is disabled' do diff --git a/spec/services/fetch_remote_status_service_spec.rb b/spec/services/fetch_remote_status_service_spec.rb index 02c62f8d6..ace520b8f 100644 --- a/spec/services/fetch_remote_status_service_spec.rb +++ b/spec/services/fetch_remote_status_service_spec.rb @@ -16,6 +16,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do context 'protocol is :activitypub' do subject { described_class.new.call(note[:id], prefetched_body: prefetched_body) } + let(:prefetched_body) { Oj.dump(note) } before do diff --git a/spec/workers/refollow_worker_spec.rb b/spec/workers/refollow_worker_spec.rb index d9c2293b6..1dac15385 100644 --- a/spec/workers/refollow_worker_spec.rb +++ b/spec/workers/refollow_worker_spec.rb @@ -4,6 +4,7 @@ require 'rails_helper' describe RefollowWorker do subject { described_class.new } + let(:account) { Fabricate(:account, domain: 'example.org', protocol: :activitypub) } let(:alice) { Fabricate(:account, domain: nil, username: 'alice') } let(:bob) { Fabricate(:account, domain: nil, username: 'bob') } -- cgit From 4552685f6bd400666ec4058783eeabb11568e575 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 23:24:14 -0500 Subject: Autofix Rubocop RSpec/LeadingSubject (#23670) --- .rubocop_todo.yml | 82 ---------------------- .../activitypub/collections_controller_spec.rb | 4 +- .../followers_synchronizations_controller_spec.rb | 4 +- .../activitypub/inboxes_controller_spec.rb | 4 +- .../activitypub/outboxes_controller_spec.rb | 4 +- spec/controllers/admin/invites_controller_spec.rb | 4 +- .../auth/registrations_controller_spec.rb | 64 ++++++++--------- .../well_known/webfinger_controller_spec.rb | 8 +-- spec/lib/activitypub/activity/accept_spec.rb | 4 +- spec/lib/activitypub/activity/announce_spec.rb | 8 +-- spec/lib/activitypub/activity/create_spec.rb | 16 ++--- spec/lib/activitypub/activity/reject_spec.rb | 4 +- spec/lib/activitypub/activity/undo_spec.rb | 4 +- spec/lib/activitypub/activity/update_spec.rb | 4 +- spec/lib/activitypub/adapter_spec.rb | 4 +- spec/lib/activitypub/dereferencer_spec.rb | 4 +- spec/lib/activitypub/linked_data_signature_spec.rb | 4 +- spec/lib/link_details_extractor_spec.rb | 4 +- spec/lib/status_filter_spec.rb | 4 +- spec/lib/status_reach_finder_spec.rb | 4 +- spec/lib/suspicious_sign_in_detector_spec.rb | 4 +- spec/lib/text_formatter_spec.rb | 4 +- spec/lib/vacuum/backups_vacuum_spec.rb | 4 +- spec/lib/vacuum/media_attachments_vacuum_spec.rb | 4 +- spec/lib/vacuum/preview_cards_vacuum_spec.rb | 4 +- spec/lib/vacuum/statuses_vacuum_spec.rb | 4 +- spec/models/account/field_spec.rb | 12 ++-- spec/models/account_spec.rb | 16 ++--- .../models/account_statuses_cleanup_policy_spec.rb | 20 +++--- spec/models/account_statuses_filter_spec.rb | 4 +- spec/models/concerns/account_interactions_spec.rb | 40 +++++------ spec/models/custom_emoji_filter_spec.rb | 4 +- spec/models/custom_emoji_spec.rb | 12 ++-- spec/models/home_feed_spec.rb | 4 +- spec/models/media_attachment_spec.rb | 8 +-- spec/models/public_feed_spec.rb | 16 ++--- spec/models/remote_follow_spec.rb | 4 +- spec/models/setting_spec.rb | 4 +- spec/models/status_spec.rb | 16 ++--- spec/models/user_spec.rb | 4 +- spec/models/web/push_subscription_spec.rb | 4 +- .../familiar_followers_presenter_spec.rb | 4 +- spec/serializers/activitypub/note_spec.rb | 4 +- spec/serializers/activitypub/update_poll_spec.rb | 4 +- spec/serializers/rest/account_serializer_spec.rb | 4 +- .../fetch_featured_collection_service_spec.rb | 4 +- .../fetch_featured_tags_collection_service_spec.rb | 4 +- .../fetch_remote_status_service_spec.rb | 4 +- .../activitypub/fetch_replies_service_spec.rb | 4 +- .../activitypub/process_account_service_spec.rb | 8 +-- .../activitypub/process_collection_service_spec.rb | 4 +- .../process_status_update_service_spec.rb | 4 +- .../synchronize_followers_service_spec.rb | 4 +- ...after_block_domain_from_account_service_spec.rb | 4 +- spec/services/app_sign_up_service_spec.rb | 4 +- spec/services/authorize_follow_service_spec.rb | 4 +- spec/services/block_domain_service_spec.rb | 4 +- spec/services/block_service_spec.rb | 4 +- spec/services/clear_domain_media_service_spec.rb | 4 +- spec/services/delete_account_service_spec.rb | 4 +- spec/services/fan_out_on_write_service_spec.rb | 4 +- spec/services/favourite_service_spec.rb | 4 +- spec/services/fetch_resource_service_spec.rb | 4 +- spec/services/follow_service_spec.rb | 4 +- spec/services/process_mentions_service_spec.rb | 4 +- spec/services/purge_domain_service_spec.rb | 4 +- spec/services/reblog_service_spec.rb | 8 +-- spec/services/reject_follow_service_spec.rb | 4 +- spec/services/remove_from_follwers_service_spec.rb | 4 +- spec/services/report_service_spec.rb | 12 ++-- spec/services/suspend_account_service_spec.rb | 4 +- spec/services/unallow_domain_service_spec.rb | 4 +- spec/services/unblock_service_spec.rb | 4 +- spec/services/unfollow_service_spec.rb | 4 +- spec/services/unsuspend_account_service_spec.rb | 4 +- .../validators/blacklisted_email_validator_spec.rb | 4 +- spec/workers/move_worker_spec.rb | 4 +- spec/workers/unfollow_follow_worker_spec.rb | 4 +- 78 files changed, 256 insertions(+), 338 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eb0910fe6..1eb039110 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -952,88 +952,6 @@ RSpec/InstanceVariable: - 'spec/services/search_service_spec.rb' - 'spec/services/unblock_domain_service_spec.rb' -# Offense count: 118 -# This cop supports safe autocorrection (--autocorrect). -RSpec/LeadingSubject: - Exclude: - - '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/admin/invites_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/well_known/webfinger_controller_spec.rb' - - 'spec/lib/activitypub/activity/accept_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/activitypub/activity/reject_spec.rb' - - 'spec/lib/activitypub/activity/undo_spec.rb' - - 'spec/lib/activitypub/activity/update_spec.rb' - - 'spec/lib/activitypub/adapter_spec.rb' - - 'spec/lib/activitypub/dereferencer_spec.rb' - - 'spec/lib/activitypub/linked_data_signature_spec.rb' - - 'spec/lib/link_details_extractor_spec.rb' - - 'spec/lib/status_filter_spec.rb' - - 'spec/lib/status_reach_finder_spec.rb' - - 'spec/lib/suspicious_sign_in_detector_spec.rb' - - 'spec/lib/text_formatter_spec.rb' - - 'spec/lib/vacuum/backups_vacuum_spec.rb' - - 'spec/lib/vacuum/media_attachments_vacuum_spec.rb' - - 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' - - 'spec/lib/vacuum/statuses_vacuum_spec.rb' - - 'spec/models/account/field_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/account_statuses_filter_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - - 'spec/models/custom_emoji_filter_spec.rb' - - 'spec/models/custom_emoji_spec.rb' - - 'spec/models/home_feed_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/public_feed_spec.rb' - - 'spec/models/remote_follow_spec.rb' - - 'spec/models/setting_spec.rb' - - 'spec/models/status_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/models/web/push_subscription_spec.rb' - - 'spec/presenters/familiar_followers_presenter_spec.rb' - - 'spec/serializers/activitypub/note_spec.rb' - - 'spec/serializers/activitypub/update_poll_spec.rb' - - 'spec/serializers/rest/account_serializer_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/after_block_domain_from_account_service_spec.rb' - - 'spec/services/app_sign_up_service_spec.rb' - - 'spec/services/authorize_follow_service_spec.rb' - - 'spec/services/block_domain_service_spec.rb' - - 'spec/services/block_service_spec.rb' - - 'spec/services/clear_domain_media_service_spec.rb' - - 'spec/services/delete_account_service_spec.rb' - - 'spec/services/fan_out_on_write_service_spec.rb' - - 'spec/services/favourite_service_spec.rb' - - 'spec/services/fetch_resource_service_spec.rb' - - 'spec/services/follow_service_spec.rb' - - 'spec/services/process_mentions_service_spec.rb' - - 'spec/services/purge_domain_service_spec.rb' - - 'spec/services/reblog_service_spec.rb' - - 'spec/services/reject_follow_service_spec.rb' - - 'spec/services/remove_from_follwers_service_spec.rb' - - 'spec/services/report_service_spec.rb' - - 'spec/services/suspend_account_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - - 'spec/services/unblock_service_spec.rb' - - 'spec/services/unfollow_service_spec.rb' - - 'spec/services/unsuspend_account_service_spec.rb' - - 'spec/validators/blacklisted_email_validator_spec.rb' - - 'spec/workers/move_worker_spec.rb' - - 'spec/workers/unfollow_follow_worker_spec.rb' - # Offense count: 15 RSpec/LeakyConstantDeclaration: Exclude: diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index 19c0e0a64..77901131e 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -35,11 +35,11 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do describe 'GET #show' do context 'when id is "featured"' do context 'without signature' do - let(:remote_account) { nil } + subject(:body) { body_as_json } subject(:response) { get :show, params: { id: 'featured', account_username: account.username } } - subject(:body) { body_as_json } + let(:remote_account) { nil } it 'returns http success' do expect(response).to have_http_status(200) diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb index 893c8e14f..6ec756d3c 100644 --- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb +++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb @@ -32,11 +32,11 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll end context 'with signature from example.com' do - let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } + subject(:body) { body_as_json } subject(:response) { get :show, params: { account_username: account.username } } - subject(:body) { body_as_json } + let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } it 'returns http success' do expect(response).to have_http_status(200) diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb index 7f4d6b2d3..8d4084648 100644 --- a/spec/controllers/activitypub/inboxes_controller_spec.rb +++ b/spec/controllers/activitypub/inboxes_controller_spec.rb @@ -22,10 +22,10 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do end context 'for a specific account' do - let(:account) { Fabricate(:account) } - subject(:response) { post :create, params: { account_username: account.username }, body: '{}' } + let(:account) { Fabricate(:account) } + context 'when account is permanently suspended' do before do account.suspend! diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index f84a902ea..7369ee413 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -33,11 +33,11 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do describe 'GET #show' do context 'without signature' do - let(:remote_account) { nil } + subject(:body) { body_as_json } subject(:response) { get :show, params: { account_username: account.username, page: page } } - subject(:body) { body_as_json } + let(:remote_account) { nil } context 'with page not requested' do let(:page) { nil } diff --git a/spec/controllers/admin/invites_controller_spec.rb b/spec/controllers/admin/invites_controller_spec.rb index 1fb488742..92ec4e449 100644 --- a/spec/controllers/admin/invites_controller_spec.rb +++ b/spec/controllers/admin/invites_controller_spec.rb @@ -33,10 +33,10 @@ describe Admin::InvitesController do end describe 'DELETE #destroy' do - let!(:invite) { Fabricate(:invite, expires_at: nil) } - subject { delete :destroy, params: { id: invite.id } } + let!(:invite) { Fabricate(:invite, expires_at: nil) } + it 'expires invite' do expect(subject).to redirect_to admin_invites_path expect(invite.reload).to be_expired diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 52023eb2e..8cfb8e277 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -95,18 +95,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do before { request.env['devise.mapping'] = Devise.mappings[:user] } context do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'open' 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 + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path @@ -121,18 +121,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'when user has not agreed to terms of service' do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'open' 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 + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'does not create user' do subject user = User.find_by(email: 'test@example.com') @@ -141,18 +141,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'approval-based registrations without invite' do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'approved' 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 + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path @@ -168,12 +168,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'approval-based registrations with expired invite' do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'approved' request.headers['Accept-Language'] = accept_language @@ -181,6 +175,12 @@ RSpec.describe Auth::RegistrationsController, type: :controller do post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path @@ -196,14 +196,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'approval-based registrations with valid invite and required invite text' do - around do |example| - registrations_mode = Setting.registrations_mode - require_invite_text = Setting.require_invite_text - example.run - Setting.require_invite_text = require_invite_text - Setting.registrations_mode = registrations_mode - end - subject do inviter = Fabricate(:user, confirmed_at: 2.days.ago) Setting.registrations_mode = 'approved' @@ -213,6 +205,14 @@ RSpec.describe Auth::RegistrationsController, type: :controller do post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end + around do |example| + registrations_mode = Setting.registrations_mode + require_invite_text = Setting.require_invite_text + example.run + Setting.require_invite_text = require_invite_text + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb index 8574d369d..1ccfb218e 100644 --- a/spec/controllers/well_known/webfinger_controller_spec.rb +++ b/spec/controllers/well_known/webfinger_controller_spec.rb @@ -4,6 +4,10 @@ describe WellKnown::WebfingerController, type: :controller do render_views describe 'GET #show' do + subject do + get :show, params: { resource: resource }, format: :json + end + let(:alternate_domains) { [] } let(:alice) { Fabricate(:account, username: 'alice') } let(:resource) { nil } @@ -15,10 +19,6 @@ describe WellKnown::WebfingerController, type: :controller do Rails.configuration.x.alternate_domains = tmp end - subject do - get :show, params: { resource: resource }, format: :json - end - shared_examples 'a successful response' do it 'returns http success' do expect(response).to have_http_status(200) diff --git a/spec/lib/activitypub/activity/accept_spec.rb b/spec/lib/activitypub/activity/accept_spec.rb index 304cf2208..95a5a8747 100644 --- a/spec/lib/activitypub/activity/accept_spec.rb +++ b/spec/lib/activitypub/activity/accept_spec.rb @@ -42,6 +42,8 @@ RSpec.describe ActivityPub::Activity::Accept do end context 'given a relay' do + subject { described_class.new(json, sender) } + let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') } let(:json) do @@ -59,8 +61,6 @@ RSpec.describe ActivityPub::Activity::Accept do }.with_indifferent_access end - subject { described_class.new(json, sender) } - it 'marks the relay as accepted' do subject.perform expect(relay.reload.accepted?).to be true diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index adb13acc2..b3257e881 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::Activity::Announce do + subject { described_class.new(json, sender) } + let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') } let(:recipient) { Fabricate(:account) } let(:status) { Fabricate(:status, account: recipient) } @@ -27,8 +29,6 @@ RSpec.describe ActivityPub::Activity::Announce do } end - subject { described_class.new(json, sender) } - describe '#perform' do context 'when sender is followed by a local account' do before do @@ -110,13 +110,13 @@ RSpec.describe ActivityPub::Activity::Announce do end context 'when the sender is relayed' do + subject { described_class.new(json, sender, relayed_through_actor: relay_account) } + let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') } let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') } let(:object_json) { 'https://example.com/actor/hello-world' } - subject { described_class.new(json, sender, relayed_through_actor: relay_account) } - before do stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json)) end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index ddbdb07aa..c26c8b358 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -752,6 +752,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'with an encrypted message' do + subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) } + let(:recipient) { Fabricate(:account) } let(:object_json) do { @@ -776,8 +778,6 @@ 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 end @@ -831,6 +831,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'when sender replies to local status' do + subject { described_class.new(json, sender, delivery: true) } + let!(:local_status) { Fabricate(:status) } let(:object_json) do { @@ -841,8 +843,6 @@ RSpec.describe ActivityPub::Activity::Create do } end - subject { described_class.new(json, sender, delivery: true) } - before do subject.perform end @@ -856,6 +856,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'when sender targets a local user' do + subject { described_class.new(json, sender, delivery: true) } + let!(:local_account) { Fabricate(:account) } let(:object_json) do { @@ -866,8 +868,6 @@ RSpec.describe ActivityPub::Activity::Create do } end - subject { described_class.new(json, sender, delivery: true) } - before do subject.perform end @@ -881,6 +881,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'when sender cc\'s a local user' do + subject { described_class.new(json, sender, delivery: true) } + let!(:local_account) { Fabricate(:account) } let(:object_json) do { @@ -891,8 +893,6 @@ RSpec.describe ActivityPub::Activity::Create do } end - subject { described_class.new(json, sender, delivery: true) } - before do subject.perform end diff --git a/spec/lib/activitypub/activity/reject_spec.rb b/spec/lib/activitypub/activity/reject_spec.rb index fed4cd8cd..7f04db4e6 100644 --- a/spec/lib/activitypub/activity/reject_spec.rb +++ b/spec/lib/activitypub/activity/reject_spec.rb @@ -121,6 +121,8 @@ RSpec.describe ActivityPub::Activity::Reject do end context 'given a relay' do + subject { described_class.new(json, sender) } + let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') } let(:json) do @@ -138,8 +140,6 @@ RSpec.describe ActivityPub::Activity::Reject do }.with_indifferent_access end - subject { described_class.new(json, sender) } - it 'marks the relay as rejected' do subject.perform expect(relay.reload.rejected?).to be true diff --git a/spec/lib/activitypub/activity/undo_spec.rb b/spec/lib/activitypub/activity/undo_spec.rb index c0309e49d..0bd1f17d3 100644 --- a/spec/lib/activitypub/activity/undo_spec.rb +++ b/spec/lib/activitypub/activity/undo_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::Activity::Undo do + subject { described_class.new(json, sender) } + let(:sender) { Fabricate(:account, domain: 'example.com') } let(:json) do @@ -13,8 +15,6 @@ RSpec.describe ActivityPub::Activity::Undo do }.with_indifferent_access end - subject { described_class.new(json, sender) } - describe '#perform' do context 'with Announce' do let(:status) { Fabricate(:status) } diff --git a/spec/lib/activitypub/activity/update_spec.rb b/spec/lib/activitypub/activity/update_spec.rb index 4cd853af2..d2a1edd7a 100644 --- a/spec/lib/activitypub/activity/update_spec.rb +++ b/spec/lib/activitypub/activity/update_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' RSpec.describe ActivityPub::Activity::Update do + subject { described_class.new(json, sender) } + let!(:sender) { Fabricate(:account) } before do sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender)) end - subject { described_class.new(json, sender) } - describe '#perform' do context 'with an Actor object' do let(:modified_sender) do diff --git a/spec/lib/activitypub/adapter_spec.rb b/spec/lib/activitypub/adapter_spec.rb index ea03797aa..e4c403abb 100644 --- a/spec/lib/activitypub/adapter_spec.rb +++ b/spec/lib/activitypub/adapter_spec.rb @@ -41,10 +41,10 @@ RSpec.describe ActivityPub::Adapter do end describe '#serializable_hash' do - let(:serializer_class) {} - subject { ActiveModelSerializers::SerializableResource.new(TestObject.new(foo: 'bar'), serializer: serializer_class, adapter: described_class).as_json } + let(:serializer_class) {} + context 'when serializer defines no context' do let(:serializer_class) { TestWithBasicContextSerializer } diff --git a/spec/lib/activitypub/dereferencer_spec.rb b/spec/lib/activitypub/dereferencer_spec.rb index e50b497c7..800473a7c 100644 --- a/spec/lib/activitypub/dereferencer_spec.rb +++ b/spec/lib/activitypub/dereferencer_spec.rb @@ -2,13 +2,13 @@ require 'rails_helper' RSpec.describe ActivityPub::Dereferencer do describe '#object' do + subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object } + let(:object) { { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://example.com/foo', type: 'Note', content: 'Hoge' } } let(:permitted_origin) { 'https://example.com' } let(:signature_actor) { nil } let(:uri) { nil } - subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object } - before do stub_request(:get, 'https://example.com/foo').to_return(body: Oj.dump(object), headers: { 'Content-Type' => 'application/activity+json' }) end diff --git a/spec/lib/activitypub/linked_data_signature_spec.rb b/spec/lib/activitypub/linked_data_signature_spec.rb index d55a7c7fa..ecb1e16db 100644 --- a/spec/lib/activitypub/linked_data_signature_spec.rb +++ b/spec/lib/activitypub/linked_data_signature_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe ActivityPub::LinkedDataSignature do include JsonLdHelper + subject { described_class.new(json) } + let!(:sender) { Fabricate(:account, uri: 'http://example.com/alice') } let(:raw_json) do @@ -14,8 +16,6 @@ RSpec.describe ActivityPub::LinkedDataSignature do let(:json) { raw_json.merge('signature' => signature) } - subject { described_class.new(json) } - before do stub_jsonld_contexts! end diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb index 7eb15ced3..fcc265474 100644 --- a/spec/lib/link_details_extractor_spec.rb +++ b/spec/lib/link_details_extractor_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe LinkDetailsExtractor do + subject { described_class.new(original_url, html, html_charset) } + let(:original_url) { '' } let(:html) { '' } let(:html_charset) { nil } - subject { described_class.new(original_url, html, html_charset) } - describe '#canonical_url' do let(:original_url) { 'https://foo.com/article?bar=baz123' } diff --git a/spec/lib/status_filter_spec.rb b/spec/lib/status_filter_spec.rb index cdb482059..08519bc59 100644 --- a/spec/lib/status_filter_spec.rb +++ b/spec/lib/status_filter_spec.rb @@ -31,10 +31,10 @@ describe StatusFilter do end context 'with real account' do - let(:account) { Fabricate(:account) } - subject { described_class.new(status, account) } + let(:account) { Fabricate(:account) } + context 'when there are no connections' do it { is_expected.to_not be_filtered } end diff --git a/spec/lib/status_reach_finder_spec.rb b/spec/lib/status_reach_finder_spec.rb index f0c22b165..785ce28a0 100644 --- a/spec/lib/status_reach_finder_spec.rb +++ b/spec/lib/status_reach_finder_spec.rb @@ -5,13 +5,13 @@ require 'rails_helper' describe StatusReachFinder do describe '#inboxes' do context 'for a local status' do + subject { described_class.new(status) } + let(:parent_status) { nil } let(:visibility) { :public } let(:alice) { Fabricate(:account, username: 'alice') } let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) } - subject { described_class.new(status) } - context 'when it contains mentions of remote accounts' do let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } diff --git a/spec/lib/suspicious_sign_in_detector_spec.rb b/spec/lib/suspicious_sign_in_detector_spec.rb index 101a18aa0..05aadfd8f 100644 --- a/spec/lib/suspicious_sign_in_detector_spec.rb +++ b/spec/lib/suspicious_sign_in_detector_spec.rb @@ -2,12 +2,12 @@ require 'rails_helper' RSpec.describe SuspiciousSignInDetector do describe '#suspicious?' do + subject { described_class.new(user).suspicious?(request) } + let(:user) { Fabricate(:user, current_sign_in_at: 1.day.ago) } let(:request) { double(remote_ip: remote_ip) } let(:remote_ip) { nil } - subject { described_class.new(user).suspicious?(request) } - context 'when user has 2FA enabled' do before do user.update!(otp_required_for_login: true) diff --git a/spec/lib/text_formatter_spec.rb b/spec/lib/text_formatter_spec.rb index 63a9075c7..04ae4e02c 100644 --- a/spec/lib/text_formatter_spec.rb +++ b/spec/lib/text_formatter_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe TextFormatter do describe '#to_s' do - let(:preloaded_accounts) { nil } - subject { described_class.new(text, preloaded_accounts: preloaded_accounts).to_s } + let(:preloaded_accounts) { nil } + context 'given text containing plain text' do let(:text) { 'text' } diff --git a/spec/lib/vacuum/backups_vacuum_spec.rb b/spec/lib/vacuum/backups_vacuum_spec.rb index 4e2de083f..c505a3e1a 100644 --- a/spec/lib/vacuum/backups_vacuum_spec.rb +++ b/spec/lib/vacuum/backups_vacuum_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe Vacuum::BackupsVacuum do - let(:retention_period) { 7.days } - subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } + describe '#perform' do let!(:expired_backup) { Fabricate(:backup, created_at: (retention_period + 1.day).ago) } let!(:current_backup) { Fabricate(:backup) } diff --git a/spec/lib/vacuum/media_attachments_vacuum_spec.rb b/spec/lib/vacuum/media_attachments_vacuum_spec.rb index 436237b25..afcb6f878 100644 --- a/spec/lib/vacuum/media_attachments_vacuum_spec.rb +++ b/spec/lib/vacuum/media_attachments_vacuum_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe Vacuum::MediaAttachmentsVacuum do + subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } 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/lib/vacuum/preview_cards_vacuum_spec.rb b/spec/lib/vacuum/preview_cards_vacuum_spec.rb index 275f9ba92..524f4c927 100644 --- a/spec/lib/vacuum/preview_cards_vacuum_spec.rb +++ b/spec/lib/vacuum/preview_cards_vacuum_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe Vacuum::PreviewCardsVacuum do - let(:retention_period) { 7.days } - subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } + describe '#perform' do let!(:orphaned_preview_card) { Fabricate(:preview_card, created_at: 2.days.ago) } let!(:old_preview_card) { Fabricate(:preview_card, updated_at: (retention_period + 1.day).ago) } diff --git a/spec/lib/vacuum/statuses_vacuum_spec.rb b/spec/lib/vacuum/statuses_vacuum_spec.rb index 83f3c5c9f..9583376b7 100644 --- a/spec/lib/vacuum/statuses_vacuum_spec.rb +++ b/spec/lib/vacuum/statuses_vacuum_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe Vacuum::StatusesVacuum do + subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } let(:remote_account) { Fabricate(:account, domain: 'example.com') } - subject { described_class.new(retention_period) } - describe '#perform' do let!(:remote_status_old) { Fabricate(:status, account: remote_account, created_at: (retention_period + 2.days).ago) } let!(:remote_status_recent) { Fabricate(:status, account: remote_account, created_at: (retention_period - 2.days).ago) } diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index 40bbee025..36e1a8595 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe Account::Field, type: :model do describe '#verified?' do - let(:account) { double('Account', local?: true) } - subject { described_class.new(account, 'name' => 'Foo', 'value' => 'Bar', 'verified_at' => verified_at) } + let(:account) { double('Account', local?: true) } + context 'when verified_at is set' do let(:verified_at) { Time.now.utc.iso8601 } @@ -24,11 +24,11 @@ RSpec.describe Account::Field, type: :model do end describe '#mark_verified!' do + subject { described_class.new(account, original_hash) } + let(:account) { double('Account', local?: true) } let(:original_hash) { { 'name' => 'Foo', 'value' => 'Bar' } } - subject { described_class.new(account, original_hash) } - before do subject.mark_verified! end @@ -43,10 +43,10 @@ RSpec.describe Account::Field, type: :model do end describe '#verifiable?' do - let(:account) { double('Account', local?: local) } - subject { described_class.new(account, 'name' => 'Foo', 'value' => value) } + let(:account) { double('Account', local?: local) } + context 'for local accounts' do let(:local) { true } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 03ed12d78..726e33048 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe Account, type: :model do context do - let(:bob) { Fabricate(:account, username: 'bob') } - subject { Fabricate(:account) } + let(:bob) { Fabricate(:account, username: 'bob') } + describe '#suspend!' do it 'marks the account as suspended' do subject.suspend! @@ -87,14 +87,14 @@ RSpec.describe Account, type: :model do end describe 'Local domain user methods' do + subject { Fabricate(:account, domain: nil, username: 'alice') } + around do |example| before = Rails.configuration.x.local_domain example.run Rails.configuration.x.local_domain = before end - subject { Fabricate(:account, domain: nil, username: 'alice') } - describe '#to_webfinger_s' do it 'returns a webfinger string for the account' do Rails.configuration.x.local_domain = 'example.com' @@ -243,13 +243,13 @@ RSpec.describe Account, type: :model do end describe '#favourited?' do + subject { Fabricate(:account) } + let(:original_status) do author = Fabricate(:account, username: 'original') Fabricate(:status, account: author) end - subject { Fabricate(:account) } - context 'when the status is a reblog of another status' do let(:original_reblog) do author = Fabricate(:account, username: 'original_reblogger') @@ -281,13 +281,13 @@ RSpec.describe Account, type: :model do end describe '#reblogged?' do + subject { Fabricate(:account) } + let(:original_status) do author = Fabricate(:account, username: 'original') Fabricate(:status, account: author) end - subject { Fabricate(:account) } - context 'when the status is a reblog of another status' do let(:original_reblog) do author = Fabricate(:account, username: 'original_reblogger') diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index d3c011b3a..8bd86730b 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -132,11 +132,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#invalidate_last_inspected' do + subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) } + let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } let(:status) { Fabricate(:status, id: 10, account: account) } - subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) } - before do account_statuses_cleanup_policy.record_last_inspected(42) end @@ -231,11 +231,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#compute_cutoff_id' do + subject { account_statuses_cleanup_policy.compute_cutoff_id } + 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 } - context 'when the account has posted multiple toots' do let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) } let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) } @@ -254,6 +254,8 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#statuses_to_delete' do + subject { account_statuses_cleanup_policy.statuses_to_delete } + let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) } let!(:pinned_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } @@ -275,8 +277,6 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } - subject { account_statuses_cleanup_policy.statuses_to_delete } - before do 4.times { faved4.increment_count!(:favourites_count) } 5.times { faved5.increment_count!(:favourites_count) } @@ -285,11 +285,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end context 'when passed a max_id' do + subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) } + let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) } - subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) } - it 'returns statuses including max_id' do expect(subject).to include(old_status.id) end @@ -304,11 +304,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end context 'when passed a min_id' do + subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) } + let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) } - subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) } - it 'returns statuses including min_id' do expect(subject).to include(old_status.id) end diff --git a/spec/models/account_statuses_filter_spec.rb b/spec/models/account_statuses_filter_spec.rb index 03f0ffeb0..fa7664d92 100644 --- a/spec/models/account_statuses_filter_spec.rb +++ b/spec/models/account_statuses_filter_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' RSpec.describe AccountStatusesFilter do + subject { described_class.new(account, current_account, params) } + let(:account) { Fabricate(:account) } let(:current_account) { nil } let(:params) { {} } - subject { described_class.new(account, current_account, params) } - def status!(visibility) Fabricate(:status, account: account, visibility: visibility) end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index fbfc9fbbc..ed3fc056b 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -225,10 +225,10 @@ describe AccountInteractions do end describe '#mute_conversation!' do - let(:conversation) { Fabricate(:conversation) } - subject { account.mute_conversation!(conversation) } + let(:conversation) { Fabricate(:conversation) } + it 'creates and returns ConversationMute' do expect do expect(subject).to be_a ConversationMute @@ -237,10 +237,10 @@ describe AccountInteractions do end describe '#block_domain!' do - let(:domain) { 'example.com' } - subject { account.block_domain!(domain) } + let(:domain) { 'example.com' } + it 'creates and returns AccountDomainBlock' do expect do expect(subject).to be_a AccountDomainBlock @@ -303,10 +303,10 @@ describe AccountInteractions do end describe '#unmute_conversation!' do - let(:conversation) { Fabricate(:conversation) } - subject { account.unmute_conversation!(conversation) } + let(:conversation) { Fabricate(:conversation) } + context 'muting the conversation' do it 'returns destroyed ConversationMute' do account.conversation_mutes.create(conversation: conversation) @@ -323,10 +323,10 @@ describe AccountInteractions do end describe '#unblock_domain!' do - let(:domain) { 'example.com' } - subject { account.unblock_domain!(domain) } + let(:domain) { 'example.com' } + context 'blocking the domain' do it 'returns destroyed AccountDomainBlock' do account_domain_block = Fabricate(:account_domain_block, domain: domain) @@ -395,10 +395,10 @@ describe AccountInteractions do end describe '#domain_blocking?' do - let(:domain) { 'example.com' } - subject { account.domain_blocking?(domain) } + let(:domain) { 'example.com' } + context 'blocking the domain' do it 'returns true' do account_domain_block = Fabricate(:account_domain_block, domain: domain) @@ -433,10 +433,10 @@ describe AccountInteractions do end describe '#muting_conversation?' do - let(:conversation) { Fabricate(:conversation) } - subject { account.muting_conversation?(conversation) } + let(:conversation) { Fabricate(:conversation) } + context 'muting the conversation' do it 'returns true' do account.conversation_mutes.create(conversation: conversation) @@ -452,13 +452,13 @@ describe AccountInteractions do end describe '#muting_notifications?' do + subject { account.muting_notifications?(target_account) } + before do mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide) account.mute_relationships << mute end - subject { account.muting_notifications?(target_account) } - context 'muting notifications of target_account' do let(:hide) { true } @@ -494,10 +494,10 @@ describe AccountInteractions do end describe '#favourited?' do - let(:status) { Fabricate(:status, account: account, favourites: favourites) } - subject { account.favourited?(status) } + let(:status) { Fabricate(:status, account: account, favourites: favourites) } + context 'favorited' do let(:favourites) { [Fabricate(:favourite, account: account)] } @@ -516,10 +516,10 @@ describe AccountInteractions do end describe '#reblogged?' do - let(:status) { Fabricate(:status, account: account, reblogs: reblogs) } - subject { account.reblogged?(status) } + let(:status) { Fabricate(:status, account: account, reblogs: reblogs) } + context 'reblogged' do let(:reblogs) { [Fabricate(:status, account: account)] } @@ -538,10 +538,10 @@ describe AccountInteractions do end describe '#pinned?' do - let(:status) { Fabricate(:status, account: account) } - subject { account.pinned?(status) } + let(:status) { Fabricate(:status, account: account) } + context 'pinned' do it 'returns true' do Fabricate(:status_pin, account: account, status: status) diff --git a/spec/models/custom_emoji_filter_spec.rb b/spec/models/custom_emoji_filter_spec.rb index 515c0a715..30f0ec2b2 100644 --- a/spec/models/custom_emoji_filter_spec.rb +++ b/spec/models/custom_emoji_filter_spec.rb @@ -4,12 +4,12 @@ require 'rails_helper' RSpec.describe CustomEmojiFilter do describe '#results' do + subject { described_class.new(params).results } + let!(:custom_emoji_0) { Fabricate(:custom_emoji, domain: 'a') } let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') } let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') } - subject { described_class.new(params).results } - context 'params have values' do context 'local' do let(:params) { { local: true } } diff --git a/spec/models/custom_emoji_spec.rb b/spec/models/custom_emoji_spec.rb index 1fc112db3..f6fcd468b 100644 --- a/spec/models/custom_emoji_spec.rb +++ b/spec/models/custom_emoji_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe CustomEmoji, type: :model do describe '#search' do - let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) } - subject { described_class.search(search_term) } + let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) } + context 'shortcode is exact' do let(:shortcode) { 'blobpats' } let(:search_term) { 'blobpats' } @@ -26,10 +26,10 @@ RSpec.describe CustomEmoji, type: :model do end describe '#local?' do - let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) } - subject { custom_emoji.local? } + let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) } + context 'domain is nil' do let(:domain) { nil } @@ -55,10 +55,10 @@ RSpec.describe CustomEmoji, type: :model do end describe '.from_text' do - let!(:emojo) { Fabricate(:custom_emoji) } - subject { described_class.from_text(text, nil) } + let!(:emojo) { Fabricate(:custom_emoji) } + context 'with plain text' do let(:text) { 'Hello :coolcat:' } diff --git a/spec/models/home_feed_spec.rb b/spec/models/home_feed_spec.rb index 80f6edbff..196bef1e4 100644 --- a/spec/models/home_feed_spec.rb +++ b/spec/models/home_feed_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe HomeFeed, type: :model do - let(:account) { Fabricate(:account) } - subject { described_class.new(account) } + let(:account) { Fabricate(:account) } + describe '#get' do before do Fabricate(:status, account: account, id: 1) diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 8889d5f7c..57e131423 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe MediaAttachment, type: :model do describe 'local?' do - let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) } - subject { media_attachment.local? } + let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) } + context 'remote_url is blank' do let(:remote_url) { '' } @@ -24,10 +24,10 @@ RSpec.describe MediaAttachment, type: :model do end describe 'needs_redownload?' do - let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) } - subject { media_attachment.needs_redownload? } + let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) } + context 'file is blank' do let(:file) { nil } diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index be46639c5..59c81dd95 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -40,6 +40,8 @@ RSpec.describe PublicFeed, type: :model do end context 'without local_only option' do + subject { described_class.new(viewer).get(20).map(&:id) } + let(:viewer) { nil } let!(:local_account) { Fabricate(:account, domain: nil) } @@ -47,8 +49,6 @@ RSpec.describe PublicFeed, type: :model do let!(:local_status) { Fabricate(:status, account: local_account) } let!(:remote_status) { Fabricate(:status, account: remote_account) } - subject { described_class.new(viewer).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -75,13 +75,13 @@ RSpec.describe PublicFeed, type: :model do end context 'with a local_only option set' do + subject { described_class.new(viewer, local: true).get(20).map(&:id) } + let!(:local_account) { Fabricate(:account, domain: nil) } let!(:remote_account) { Fabricate(:account, domain: 'test.com') } let!(:local_status) { Fabricate(:status, account: local_account) } let!(:remote_status) { Fabricate(:status, account: remote_account) } - subject { described_class.new(viewer, local: true).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -108,13 +108,13 @@ RSpec.describe PublicFeed, type: :model do end context 'with a remote_only option set' do + subject { described_class.new(viewer, remote: true).get(20).map(&:id) } + let!(:local_account) { Fabricate(:account, domain: nil) } let!(:remote_account) { Fabricate(:account, domain: 'test.com') } let!(:local_status) { Fabricate(:status, account: local_account) } let!(:remote_status) { Fabricate(:status, account: remote_account) } - subject { described_class.new(viewer, remote: true).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -135,12 +135,12 @@ RSpec.describe PublicFeed, type: :model do end describe 'with an account passed in' do + subject { described_class.new(@account).get(20).map(&:id) } + before do @account = Fabricate(:account) end - subject { described_class.new(@account).get(20).map(&:id) } - it 'excludes statuses from accounts blocked by the account' do blocked = Fabricate(:account) @account.block!(blocked) diff --git a/spec/models/remote_follow_spec.rb b/spec/models/remote_follow_spec.rb index c6bbecf25..ea36b0076 100644 --- a/spec/models/remote_follow_spec.rb +++ b/spec/models/remote_follow_spec.rb @@ -51,6 +51,8 @@ RSpec.describe RemoteFollow do end describe '#subscribe_address_for' do + subject { remote_follow.subscribe_address_for(account) } + before do remote_follow.valid? end @@ -58,8 +60,6 @@ RSpec.describe RemoteFollow do let(:attrs) { { acct: 'gargron@quitter.no' } } let(:account) { Fabricate(:account, username: 'alice') } - subject { remote_follow.subscribe_address_for(account) } - it 'returns subscribe address' do expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice' end diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 86fdf4e08..826a13878 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -163,12 +163,12 @@ RSpec.describe Setting, type: :model do end describe '.default_settings' do + subject { described_class.default_settings } + before do allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled) end - subject { described_class.default_settings } - context 'RailsSettings::Default.enabled? is false' do let(:enabled) { false } diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 78cc05959..442f14ddf 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe Status, type: :model do + subject { Fabricate(:status, account: alice) } + let(:alice) { Fabricate(:account, username: 'alice') } let(:bob) { Fabricate(:account, username: 'bob') } let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!') } - subject { Fabricate(:status, account: alice) } - describe '#local?' do it 'returns true when no remote URI is set' do expect(subject.local?).to be true @@ -204,11 +204,11 @@ RSpec.describe Status, type: :model do end describe '.mutes_map' do + subject { Status.mutes_map([status.conversation.id], account) } + let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - subject { Status.mutes_map([status.conversation.id], account) } - it 'returns a hash' do expect(subject).to be_a Hash end @@ -220,11 +220,11 @@ RSpec.describe Status, type: :model do end describe '.favourites_map' do + subject { Status.favourites_map([status], account) } + let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - subject { Status.favourites_map([status], account) } - it 'returns a hash' do expect(subject).to be_a Hash end @@ -236,11 +236,11 @@ RSpec.describe Status, type: :model do end describe '.reblogs_map' do + subject { Status.reblogs_map([status], account) } + let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - subject { Status.reblogs_map([status], account) } - it 'returns a hash' do expect(subject).to be_a Hash end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d23439f1a..9af616b32 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -142,10 +142,10 @@ RSpec.describe User, type: :model do end describe '#confirm' do - let(:new_email) { 'new-email@example.com' } - subject { user.confirm } + let(:new_email) { 'new-email@example.com' } + before do allow(TriggerWebhookWorker).to receive(:perform_async) end diff --git a/spec/models/web/push_subscription_spec.rb b/spec/models/web/push_subscription_spec.rb index eeadbb71c..388154000 100644 --- a/spec/models/web/push_subscription_spec.rb +++ b/spec/models/web/push_subscription_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe Web::PushSubscription, type: :model do + subject { described_class.new(data: data) } + let(:account) { Fabricate(:account) } let(:policy) { 'all' } @@ -19,8 +21,6 @@ RSpec.describe Web::PushSubscription, type: :model do } end - subject { described_class.new(data: data) } - describe '#pushable?' do let(:notification_type) { :mention } let(:notification) { Fabricate(:notification, account: account, type: notification_type) } diff --git a/spec/presenters/familiar_followers_presenter_spec.rb b/spec/presenters/familiar_followers_presenter_spec.rb index 17be4b971..607e3002f 100644 --- a/spec/presenters/familiar_followers_presenter_spec.rb +++ b/spec/presenters/familiar_followers_presenter_spec.rb @@ -4,12 +4,12 @@ require 'rails_helper' RSpec.describe FamiliarFollowersPresenter do describe '#accounts' do + subject { described_class.new(requested_accounts, account.id) } + let(:account) { Fabricate(:account) } let(:familiar_follower) { Fabricate(:account) } let(:requested_accounts) { Fabricate.times(2, :account) } - subject { described_class.new(requested_accounts, account.id) } - before do familiar_follower.follow!(requested_accounts.first) account.follow!(familiar_follower) diff --git a/spec/serializers/activitypub/note_spec.rb b/spec/serializers/activitypub/note_spec.rb index 55bfbc16b..7ea47baef 100644 --- a/spec/serializers/activitypub/note_spec.rb +++ b/spec/serializers/activitypub/note_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' describe ActivityPub::NoteSerializer do + subject { JSON.parse(@serialization.to_json) } + let!(:account) { Fabricate(:account) } let!(:other) { Fabricate(:account) } let!(:parent) { Fabricate(:status, account: account, visibility: :public) } @@ -16,8 +18,6 @@ describe ActivityPub::NoteSerializer do @serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter) end - subject { JSON.parse(@serialization.to_json) } - it 'has a Note type' do expect(subject['type']).to eql('Note') end diff --git a/spec/serializers/activitypub/update_poll_spec.rb b/spec/serializers/activitypub/update_poll_spec.rb index f9e035eab..4360808b5 100644 --- a/spec/serializers/activitypub/update_poll_spec.rb +++ b/spec/serializers/activitypub/update_poll_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' describe ActivityPub::UpdatePollSerializer do + subject { JSON.parse(@serialization.to_json) } + let(:account) { Fabricate(:account) } let(:poll) { Fabricate(:poll, account: account) } let!(:status) { Fabricate(:status, account: account, poll: poll) } @@ -11,8 +13,6 @@ describe ActivityPub::UpdatePollSerializer do @serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter) end - subject { JSON.parse(@serialization.to_json) } - it 'has a Update type' do expect(subject['type']).to eql('Update') end diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index 3bca06b73..528639943 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe REST::AccountSerializer do + subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } let(:user) { Fabricate(:user, role: role) } let(:account) { user.account } - subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } - context 'when the account is suspended' do before do account.suspend! diff --git a/spec/services/activitypub/fetch_featured_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_collection_service_spec.rb index 23d90a9a2..d9266ffc2 100644 --- a/spec/services/activitypub/fetch_featured_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_collection_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account', featured_collection_url: 'https://example.com/account/pinned') } let!(:known_status) { Fabricate(:status, account: actor, uri: 'https://example.com/account/pinned/1') } @@ -56,8 +58,6 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do }.with_indifferent_access end - subject { described_class.new } - shared_examples 'sets pinned posts' do before do stub_request(:get, 'https://example.com/account/pinned/1').to_return(status: 200, body: Oj.dump(status_json_1)) 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 692866bce..2110baa2d 100644 --- a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do + subject { described_class.new } + let(:collection_url) { 'https://example.com/account/tags' } let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account') } @@ -21,8 +23,6 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service d }.with_indifferent_access end - subject { described_class.new } - shared_examples 'sets featured tags' do before do subject.call(actor, collection_url) diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index 4f3503ac2..6e47392b3 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do include ActionView::Helpers::TextHelper + subject { described_class.new } + let!(:sender) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar') } let!(:recipient) { Fabricate(:account) } @@ -18,8 +20,6 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do } end - subject { described_class.new } - before do stub_request(:get, 'https://foo.bar/watch?v=12345').to_return(status: 404, body: '') stub_request(:get, object[:id]).to_return(body: Oj.dump(object)) diff --git a/spec/services/activitypub/fetch_replies_service_spec.rb b/spec/services/activitypub/fetch_replies_service_spec.rb index 5741e0c3f..0231a5e9a 100644 --- a/spec/services/activitypub/fetch_replies_service_spec.rb +++ b/spec/services/activitypub/fetch_replies_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchRepliesService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') } let(:status) { Fabricate(:status, account: actor) } let(:collection_uri) { 'http://example.com/replies/1' } @@ -28,8 +30,6 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do }.with_indifferent_access end - subject { described_class.new } - describe '#call' do context 'when the payload is a Collection with inlined replies' do context 'when passing the collection itself' do diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index d0af7de76..6c3236bae 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -31,6 +31,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do end context 'when account is not suspended' do + subject { described_class.new.call('alice', 'example.com', payload) } + let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com') } let(:payload) do @@ -46,8 +48,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do allow(Admin::SuspensionWorker).to receive(:perform_async) end - subject { described_class.new.call('alice', 'example.com', payload) } - it 'suspends account remotely' do expect(subject.suspended?).to be true expect(subject.suspension_origin_remote?).to be true @@ -60,6 +60,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do end context 'when account is suspended' do + subject { described_class.new.call('alice', 'example.com', payload) } + let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com', display_name: '') } let(:payload) do @@ -78,8 +80,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do account.suspend!(origin: suspension_origin) end - subject { described_class.new.call('alice', 'example.com', payload) } - context 'locally' do let(:suspension_origin) { :local } diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index d35d9596d..c7d0bb92a 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::ProcessCollectionService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') } let(:payload) do @@ -19,8 +21,6 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do let(:json) { Oj.dump(payload) } - subject { described_class.new } - describe '#call' do context 'when actor is suspended' do before do diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 9a6d75ec0..3d6f76163 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -5,6 +5,8 @@ def poll_option_json(name, votes) end RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do + subject { described_class.new } + let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) } let(:payload) do { @@ -35,8 +37,6 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do media_attachments.each { |m| status.media_attachments << m } end - subject { described_class.new } - describe '#call' do it 'updates text' do subject.call(status, json) diff --git a/spec/services/activitypub/synchronize_followers_service_spec.rb b/spec/services/activitypub/synchronize_followers_service_spec.rb index 5a37f0733..0e829a302 100644 --- a/spec/services/activitypub/synchronize_followers_service_spec.rb +++ b/spec/services/activitypub/synchronize_followers_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account', inbox_url: 'http://example.com/inbox') } let(:alice) { Fabricate(:account, username: 'alice') } let(:bob) { Fabricate(:account, username: 'bob') } @@ -25,8 +27,6 @@ RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do }.with_indifferent_access end - subject { described_class.new } - shared_examples 'synchronizes followers' do before do alice.follow!(actor) 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 006e3f4d2..9cca82bff 100644 --- a/spec/services/after_block_domain_from_account_service_spec.rb +++ b/spec/services/after_block_domain_from_account_service_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' RSpec.describe AfterBlockDomainFromAccountService, type: :service do + subject { AfterBlockDomainFromAccountService.new } + let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) } let!(:alice) { Fabricate(:account, username: 'alice') } - subject { AfterBlockDomainFromAccountService.new } - before do stub_jsonld_contexts! allow(ActivityPub::DeliveryWorker).to receive(:perform_async) diff --git a/spec/services/app_sign_up_service_spec.rb b/spec/services/app_sign_up_service_spec.rb index 8ec4d4a7a..10da07dcf 100644 --- a/spec/services/app_sign_up_service_spec.rb +++ b/spec/services/app_sign_up_service_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe AppSignUpService, type: :service do + subject { described_class.new } + let(:app) { Fabricate(:application, scopes: 'read write') } let(:good_params) { { username: 'alice', password: '12345678', email: 'good@email.com', agreement: true } } let(:remote_ip) { IPAddr.new('198.0.2.1') } - subject { described_class.new } - describe '#call' do it 'returns nil when registrations are closed' do tmp = Setting.registrations_mode diff --git a/spec/services/authorize_follow_service_spec.rb b/spec/services/authorize_follow_service_spec.rb index 888d694b6..8f8e44ec7 100644 --- a/spec/services/authorize_follow_service_spec.rb +++ b/spec/services/authorize_follow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe AuthorizeFollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { AuthorizeFollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index e24e48d41..56b3a5ad1 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' RSpec.describe BlockDomainService, type: :service do + subject { BlockDomainService.new } + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) } let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) } - subject { BlockDomainService.new } - describe 'for a suspension' do before do subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend)) diff --git a/spec/services/block_service_spec.rb b/spec/services/block_service_spec.rb index a53e1f928..049644dbc 100644 --- a/spec/services/block_service_spec.rb +++ b/spec/services/block_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe BlockService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { BlockService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/services/clear_domain_media_service_spec.rb b/spec/services/clear_domain_media_service_spec.rb index e90faf84d..993ba789e 100644 --- a/spec/services/clear_domain_media_service_spec.rb +++ b/spec/services/clear_domain_media_service_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' RSpec.describe ClearDomainMediaService, type: :service do + subject { ClearDomainMediaService.new } + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) } - subject { ClearDomainMediaService.new } - describe 'for a silence with reject media' do before do subject.call(DomainBlock.create!(domain: 'evil.org', severity: :silence, reject_media: true)) diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index cc4b168fc..d0cc8d288 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -2,6 +2,8 @@ require 'rails_helper' RSpec.describe DeleteAccountService, type: :service do shared_examples 'common behavior' do + subject { described_class.new.call(account) } + let!(:status) { Fabricate(:status, account: account) } let!(:mention) { Fabricate(:mention, account: local_follower) } let!(:status_with_mention) { Fabricate(:status, account: account, mentions: [mention]) } @@ -23,8 +25,6 @@ RSpec.describe DeleteAccountService, type: :service do let!(:account_note) { Fabricate(:account_note, account: account) } - subject { described_class.new.call(account) } - it 'deletes associated owned records' do expect { subject }.to change { [ diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 3c294cf95..d09750dd2 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe FanOutOnWriteService, type: :service do + subject { described_class.new } + let(:last_active_at) { Time.now.utc } let(:status) { Fabricate(:status, account: alice, visibility: visibility, text: 'Hello @bob #hoge') } @@ -8,8 +10,6 @@ RSpec.describe FanOutOnWriteService, type: :service do let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account } let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account } - subject { described_class.new } - before do bob.follow!(alice) tom.follow!(alice) diff --git a/spec/services/favourite_service_spec.rb b/spec/services/favourite_service_spec.rb index 8703c2af8..4f621200a 100644 --- a/spec/services/favourite_service_spec.rb +++ b/spec/services/favourite_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe FavouriteService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { FavouriteService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account) } let(:status) { Fabricate(:status, account: bob) } diff --git a/spec/services/fetch_resource_service_spec.rb b/spec/services/fetch_resource_service_spec.rb index c39f52632..84c4035cb 100644 --- a/spec/services/fetch_resource_service_spec.rb +++ b/spec/services/fetch_resource_service_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe FetchResourceService, type: :service do describe '#call' do - let(:url) { 'http://example.com' } - subject { described_class.new.call(url) } + let(:url) { 'http://example.com' } + context 'with blank url' do let(:url) { '' } diff --git a/spec/services/follow_service_spec.rb b/spec/services/follow_service_spec.rb index 59073c27f..f95d59440 100644 --- a/spec/services/follow_service_spec.rb +++ b/spec/services/follow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe FollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { FollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + context 'local account' do describe 'locked account' do let(:bob) { Fabricate(:account, locked: true, username: 'bob') } diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index 6a16928e0..79ccfa322 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe ProcessMentionsService, type: :service do - let(:account) { Fabricate(:account, username: 'alice') } - subject { ProcessMentionsService.new } + let(:account) { Fabricate(:account, username: 'alice') } + context 'when mentions contain blocked accounts' do let(:non_blocked_account) { Fabricate(:account) } let(:individually_blocked_account) { Fabricate(:account) } diff --git a/spec/services/purge_domain_service_spec.rb b/spec/services/purge_domain_service_spec.rb index 59285f126..7d8969ee8 100644 --- a/spec/services/purge_domain_service_spec.rb +++ b/spec/services/purge_domain_service_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' RSpec.describe PurgeDomainService, type: :service do + subject { PurgeDomainService.new } + let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') } let!(:old_status1) { Fabricate(:status, account: old_account) } let!(:old_status2) { Fabricate(:status, account: old_account) } let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status2, file: attachment_fixture('attachment.jpg')) } - subject { PurgeDomainService.new } - describe 'for a suspension' do before do subject.call('obsolete.org') diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index c0ae5eedc..e2ac0154c 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -4,12 +4,12 @@ RSpec.describe ReblogService, type: :service do let(:alice) { Fabricate(:account, username: 'alice') } context 'creates a reblog with appropriate visibility' do + subject { ReblogService.new } + let(:visibility) { :public } let(:reblog_visibility) { :public } let(:status) { Fabricate(:status, account: alice, visibility: visibility) } - subject { ReblogService.new } - before do subject.call(alice, status, visibility: reblog_visibility) end @@ -45,11 +45,11 @@ RSpec.describe ReblogService, type: :service do end context 'ActivityPub' do + subject { ReblogService.new } + let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } let(:status) { Fabricate(:status, account: bob) } - subject { ReblogService.new } - before do stub_request(:post, bob.inbox_url) allow(ActivityPub::DistributionWorker).to receive(:perform_async) diff --git a/spec/services/reject_follow_service_spec.rb b/spec/services/reject_follow_service_spec.rb index e14bfa78d..97b7412b9 100644 --- a/spec/services/reject_follow_service_spec.rb +++ b/spec/services/reject_follow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe RejectFollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { RejectFollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account) } diff --git a/spec/services/remove_from_follwers_service_spec.rb b/spec/services/remove_from_follwers_service_spec.rb index 9b9c846cf..782f859e2 100644 --- a/spec/services/remove_from_follwers_service_spec.rb +++ b/spec/services/remove_from_follwers_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe RemoveFromFollowersService, type: :service do - let(:bob) { Fabricate(:account, username: 'bob') } - subject { RemoveFromFollowersService.new } + let(:bob) { Fabricate(:account, username: 'bob') } + describe 'local' do let(:sender) { Fabricate(:account, username: 'alice') } diff --git a/spec/services/report_service_spec.rb b/spec/services/report_service_spec.rb index 02bc42ac1..c3a3fddf8 100644 --- a/spec/services/report_service_spec.rb +++ b/spec/services/report_service_spec.rb @@ -29,13 +29,13 @@ RSpec.describe ReportService, type: :service do end context 'when the reported status is a DM' do - let(:target_account) { Fabricate(:account) } - let(:status) { Fabricate(:status, account: target_account, visibility: :direct) } - subject do -> { described_class.new.call(source_account, target_account, status_ids: [status.id]) } end + let(:target_account) { Fabricate(:account) } + let(:status) { Fabricate(:status, account: target_account, visibility: :direct) } + context 'when it is addressed to the reporter' do before do status.mentions.create(account: source_account) @@ -85,13 +85,13 @@ RSpec.describe ReportService, type: :service do end context 'when other reports already exist for the same target' do - let!(:target_account) { Fabricate(:account) } - let!(:other_report) { Fabricate(:report, target_account: target_account) } - subject do -> { described_class.new.call(source_account, target_account) } end + let!(:target_account) { Fabricate(:account) } + let!(:other_report) { Fabricate(:report, target_account: target_account) } + before do ActionMailer::Base.deliveries.clear source_account.user.settings.notification_emails['report'] = true diff --git a/spec/services/suspend_account_service_spec.rb b/spec/services/suspend_account_service_spec.rb index 126b13986..5701090b3 100644 --- a/spec/services/suspend_account_service_spec.rb +++ b/spec/services/suspend_account_service_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' RSpec.describe SuspendAccountService, type: :service do shared_examples 'common behavior' do + subject { described_class.new.call(account) } + let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account } let!(:list) { Fabricate(:list, account: local_follower) } - subject { described_class.new.call(account) } - before do allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil) allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil) diff --git a/spec/services/unallow_domain_service_spec.rb b/spec/services/unallow_domain_service_spec.rb index b93945b9a..ae7d00c7d 100644 --- a/spec/services/unallow_domain_service_spec.rb +++ b/spec/services/unallow_domain_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe UnallowDomainService, type: :service do + subject { UnallowDomainService.new } + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } @@ -8,8 +10,6 @@ RSpec.describe UnallowDomainService, type: :service do let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) } let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') } - subject { UnallowDomainService.new } - context 'in limited federation mode' do before do allow(subject).to receive(:whitelist_mode?).and_return(true) diff --git a/spec/services/unblock_service_spec.rb b/spec/services/unblock_service_spec.rb index 10448b340..bd24005f6 100644 --- a/spec/services/unblock_service_spec.rb +++ b/spec/services/unblock_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe UnblockService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { UnblockService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account) } diff --git a/spec/services/unfollow_service_spec.rb b/spec/services/unfollow_service_spec.rb index bb5bef5c9..55969bef9 100644 --- a/spec/services/unfollow_service_spec.rb +++ b/spec/services/unfollow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe UnfollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { UnfollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/services/unsuspend_account_service_spec.rb b/spec/services/unsuspend_account_service_spec.rb index 987eb09e2..667507469 100644 --- a/spec/services/unsuspend_account_service_spec.rb +++ b/spec/services/unsuspend_account_service_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' RSpec.describe UnsuspendAccountService, type: :service do shared_examples 'common behavior' do + subject { described_class.new.call(account) } + let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account } let!(:list) { Fabricate(:list, account: local_follower) } - subject { described_class.new.call(account) } - before do allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil) allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil) diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb index cb807fe24..a642405ae 100644 --- a/spec/validators/blacklisted_email_validator_spec.rb +++ b/spec/validators/blacklisted_email_validator_spec.rb @@ -4,6 +4,8 @@ require 'rails_helper' RSpec.describe BlacklistedEmailValidator, type: :validator do describe '#validate' do + subject { described_class.new.validate(user); errors } + let(:user) { double(email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) } let(:errors) { double(add: nil) } @@ -12,8 +14,6 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email } end - subject { described_class.new.validate(user); errors } - context 'when e-mail provider is blocked' do let(:blocked_email) { true } diff --git a/spec/workers/move_worker_spec.rb b/spec/workers/move_worker_spec.rb index 3ca6aaf4d..e93060adb 100644 --- a/spec/workers/move_worker_spec.rb +++ b/spec/workers/move_worker_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' describe MoveWorker do + subject { described_class.new } + let(:local_follower) { Fabricate(:account) } let(:blocking_account) { Fabricate(:account) } let(:muting_account) { Fabricate(:account) } @@ -14,8 +16,6 @@ describe MoveWorker do let(:block_service) { double } - subject { described_class.new } - before do local_follower.follow!(source_account) blocking_account.block!(source_account) diff --git a/spec/workers/unfollow_follow_worker_spec.rb b/spec/workers/unfollow_follow_worker_spec.rb index 5ea4256a9..8025b88c0 100644 --- a/spec/workers/unfollow_follow_worker_spec.rb +++ b/spec/workers/unfollow_follow_worker_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe UnfollowFollowWorker do + subject { described_class.new } + let(:local_follower) { Fabricate(:account) } let(:source_account) { Fabricate(:account) } let(:target_account) { Fabricate(:account) } let(:show_reblogs) { true } - subject { described_class.new } - before do local_follower.follow!(source_account, reblogs: show_reblogs) end -- 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/models/user_spec.rb') 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 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/models/user_spec.rb') 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 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/models/user_spec.rb') 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