The code powering m.abunchtell.com https://m.abunchtell.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

43 行
1.8 KiB

  1. require 'rails_helper'
  2. RSpec.describe RemoveStatusService, type: :service 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, text: '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 delete activity to followers' do
  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. expect(a_request(:post, 'http://example2.com/inbox')).to have_been_made
  32. end
  33. end