闭社主体 forked from https://github.com/tootsuite/mastodon
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.

39 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PrecomputeFeedService do
  4. subject { PrecomputeFeedService.new }
  5. describe 'call' do
  6. let(:account) { Fabricate(:account) }
  7. it 'fills a user timeline with statuses' do
  8. account = Fabricate(:account)
  9. followed_account = Fabricate(:account)
  10. Fabricate(:follow, account: account, target_account: followed_account)
  11. reblog = Fabricate(:status, account: followed_account)
  12. status = Fabricate(:status, account: account, reblog: reblog)
  13. subject.call(account)
  14. expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq status.id
  15. end
  16. it 'does not raise an error even if it could not find any status' do
  17. account = Fabricate(:account)
  18. subject.call(account)
  19. end
  20. it 'filters statuses' do
  21. account = Fabricate(:account)
  22. muted_account = Fabricate(:account)
  23. Fabricate(:mute, account: account, target_account: muted_account)
  24. reblog = Fabricate(:status, account: muted_account)
  25. status = Fabricate(:status, account: account, reblog: reblog)
  26. subject.call(account)
  27. expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq nil
  28. end
  29. end
  30. end