|
1 | 1 | require 'rails_helper' |
2 | 2 |
|
3 | 3 | RSpec.describe ActivityPub::Activity::Announce do |
4 | | - let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers') } |
| 4 | + let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') } |
5 | 5 | let(:recipient) { Fabricate(:account) } |
6 | 6 | let(:status) { Fabricate(:status, account: recipient) } |
7 | 7 |
|
|
10 | 10 | '@context': 'https://www.w3.org/ns/activitystreams', |
11 | 11 | id: 'foo', |
12 | 12 | type: 'Announce', |
13 | | - actor: ActivityPub::TagManager.instance.uri_for(sender), |
| 13 | + actor: 'https://example.com/actor', |
14 | 14 | object: object_json, |
15 | 15 | }.with_indifferent_access |
16 | 16 | end |
17 | 17 |
|
18 | | - subject { described_class.new(json, sender) } |
19 | | - |
20 | | - before do |
21 | | - sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender)) |
| 18 | + let(:unknown_object_json) do |
| 19 | + { |
| 20 | + '@context': 'https://www.w3.org/ns/activitystreams', |
| 21 | + id: 'https://example.com/actor/hello-world', |
| 22 | + type: 'Note', |
| 23 | + attributedTo: 'https://example.com/actor', |
| 24 | + content: 'Hello world', |
| 25 | + to: 'http://example.com/followers', |
| 26 | + } |
22 | 27 | end |
23 | 28 |
|
| 29 | + subject { described_class.new(json, sender) } |
| 30 | + |
24 | 31 | describe '#perform' do |
25 | 32 | context 'when sender is followed by a local account' do |
26 | 33 | before do |
27 | 34 | Fabricate(:account).follow!(sender) |
| 35 | + stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json)) |
28 | 36 | subject.perform |
29 | 37 | end |
30 | 38 |
|
|
38 | 46 | end |
39 | 47 | end |
40 | 48 |
|
| 49 | + context 'an unknown status' do |
| 50 | + let(:object_json) { 'https://example.com/actor/hello-world' } |
| 51 | + |
| 52 | + it 'creates a reblog by sender of status' do |
| 53 | + reblog = sender.statuses.first |
| 54 | + |
| 55 | + expect(reblog).to_not be_nil |
| 56 | + expect(reblog.reblog.text).to eq 'Hello world' |
| 57 | + end |
| 58 | + end |
| 59 | + |
41 | 60 | context 'self-boost of a previously unknown status with missing attributedTo' do |
42 | 61 | let(:object_json) do |
43 | 62 | { |
44 | | - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 63 | + id: 'https://example.com/actor#bar', |
45 | 64 | type: 'Note', |
46 | 65 | content: 'Lorem ipsum', |
47 | 66 | to: 'http://example.com/followers', |
|
56 | 75 | context 'self-boost of a previously unknown status with correct attributedTo' do |
57 | 76 | let(:object_json) do |
58 | 77 | { |
59 | | - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 78 | + id: 'https://example.com/actor#bar', |
60 | 79 | type: 'Note', |
61 | 80 | content: 'Lorem ipsum', |
62 | | - attributedTo: ActivityPub::TagManager.instance.uri_for(sender), |
| 81 | + attributedTo: 'https://example.com/actor', |
63 | 82 | to: 'http://example.com/followers', |
64 | 83 | } |
65 | 84 | end |
|
98 | 117 |
|
99 | 118 | let(:object_json) do |
100 | 119 | { |
101 | | - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 120 | + id: 'https://example.com/actor#bar', |
102 | 121 | type: 'Note', |
103 | 122 | content: 'Lorem ipsum', |
104 | 123 | to: 'http://example.com/followers', |
|
117 | 136 |
|
118 | 137 | let(:object_json) do |
119 | 138 | { |
120 | | - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 139 | + id: 'https://example.com/actor#bar', |
121 | 140 | type: 'Note', |
122 | 141 | content: 'Lorem ipsum', |
123 | 142 | to: 'http://example.com/followers', |
|
137 | 156 |
|
138 | 157 | let(:object_json) do |
139 | 158 | { |
140 | | - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 159 | + id: 'https://example.com/actor#bar', |
141 | 160 | type: 'Note', |
142 | 161 | content: 'Lorem ipsum', |
143 | 162 | to: 'http://example.com/followers', |
|
0 commit comments