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.

49 lines
1.8 KiB

  1. require 'rails_helper'
  2. RSpec.describe RemoveStatusService, type: :service do
  3. subject { RemoveStatusService.new }
  4. let!(:alice) { Fabricate(:account, user: Fabricate(:user)) }
  5. let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
  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. FavouriteService.new.call(jeff, @status)
  16. Fabricate(:status, account: bill, reblog: @status, uri: 'hoge')
  17. end
  18. it 'removes status from author\'s home feed' do
  19. subject.call(@status)
  20. expect(HomeFeed.new(alice).get(10)).to_not include(@status.id)
  21. end
  22. it 'removes status from local follower\'s home feed' do
  23. subject.call(@status)
  24. expect(HomeFeed.new(jeff).get(10)).to_not include(@status.id)
  25. end
  26. it 'sends delete activity to followers' do
  27. subject.call(@status)
  28. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.twice
  29. end
  30. it 'sends delete activity to rebloggers' do
  31. subject.call(@status)
  32. expect(a_request(:post, 'http://example2.com/inbox')).to have_been_made
  33. end
  34. it 'remove status from notifications' do
  35. expect { subject.call(@status) }.to change {
  36. Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count
  37. }.from(1).to(0)
  38. end
  39. end