Add coverage for StatusTrend.allowed method (#39239)

This commit is contained in:
Matt Jankowski 2026-06-02 03:45:08 -04:00 committed by GitHub
parent facb552c9c
commit 78932fe567
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,4 +9,23 @@ RSpec.describe StatusTrend do
it { is_expected.to belong_to(:account).required }
it { is_expected.to belong_to(:status).required }
end
describe 'Scopes' do
describe '.allowed' do
context 'with multiple trends per account' do
let(:account) { Fabricate :account }
let!(:allowed_high_score) { Fabricate :status_trend, allowed: true, score: 10, account: }
before do
Fabricate :status_trend, allowed: false, score: 25
Fabricate :status_trend, allowed: true, score: 2, account:
end
it 'returns allowed records with account grouped max scores' do
expect(described_class.allowed)
.to contain_exactly(eq(allowed_high_score).and(have_attributes(score: 10)))
end
end
end
end
end