diff options
Diffstat (limited to 'spec/models/metrics/dashboard/annotation_spec.rb')
-rw-r--r-- | spec/models/metrics/dashboard/annotation_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/metrics/dashboard/annotation_spec.rb b/spec/models/metrics/dashboard/annotation_spec.rb index ed3bef37a7c..f7fd7ded7e6 100644 --- a/spec/models/metrics/dashboard/annotation_spec.rb +++ b/spec/models/metrics/dashboard/annotation_spec.rb @@ -50,4 +50,30 @@ describe Metrics::Dashboard::Annotation do end end end + + describe 'scopes' do + let_it_be(:nine_minutes_old_annotation) { create(:metrics_dashboard_annotation, starting_at: 9.minutes.ago) } + let_it_be(:fifteen_minutes_old_annotation) { create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago) } + let_it_be(:just_created_annotation) { create(:metrics_dashboard_annotation) } + + describe '#after' do + it 'returns only younger annotations' do + expect(described_class.after(12.minutes.ago)).to match_array [nine_minutes_old_annotation, just_created_annotation] + end + end + + describe '#before' do + it 'returns only older annotations' do + expect(described_class.before(5.minutes.ago)).to match_array [fifteen_minutes_old_annotation, nine_minutes_old_annotation] + end + end + + describe '#for_dashboard' do + let!(:other_dashboard_annotation) { create(:metrics_dashboard_annotation, dashboard_path: 'other_dashboard.yml') } + + it 'returns annotations only for appointed dashboard' do + expect(described_class.for_dashboard('other_dashboard.yml')).to match_array [other_dashboard_annotation] + end + end + end end |