|
1 | 1 | require 'rails_helper' |
2 | 2 |
|
3 | 3 | RSpec.describe ActivityPub::Activity::Announce do |
4 | | - let(:sender) { Fabricate(:account) } |
| 4 | + let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers') } |
5 | 5 | let(:recipient) { Fabricate(:account) } |
6 | 6 | let(:status) { Fabricate(:status, account: recipient) } |
7 | 7 |
|
|
11 | 11 | id: 'foo', |
12 | 12 | type: 'Announce', |
13 | 13 | actor: ActivityPub::TagManager.instance.uri_for(sender), |
14 | | - object: ActivityPub::TagManager.instance.uri_for(status), |
| 14 | + object: object_json, |
15 | 15 | }.with_indifferent_access |
16 | 16 | end |
17 | 17 |
|
18 | | - describe '#perform' do |
19 | | - subject { described_class.new(json, sender) } |
| 18 | + subject { described_class.new(json, sender) } |
| 19 | + |
| 20 | + before do |
| 21 | + sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender)) |
| 22 | + end |
20 | 23 |
|
| 24 | + describe '#perform' do |
21 | 25 | before do |
22 | 26 | subject.perform |
23 | 27 | end |
24 | 28 |
|
25 | | - it 'creates a reblog by sender of status' do |
26 | | - expect(sender.reblogged?(status)).to be true |
| 29 | + context 'a known status' do |
| 30 | + let(:object_json) do |
| 31 | + ActivityPub::TagManager.instance.uri_for(status) |
| 32 | + end |
| 33 | + |
| 34 | + it 'creates a reblog by sender of status' do |
| 35 | + expect(sender.reblogged?(status)).to be true |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + context 'self-boost of a previously unknown status with missing attributedTo' do |
| 40 | + let(:object_json) do |
| 41 | + { |
| 42 | + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 43 | + type: 'Note', |
| 44 | + content: 'Lorem ipsum', |
| 45 | + to: 'http://example.com/followers', |
| 46 | + } |
| 47 | + end |
| 48 | + |
| 49 | + it 'creates a reblog by sender of status' do |
| 50 | + expect(sender.reblogged?(sender.statuses.first)).to be true |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + context 'self-boost of a previously unknown status with correct attributedTo' do |
| 55 | + let(:object_json) do |
| 56 | + { |
| 57 | + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 58 | + type: 'Note', |
| 59 | + content: 'Lorem ipsum', |
| 60 | + attributedTo: ActivityPub::TagManager.instance.uri_for(sender), |
| 61 | + to: 'http://example.com/followers', |
| 62 | + } |
| 63 | + end |
| 64 | + |
| 65 | + it 'creates a reblog by sender of status' do |
| 66 | + expect(sender.reblogged?(sender.statuses.first)).to be true |
| 67 | + end |
27 | 68 | end |
28 | 69 | end |
29 | 70 | end |
0 commit comments