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.

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