after_block_service_spec.rb 1.8 KB

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