remove_status_service_spec.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. require 'rails_helper'
  2. RSpec.describe RemoveStatusService, type: :service do
  3. subject { RemoveStatusService.new }
  4. let!(:alice) { Fabricate(:account) }
  5. let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://example.com/salmon') }
  6. let!(:jeff) { Fabricate(:account) }
  7. let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  8. let!(:bill) { Fabricate(:account, username: 'bill', protocol: :activitypub, domain: 'example2.com', inbox_url: 'http://example2.com/inbox') }
  9. before do
  10. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  11. stub_request(:post, 'http://example2.com/inbox').to_return(status: 200)
  12. jeff.follow!(alice)
  13. hank.follow!(alice)
  14. @status = PostStatusService.new.call(alice, text: 'Hello @bob@example.com')
  15. Fabricate(:status, account: bill, reblog: @status, uri: 'hoge')
  16. subject.call(@status)
  17. end
  18. it 'removes status from author\'s home feed' do
  19. expect(HomeFeed.new(alice).get(10)).to_not include(@status.id)
  20. end
  21. it 'removes status from local follower\'s home feed' do
  22. expect(HomeFeed.new(jeff).get(10)).to_not include(@status.id)
  23. end
  24. it 'sends delete activity to followers' do
  25. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.twice
  26. end
  27. it 'sends delete activity to rebloggers' do
  28. expect(a_request(:post, 'http://example2.com/inbox')).to have_been_made
  29. end
  30. end