|
18 | 18 | subject { described_class.new(json, sender) } |
19 | 19 |
|
20 | 20 | before do |
21 | | - Fabricate(:account).follow!(sender) |
22 | 21 | sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender)) |
23 | 22 | end |
24 | 23 |
|
25 | 24 | describe '#perform' do |
26 | | - before do |
27 | | - subject.perform |
| 25 | + context 'when sender is followed by a local account' do |
| 26 | + before do |
| 27 | + Fabricate(:account).follow!(sender) |
| 28 | + subject.perform |
| 29 | + end |
| 30 | + |
| 31 | + context 'a known status' do |
| 32 | + let(:object_json) do |
| 33 | + ActivityPub::TagManager.instance.uri_for(status) |
| 34 | + end |
| 35 | + |
| 36 | + it 'creates a reblog by sender of status' do |
| 37 | + expect(sender.reblogged?(status)).to be true |
| 38 | + end |
| 39 | + end |
| 40 | + |
| 41 | + context 'self-boost of a previously unknown status with missing attributedTo' do |
| 42 | + let(:object_json) do |
| 43 | + { |
| 44 | + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 45 | + type: 'Note', |
| 46 | + content: 'Lorem ipsum', |
| 47 | + to: 'http://example.com/followers', |
| 48 | + } |
| 49 | + end |
| 50 | + |
| 51 | + it 'creates a reblog by sender of status' do |
| 52 | + expect(sender.reblogged?(sender.statuses.first)).to be true |
| 53 | + end |
| 54 | + end |
| 55 | + |
| 56 | + context 'self-boost of a previously unknown status with correct attributedTo' do |
| 57 | + let(:object_json) do |
| 58 | + { |
| 59 | + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 60 | + type: 'Note', |
| 61 | + content: 'Lorem ipsum', |
| 62 | + attributedTo: ActivityPub::TagManager.instance.uri_for(sender), |
| 63 | + to: 'http://example.com/followers', |
| 64 | + } |
| 65 | + end |
| 66 | + |
| 67 | + it 'creates a reblog by sender of status' do |
| 68 | + expect(sender.reblogged?(sender.statuses.first)).to be true |
| 69 | + end |
| 70 | + end |
28 | 71 | end |
29 | 72 |
|
30 | | - context 'a known status' do |
| 73 | + context 'when the status belongs to a local user' do |
| 74 | + before do |
| 75 | + subject.perform |
| 76 | + end |
| 77 | + |
31 | 78 | let(:object_json) do |
32 | 79 | ActivityPub::TagManager.instance.uri_for(status) |
33 | 80 | end |
|
37 | 84 | end |
38 | 85 | end |
39 | 86 |
|
40 | | - context 'self-boost of a previously unknown status with missing attributedTo' do |
41 | | - let(:object_json) do |
42 | | - { |
43 | | - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
44 | | - type: 'Note', |
45 | | - content: 'Lorem ipsum', |
46 | | - to: 'http://example.com/followers', |
47 | | - } |
| 87 | + context 'when the sender is relayed' do |
| 88 | + let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') } |
| 89 | + let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') } |
| 90 | + |
| 91 | + subject { described_class.new(json, sender, relayed_through_account: relay_account) } |
| 92 | + |
| 93 | + context 'and the relay is enabled' do |
| 94 | + before do |
| 95 | + relay.update(state: :accepted) |
| 96 | + subject.perform |
| 97 | + end |
| 98 | + |
| 99 | + let(:object_json) do |
| 100 | + { |
| 101 | + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 102 | + type: 'Note', |
| 103 | + content: 'Lorem ipsum', |
| 104 | + to: 'http://example.com/followers', |
| 105 | + } |
| 106 | + end |
| 107 | + |
| 108 | + it 'creates a reblog by sender of status' do |
| 109 | + expect(sender.statuses.count).to eq 2 |
| 110 | + end |
48 | 111 | end |
49 | 112 |
|
50 | | - it 'creates a reblog by sender of status' do |
51 | | - expect(sender.reblogged?(sender.statuses.first)).to be true |
| 113 | + context 'and the relay is disabled' do |
| 114 | + before do |
| 115 | + subject.perform |
| 116 | + end |
| 117 | + |
| 118 | + let(:object_json) do |
| 119 | + { |
| 120 | + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
| 121 | + type: 'Note', |
| 122 | + content: 'Lorem ipsum', |
| 123 | + to: 'http://example.com/followers', |
| 124 | + } |
| 125 | + end |
| 126 | + |
| 127 | + it 'does not create anything' do |
| 128 | + expect(sender.statuses.count).to eq 0 |
| 129 | + end |
52 | 130 | end |
53 | 131 | end |
54 | 132 |
|
55 | | - context 'self-boost of a previously unknown status with correct attributedTo' do |
| 133 | + context 'when the sender has no relevance to local activity' do |
| 134 | + before do |
| 135 | + subject.perform |
| 136 | + end |
| 137 | + |
56 | 138 | let(:object_json) do |
57 | 139 | { |
58 | 140 | id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, |
59 | 141 | type: 'Note', |
60 | 142 | content: 'Lorem ipsum', |
61 | | - attributedTo: ActivityPub::TagManager.instance.uri_for(sender), |
62 | 143 | to: 'http://example.com/followers', |
63 | 144 | } |
64 | 145 | end |
65 | 146 |
|
66 | | - it 'creates a reblog by sender of status' do |
67 | | - expect(sender.reblogged?(sender.statuses.first)).to be true |
| 147 | + it 'does not create anything' do |
| 148 | + expect(sender.statuses.count).to eq 0 |
68 | 149 | end |
69 | 150 | end |
70 | 151 | end |
|
0 commit comments