You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

  1. require 'rails_helper'
  2. RSpec.describe ProcessMentionsService do
  3. let(:account) { Fabricate(:account, username: 'alice') }
  4. let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}") }
  5. context 'OStatus' do
  6. let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :ostatus, domain: 'example.com', salmon_url: 'http://salmon.example.com') }
  7. subject { ProcessMentionsService.new }
  8. before do
  9. stub_request(:post, remote_user.salmon_url)
  10. subject.call(status)
  11. end
  12. it 'creates a mention' do
  13. expect(remote_user.mentions.where(status: status).count).to eq 1
  14. end
  15. it 'posts to remote user\'s Salmon end point' do
  16. expect(a_request(:post, remote_user.salmon_url)).to have_been_made.once
  17. end
  18. end
  19. context 'ActivityPub' do
  20. let(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  21. subject { ProcessMentionsService.new }
  22. before do
  23. stub_request(:post, remote_user.inbox_url)
  24. subject.call(status)
  25. end
  26. it 'creates a mention' do
  27. expect(remote_user.mentions.where(status: status).count).to eq 1
  28. end
  29. it 'sends activity to the inbox' do
  30. expect(a_request(:post, remote_user.inbox_url)).to have_been_made.once
  31. end
  32. end
  33. end