feed_spec.rb 717 B

123456789101112131415161718192021
  1. require 'rails_helper'
  2. RSpec.describe Feed, type: :model do
  3. describe '#get' do
  4. it 'gets statuses with ids in the range' do
  5. account = Fabricate(:account)
  6. Fabricate(:status, account: account, id: 1)
  7. Fabricate(:status, account: account, id: 2)
  8. Fabricate(:status, account: account, id: 3)
  9. Fabricate(:status, account: account, id: 10)
  10. Redis.current.zadd(FeedManager.instance.key(:home, account.id),
  11. [[4, 'deleted'], [3, 'val3'], [2, 'val2'], [1, 'val1']])
  12. feed = Feed.new(:home, account)
  13. results = feed.get(3)
  14. expect(results.map(&:id)).to eq [3, 2]
  15. expect(results.first.attributes.keys).to eq %w(id updated_at)
  16. end
  17. end
  18. end