about summary refs log tree commit diff
path: root/spec/lib
diff options
context:
space:
mode:
authorNick Schonning <nschonni@gmail.com>2023-02-19 23:24:14 -0500
committerGitHub <noreply@github.com>2023-02-20 13:24:14 +0900
commit4552685f6bd400666ec4058783eeabb11568e575 (patch)
treeab708e0d54b9309f96ef0e4d17e8afd32221c5c6 /spec/lib
parent4ea1e0fceb0c0c5fee014a99f81f8f13a16f6dde (diff)
Autofix Rubocop RSpec/LeadingSubject (#23670)
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/activitypub/activity/accept_spec.rb4
-rw-r--r--spec/lib/activitypub/activity/announce_spec.rb8
-rw-r--r--spec/lib/activitypub/activity/create_spec.rb16
-rw-r--r--spec/lib/activitypub/activity/reject_spec.rb4
-rw-r--r--spec/lib/activitypub/activity/undo_spec.rb4
-rw-r--r--spec/lib/activitypub/activity/update_spec.rb4
-rw-r--r--spec/lib/activitypub/adapter_spec.rb4
-rw-r--r--spec/lib/activitypub/dereferencer_spec.rb4
-rw-r--r--spec/lib/activitypub/linked_data_signature_spec.rb4
-rw-r--r--spec/lib/link_details_extractor_spec.rb4
-rw-r--r--spec/lib/status_filter_spec.rb4
-rw-r--r--spec/lib/status_reach_finder_spec.rb4
-rw-r--r--spec/lib/suspicious_sign_in_detector_spec.rb4
-rw-r--r--spec/lib/text_formatter_spec.rb4
-rw-r--r--spec/lib/vacuum/backups_vacuum_spec.rb4
-rw-r--r--spec/lib/vacuum/media_attachments_vacuum_spec.rb4
-rw-r--r--spec/lib/vacuum/preview_cards_vacuum_spec.rb4
-rw-r--r--spec/lib/vacuum/statuses_vacuum_spec.rb4
18 files changed, 44 insertions, 44 deletions
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) }