Skip to content

Commit

Permalink
Add tests for making sure private status don't get sent over OStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Apr 14, 2019
1 parent afceb84 commit 45fe442
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions spec/services/process_mentions_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require 'rails_helper'

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

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

subject { ProcessMentionsService.new }
Expand All @@ -23,6 +24,26 @@
end
end

context 'OStatus with private toot' do
let(:visibility) { :private }
let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :ostatus, domain: 'example.com', salmon_url: 'http://salmon.example.com') }

subject { ProcessMentionsService.new }

before do
stub_request(:post, remote_user.salmon_url)
subject.call(status)
end

it 'does not create a mention' do
expect(remote_user.mentions.where(status: status).count).to eq 0
end

it 'does not post to remote user\'s Salmon end point' do
expect(a_request(:post, remote_user.salmon_url)).to_not have_been_made
end
end

context 'ActivityPub' do
let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }

Expand Down

0 comments on commit 45fe442

Please sign in to comment.