1
0
Fork 0
forked from gitea/nas

Use in_order_of in trends/* classes (#33531)

This commit is contained in:
Matt Jankowski 2025-01-10 04:33:07 -05:00 committed by GitHub
parent e0f6292492
commit 4f6edc7596
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 94 additions and 6 deletions

View file

@ -45,6 +45,31 @@ RSpec.describe Trends::Statuses do
end
end
describe 'Trends::Statuses::Query methods' do
subject { described_class.new.query }
describe '#records' do
context 'with scored cards' do
let!(:higher_score) { Fabricate :status_trend, score: 10, language: 'en' }
let!(:lower_score) { Fabricate :status_trend, score: 1, language: 'es' }
it 'returns higher score first' do
expect(subject.records)
.to eq([higher_score.status, lower_score.status])
end
context 'with preferred locale' do
before { subject.in_locale!('es') }
it 'returns in language order' do
expect(subject.records)
.to eq([lower_score.status, higher_score.status])
end
end
end
end
end
describe '#add' do
let(:status) { Fabricate(:status) }