1
0

after_block_service_spec.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. require 'rails_helper'
  2. RSpec.describe AfterBlockService, type: :service do
  3. subject { described_class.new.call(account, target_account) }
  4. let(:account) { Fabricate(:account) }
  5. let(:target_account) { Fabricate(:account) }
  6. let(:status) { Fabricate(:status, account: target_account) }
  7. let(:other_status) { Fabricate(:status, account: target_account) }
  8. let(:other_account_status) { Fabricate(:status) }
  9. let(:other_account_reblog) { Fabricate(:status, reblog_of_id: other_status.id) }
  10. describe 'home timeline' do
  11. let(:home_timeline_key) { FeedManager.instance.key(:home, account.id) }
  12. before do
  13. redis.del(home_timeline_key)
  14. end
  15. it "clears account's statuses" do
  16. FeedManager.instance.push_to_home(account, status)
  17. FeedManager.instance.push_to_home(account, other_account_status)
  18. FeedManager.instance.push_to_home(account, other_account_reblog)
  19. expect { subject }.to change {
  20. redis.zrange(home_timeline_key, 0, -1)
  21. }.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
  22. end
  23. end
  24. describe 'lists' do
  25. let(:list) { Fabricate(:list, account: account) }
  26. let(:list_timeline_key) { FeedManager.instance.key(:list, list.id) }
  27. before do
  28. redis.del(list_timeline_key)
  29. end
  30. it "clears account's statuses" do
  31. FeedManager.instance.push_to_list(list, status)
  32. FeedManager.instance.push_to_list(list, other_account_status)
  33. FeedManager.instance.push_to_list(list, other_account_reblog)
  34. expect { subject }.to change {
  35. redis.zrange(list_timeline_key, 0, -1)
  36. }.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
  37. end
  38. end
  39. end