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.

21 lines
768 B

  1. require 'rails_helper'
  2. RSpec.describe Feed, type: :model do
  3. describe '#get' do
  4. it "gets statuses with ids in the range, maintining the order from Redis" 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 = double(zrevrangebyscore: [["val2", 2.0], ["val1", 1.0], ["val3", 3.0], ["deleted", 4.0]])
  11. allow(Redis).to receive(:current).and_return(redis)
  12. feed = Feed.new("type", account)
  13. results = feed.get(3)
  14. expect(results.map(&:id)).to eq [2, 1, 3]
  15. expect(results.first.attributes.keys).to eq ["id", "updated_at"]
  16. end
  17. end
  18. end