logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

remove_status_service_spec.rb (2304B)


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