1
0

favourite_service_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. RSpec.describe FavouriteService, type: :service do
  3. let(:sender) { Fabricate(:account, username: 'alice') }
  4. subject { FavouriteService.new }
  5. describe 'local' do
  6. let(:bob) { Fabricate(:account) }
  7. let(:status) { Fabricate(:status, account: bob) }
  8. before do
  9. subject.call(sender, status)
  10. end
  11. it 'creates a favourite' do
  12. expect(status.favourites.first).to_not be_nil
  13. end
  14. end
  15. describe 'remote ActivityPub' do
  16. let(:bob) { Fabricate(:account, protocol: :activitypub, username: 'bob', domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  17. let(:status) { Fabricate(:status, account: bob) }
  18. before do
  19. stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {})
  20. subject.call(sender, status)
  21. end
  22. it 'creates a favourite' do
  23. expect(status.favourites.first).to_not be_nil
  24. end
  25. it 'sends a like activity' do
  26. expect(a_request(:post, "http://example.com/inbox")).to have_been_made.once
  27. end
  28. end
  29. end