diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-10-08 16:45:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-08 16:45:40 +0200 |
commit | 45ebdb72ca1678eb30e6087f61bd019c7ea903f4 (patch) | |
tree | 39fa4a3185bf358efa8c954a42b39b927d3b904b /spec/models | |
parent | 678fc4d292664550df554a224b8fd59dcef20d35 (diff) |
Add support for language preferences for trending statuses and links (#18288)
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/preview_card_trend_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/status_trend_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/trends/statuses_spec.rb | 14 |
3 files changed, 15 insertions, 7 deletions
diff --git a/spec/models/preview_card_trend_spec.rb b/spec/models/preview_card_trend_spec.rb new file mode 100644 index 000000000..c7ab6ed14 --- /dev/null +++ b/spec/models/preview_card_trend_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe PreviewCardTrend, type: :model do +end diff --git a/spec/models/status_trend_spec.rb b/spec/models/status_trend_spec.rb new file mode 100644 index 000000000..6b82204a6 --- /dev/null +++ b/spec/models/status_trend_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe StatusTrend, type: :model do +end diff --git a/spec/models/trends/statuses_spec.rb b/spec/models/trends/statuses_spec.rb index 9cc67acbe..5f338a65e 100644 --- a/spec/models/trends/statuses_spec.rb +++ b/spec/models/trends/statuses_spec.rb @@ -9,8 +9,8 @@ RSpec.describe Trends::Statuses do let!(:query) { subject.query } let!(:today) { at_time } - let!(:status1) { Fabricate(:status, text: 'Foo', trendable: true, created_at: today) } - let!(:status2) { Fabricate(:status, text: 'Bar', trendable: true, created_at: today) } + let!(:status1) { Fabricate(:status, text: 'Foo', language: 'en', trendable: true, created_at: today) } + let!(:status2) { Fabricate(:status, text: 'Bar', language: 'en', trendable: true, created_at: today) } before do 15.times { reblog(status1, today) } @@ -69,9 +69,9 @@ RSpec.describe Trends::Statuses do let!(:today) { at_time } let!(:yesterday) { today - 1.day } - let!(:status1) { Fabricate(:status, text: 'Foo', trendable: true, created_at: yesterday) } - let!(:status2) { Fabricate(:status, text: 'Bar', trendable: true, created_at: today) } - let!(:status3) { Fabricate(:status, text: 'Baz', trendable: true, created_at: today) } + let!(:status1) { Fabricate(:status, text: 'Foo', language: 'en', trendable: true, created_at: yesterday) } + let!(:status2) { Fabricate(:status, text: 'Bar', language: 'en', trendable: true, created_at: today) } + let!(:status3) { Fabricate(:status, text: 'Baz', language: 'en', trendable: true, created_at: today) } before do 13.times { reblog(status1, today) } @@ -95,10 +95,10 @@ RSpec.describe Trends::Statuses do it 'decays scores' do subject.refresh(today) - original_score = subject.score(status2.id) + original_score = status2.trend.score expect(original_score).to be_a Float subject.refresh(today + subject.options[:score_halflife]) - decayed_score = subject.score(status2.id) + decayed_score = status2.trend.reload.score expect(decayed_score).to be <= original_score / 2 end end |