Reduce factory data created in spec/models/trends/statuses spec (#25410)

pull/2251/head
Matt Jankowski 2023-06-14 03:57:06 -04:00 committed by GitHub
parent 31d5bc89d1
commit ae9f5379d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 10 deletions

View File

@ -15,8 +15,8 @@ RSpec.describe Trends::Statuses do
let!(:status2) { Fabricate(:status, text: 'Bar', language: 'en', trendable: true, created_at: today) }
before do
15.times { reblog(status1, today) }
12.times { reblog(status2, today) }
default_threshold_value.times { reblog(status1, today) }
default_threshold_value.times { reblog(status2, today) }
subject.refresh(today)
end
@ -76,9 +76,9 @@ RSpec.describe Trends::Statuses do
let!(:status3) { Fabricate(:status, text: 'Baz', language: 'en', trendable: true, created_at: today) }
before do
13.times { reblog(status1, today) }
13.times { reblog(status2, today) }
4.times { reblog(status3, today) }
default_threshold_value.times { reblog(status1, today) }
default_threshold_value.times { reblog(status2, today) }
(default_threshold_value - 1).times { reblog(status3, today) }
end
context 'when status trends are refreshed' do
@ -86,12 +86,11 @@ RSpec.describe Trends::Statuses do
subject.refresh(today)
end
it 'calculates and re-calculates scores' do
expect(subject.query.limit(10).to_a).to eq [status2, status1]
end
it 'returns correct statuses from query' do
results = subject.query.limit(10).to_a
it 'omits statuses below threshold' do
expect(subject.query.limit(10).to_a).to_not include(status3)
expect(results).to eq [status2, status1]
expect(results).to_not include(status3)
end
end
@ -109,4 +108,8 @@ RSpec.describe Trends::Statuses do
reblog = Fabricate(:status, reblog: status, created_at: at_time)
subject.add(status, reblog.account_id, at_time)
end
def default_threshold_value
described_class.default_options[:threshold]
end
end