about summary refs log tree commit diff
path: root/spec/lib/activitypub/activity
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-02-13 18:36:23 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-02-13 18:36:23 +0100
commit6a5307a5733e7872e7827f32b27111434e0307c4 (patch)
tree2980ccee1259a7a36b40ce86c3711eed676a0614 /spec/lib/activitypub/activity
parent169b9d4428d8e54d7bee365fd76be9a6e2a92da5 (diff)
Alternative handling of private self-boosts (#9998)
* When self-boosting, embed original toot into Announce serialization

* Process unknown self-boosts from Announce object if it is more than an URI

* Add some self-boost specs

* Only serialize private toots in self-Announces
Diffstat (limited to 'spec/lib/activitypub/activity')
-rw-r--r--spec/lib/activitypub/activity/announce_spec.rb53
1 files changed, 47 insertions, 6 deletions
diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb
index 54dd52a60..1725c2843 100644
--- a/spec/lib/activitypub/activity/announce_spec.rb
+++ b/spec/lib/activitypub/activity/announce_spec.rb
@@ -1,7 +1,7 @@
 require 'rails_helper'
 
 RSpec.describe ActivityPub::Activity::Announce do
-  let(:sender)    { Fabricate(:account) }
+  let(:sender)    { Fabricate(:account, followers_url: 'http://example.com/followers') }
   let(:recipient) { Fabricate(:account) }
   let(:status)    { Fabricate(:status, account: recipient) }
 
@@ -11,19 +11,60 @@ RSpec.describe ActivityPub::Activity::Announce do
       id: 'foo',
       type: 'Announce',
       actor: ActivityPub::TagManager.instance.uri_for(sender),
-      object: ActivityPub::TagManager.instance.uri_for(status),
+      object: object_json,
     }.with_indifferent_access
   end
 
-  describe '#perform' do
-    subject { described_class.new(json, sender) }
+  subject { described_class.new(json, sender) }
+
+  before do
+    sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender))
+  end
 
+  describe '#perform' do
     before do
       subject.perform
     end
 
-    it 'creates a reblog by sender of status' do
-      expect(sender.reblogged?(status)).to be true
+    context 'a known status' do
+      let(:object_json) do
+        ActivityPub::TagManager.instance.uri_for(status)
+      end
+
+      it 'creates a reblog by sender of status' do
+        expect(sender.reblogged?(status)).to be true
+      end
+    end
+
+    context 'self-boost of a previously unknown status with missing attributedTo' do
+      let(:object_json) do
+        {
+          id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
+          type: 'Note',
+          content: 'Lorem ipsum',
+          to: 'http://example.com/followers',
+        }
+      end
+
+      it 'creates a reblog by sender of status' do
+        expect(sender.reblogged?(sender.statuses.first)).to be true
+      end
+    end
+
+    context 'self-boost of a previously unknown status with correct attributedTo' do
+      let(:object_json) do
+        {
+          id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
+          type: 'Note',
+          content: 'Lorem ipsum',
+          attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
+          to: 'http://example.com/followers',
+        }
+      end
+
+      it 'creates a reblog by sender of status' do
+        expect(sender.reblogged?(sender.statuses.first)).to be true
+      end
     end
   end
 end