precompute_feed_service_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PrecomputeFeedService, type: :service do
  4. subject { described_class.new }
  5. describe 'call' do
  6. let(:account) { Fabricate(:account) }
  7. it 'fills a user timeline with statuses' do
  8. account = Fabricate(:account)
  9. status = Fabricate(:status, account: account)
  10. subject.call(account)
  11. expect(redis.zscore(FeedManager.instance.key(:home, account.id), status.id)).to be_within(0.1).of(status.id.to_f)
  12. end
  13. it 'does not raise an error even if it could not find any status' do
  14. account = Fabricate(:account)
  15. expect { subject.call(account) }.to_not raise_error
  16. end
  17. it 'filters statuses' do
  18. account = Fabricate(:account)
  19. muted_account = Fabricate(:account)
  20. Fabricate(:mute, account: account, target_account: muted_account)
  21. reblog = Fabricate(:status, account: muted_account)
  22. Fabricate(:status, account: account, reblog: reblog)
  23. subject.call(account)
  24. expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to be_nil
  25. end
  26. end
  27. end