logo

mastofe

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

batched_remove_status_service_spec.rb (2674B)


  1. require 'rails_helper'
  2. RSpec.describe BatchedRemoveStatusService do
  3. subject { BatchedRemoveStatusService.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(:user).account }
  7. let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  8. let(:status1) { PostStatusService.new.call(alice, 'Hello @bob@example.com') }
  9. let(:status2) { PostStatusService.new.call(alice, 'Another status') }
  10. before do
  11. allow(Redis.current).to receive_messages(publish: nil)
  12. stub_request(:post, 'http://example.com/push').to_return(status: 200, body: '', headers: {})
  13. stub_request(:post, 'http://example.com/salmon').to_return(status: 200, body: '', headers: {})
  14. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  15. Fabricate(:subscription, account: alice, callback_url: 'http://example.com/push', confirmed: true, expires_at: 30.days.from_now)
  16. jeff.user.update(current_sign_in_at: Time.now)
  17. jeff.follow!(alice)
  18. hank.follow!(alice)
  19. status1
  20. status2
  21. subject.call([status1, status2])
  22. end
  23. it 'removes statuses from author\'s home feed' do
  24. expect(HomeFeed.new(alice).get(10)).to_not include([status1.id, status2.id])
  25. end
  26. it 'removes statuses from local follower\'s home feed' do
  27. expect(HomeFeed.new(jeff).get(10)).to_not include([status1.id, status2.id])
  28. end
  29. it 'notifies streaming API of followers' do
  30. expect(Redis.current).to have_received(:publish).with("timeline:#{jeff.id}", any_args).at_least(:once)
  31. end
  32. it 'notifies streaming API of author' do
  33. expect(Redis.current).to have_received(:publish).with("timeline:#{alice.id}", any_args).at_least(:once)
  34. end
  35. it 'notifies streaming API of public timeline' do
  36. expect(Redis.current).to have_received(:publish).with('timeline:public', any_args).at_least(:once)
  37. end
  38. it 'sends PuSH update to PuSH subscribers' do
  39. expect(a_request(:post, 'http://example.com/push').with { |req|
  40. matches = req.body.match(OStatus::TagManager::VERBS[:delete])
  41. }).to have_been_made.at_least_once
  42. end
  43. it 'sends Salmon slap to previously mentioned users' do
  44. expect(a_request(:post, "http://example.com/salmon").with { |req|
  45. xml = OStatus2::Salmon.new.unpack(req.body)
  46. xml.match(OStatus::TagManager::VERBS[:delete])
  47. }).to have_been_made.once
  48. end
  49. it 'sends delete activity to followers' do
  50. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.at_least_once
  51. end
  52. end