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.

48 lines
1.8 KiB

  1. require 'rails_helper'
  2. RSpec.describe RemoveStatusService 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. before do
  9. stub_request(:post, 'http://example.com/push').to_return(status: 200, body: '', headers: {})
  10. stub_request(:post, 'http://example.com/salmon').to_return(status: 200, body: '', headers: {})
  11. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  12. Fabricate(:subscription, account: alice, callback_url: 'http://example.com/push', confirmed: true, expires_at: 30.days.from_now)
  13. jeff.follow!(alice)
  14. hank.follow!(alice)
  15. @status = PostStatusService.new.call(alice, 'Hello @bob@example.com')
  16. subject.call(@status)
  17. end
  18. it 'removes status from author\'s home feed' do
  19. expect(Feed.new(:home, alice).get(10)).to_not include(@status.id)
  20. end
  21. it 'removes status from local follower\'s home feed' do
  22. expect(Feed.new(:home, jeff).get(10)).to_not include(@status.id)
  23. end
  24. it 'sends PuSH update to PuSH subscribers' do
  25. expect(a_request(:post, 'http://example.com/push').with { |req|
  26. req.body.match(TagManager::VERBS[:delete])
  27. }).to have_been_made
  28. end
  29. it 'sends delete activity to followers' do
  30. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.twice
  31. end
  32. it 'sends Salmon slap to previously mentioned users' do
  33. expect(a_request(:post, "http://example.com/salmon").with { |req|
  34. xml = OStatus2::Salmon.new.unpack(req.body)
  35. xml.match(TagManager::VERBS[:delete])
  36. }).to have_been_made.once
  37. end
  38. end