about summary refs log tree commit diff
path: root/spec/lib/activitypub
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-02-17 10:58:25 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-02-17 10:58:44 +0100
commitf224237862b009ad4b008a8730c58111f103145b (patch)
tree097c08663c6348914fdf95d2ac9ce57ee2a3307c /spec/lib/activitypub
parentec4f9066189fbab4368a275e9cd654dc7ad48217 (diff)
parentac99f586bb4138e083676579097d951434e90515 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `db/schema.rb`:
  Conflict due to glitch-soc adding the `content_type` column on status edits
  and thus having a different schema version number.
  Solved by taking upstream's schema version number, as it is higher than
  glitch-soc's.
Diffstat (limited to 'spec/lib/activitypub')
-rw-r--r--spec/lib/activitypub/activity/announce_spec.rb32
1 files changed, 12 insertions, 20 deletions
diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb
index b93fcbe66..41806b258 100644
--- a/spec/lib/activitypub/activity/announce_spec.rb
+++ b/spec/lib/activitypub/activity/announce_spec.rb
@@ -113,26 +113,23 @@ RSpec.describe ActivityPub::Activity::Announce do
       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_account: relay_account) }
 
+      before do
+        stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
+      end
+
       context 'and the relay is enabled' do
         before do
           relay.update(state: :accepted)
           subject.perform
         end
 
-        let(:object_json) do
-          {
-            id: 'https://example.com/actor#bar',
-            type: 'Note',
-            content: 'Lorem ipsum',
-            to: 'http://example.com/followers',
-            attributedTo: 'https://example.com/actor',
-          }
-        end
-
-        it 'creates a reblog by sender of status' do
-          expect(sender.statuses.count).to eq 2
+        it 'fetches the remote status' do
+          expect(a_request(:get, 'https://example.com/actor/hello-world')).to have_been_made
+          expect(Status.find_by(uri: 'https://example.com/actor/hello-world').text).to eq 'Hello world'
         end
       end
 
@@ -141,14 +138,9 @@ RSpec.describe ActivityPub::Activity::Announce do
           subject.perform
         end
 
-        let(:object_json) do
-          {
-            id: 'https://example.com/actor#bar',
-            type: 'Note',
-            content: 'Lorem ipsum',
-            to: 'http://example.com/followers',
-            attributedTo: 'https://example.com/actor',
-          }
+        it 'does not fetch the remote status' do
+          expect(a_request(:get, 'https://example.com/actor/hello-world')).not_to have_been_made
+          expect(Status.find_by(uri: 'https://example.com/actor/hello-world')).to be_nil
         end
 
         it 'does not create anything' do