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.

51 lines
1.8 KiB

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