about summary refs log tree commit diff
path: root/spec/lib/activitypub/activity
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/activitypub/activity')
-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
6 files changed, 20 insertions, 20 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