about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-01-18 15:57:19 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-01-18 15:57:19 +0100
commitaeb124491d169c2a75ee6c20520859dc865511ed (patch)
treec587e1c50e992e25ab11b838cec4542c24edebdf /spec/services
parent75b1488cf4dfe54260deff8df20e5e9b9fd90aea (diff)
Reject existing Follow in addition to sending a Block (#9811)
Mastodon expects remote servers to remove follow relationships upon receiving
a Block. However, the spec only evokes Block activities in a C2S context, never
in a S2S context.

This PR, in addition to federating the Block, explicitly sends a Reject for any
affected follow relationship, which makes a bit more sense with regards to the
spec.
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/unfollow_service_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/services/unfollow_service_spec.rb b/spec/services/unfollow_service_spec.rb
index c5914c818..8a2881ab1 100644
--- a/spec/services/unfollow_service_spec.rb
+++ b/spec/services/unfollow_service_spec.rb
@@ -56,4 +56,22 @@ RSpec.describe UnfollowService, type: :service do
       expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
     end
   end
+
+  describe 'remote ActivityPub (reverse)' do
+    let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox')).account }
+
+    before do
+      bob.follow!(sender)
+      stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
+      subject.call(bob, sender)
+    end
+
+    it 'destroys the following relation' do
+      expect(bob.following?(sender)).to be false
+    end
+
+    it 'sends a reject activity' do
+      expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
+    end
+  end
 end