Skip to content

Commit 45fe442

Browse files
committed
Add tests for making sure private status don't get sent over OStatus
1 parent afceb84 commit 45fe442

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

spec/services/process_mentions_service_spec.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
require 'rails_helper'
22

33
RSpec.describe ProcessMentionsService, type: :service do
4-
let(:account) { Fabricate(:account, username: 'alice') }
5-
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}") }
4+
let(:account) { Fabricate(:account, username: 'alice') }
5+
let(:visibility) { :public }
6+
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: visibility) }
67

7-
context 'OStatus' do
8+
context 'OStatus with public toot' do
89
let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :ostatus, domain: 'example.com', salmon_url: 'http://salmon.example.com') }
910

1011
subject { ProcessMentionsService.new }
@@ -23,6 +24,26 @@
2324
end
2425
end
2526

27+
context 'OStatus with private toot' do
28+
let(:visibility) { :private }
29+
let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :ostatus, domain: 'example.com', salmon_url: 'http://salmon.example.com') }
30+
31+
subject { ProcessMentionsService.new }
32+
33+
before do
34+
stub_request(:post, remote_user.salmon_url)
35+
subject.call(status)
36+
end
37+
38+
it 'does not create a mention' do
39+
expect(remote_user.mentions.where(status: status).count).to eq 0
40+
end
41+
42+
it 'does not post to remote user\'s Salmon end point' do
43+
expect(a_request(:post, remote_user.salmon_url)).to_not have_been_made
44+
end
45+
end
46+
2647
context 'ActivityPub' do
2748
let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
2849

0 commit comments

Comments
 (0)