Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/metrics')
-rw-r--r--spec/models/metrics/dashboard/annotation_spec.rb73
-rw-r--r--spec/models/metrics/users_starred_dashboard_spec.rb39
2 files changed, 0 insertions, 112 deletions
diff --git a/spec/models/metrics/dashboard/annotation_spec.rb b/spec/models/metrics/dashboard/annotation_spec.rb
deleted file mode 100644
index 7c4f392fcdc..00000000000
--- a/spec/models/metrics/dashboard/annotation_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Metrics::Dashboard::Annotation do
- using RSpec::Parameterized::TableSyntax
-
- describe 'validation' do
- it { is_expected.to validate_presence_of(:description) }
- it { is_expected.to validate_presence_of(:dashboard_path) }
- it { is_expected.to validate_presence_of(:starting_at) }
- it { is_expected.to validate_length_of(:dashboard_path).is_at_most(255) }
- it { is_expected.to validate_length_of(:panel_xid).is_at_most(255) }
- it { is_expected.to validate_length_of(:description).is_at_most(255) }
-
- context 'ending_at_after_starting_at' do
- where(:starting_at, :ending_at, :valid?, :message) do
- 2.days.ago.beginning_of_day | 1.day.ago.beginning_of_day | true | nil
- 1.day.ago.beginning_of_day | nil | true | nil
- 1.day.ago.beginning_of_day | 1.day.ago.beginning_of_day | true | nil
- 1.day.ago.beginning_of_day | 2.days.ago.beginning_of_day | false | /Ending at can't be before starting_at time/
- nil | 2.days.ago.beginning_of_day | false | /Starting at can't be blank/ # validation is covered by other method, be we need to assure, that ending_at_after_starting_at will not break with nil as starting_at
- nil | nil | false | /Starting at can't be blank/ # validation is covered by other method, be we need to assure, that ending_at_after_starting_at will not break with nil as starting_at
- end
-
- with_them do
- subject(:annotation) { build(:metrics_dashboard_annotation, starting_at: starting_at, ending_at: ending_at) }
-
- it do
- expect(annotation.valid?).to be(valid?)
- expect(annotation.errors.full_messages).to include(message) if message
- end
- 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
-
- describe '#ending_before' do
- it 'returns annotations only for appointed dashboard' do
- freeze_time do
- twelve_minutes_old_annotation = create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago, ending_at: 12.minutes.ago)
- create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago, ending_at: 11.minutes.ago)
-
- expect(described_class.ending_before(11.minutes.ago)).to match_array [fifteen_minutes_old_annotation, twelve_minutes_old_annotation]
- end
- end
- end
- end
-end
diff --git a/spec/models/metrics/users_starred_dashboard_spec.rb b/spec/models/metrics/users_starred_dashboard_spec.rb
deleted file mode 100644
index c89344c0a1c..00000000000
--- a/spec/models/metrics/users_starred_dashboard_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Metrics::UsersStarredDashboard do
- describe 'associations' do
- it { is_expected.to belong_to(:project).inverse_of(:metrics_users_starred_dashboards) }
- it { is_expected.to belong_to(:user).inverse_of(:metrics_users_starred_dashboards) }
- end
-
- describe 'validation' do
- subject { build(:metrics_users_starred_dashboard) }
-
- it { is_expected.to validate_presence_of(:user_id) }
- it { is_expected.to validate_presence_of(:project_id) }
- it { is_expected.to validate_presence_of(:dashboard_path) }
- it { is_expected.to validate_length_of(:dashboard_path).is_at_most(255) }
- it { is_expected.to validate_uniqueness_of(:dashboard_path).scoped_to(%i[user_id project_id]) }
- end
-
- context 'scopes' do
- let_it_be(:project) { create(:project) }
- let_it_be(:starred_dashboard_a) { create(:metrics_users_starred_dashboard, project: project, dashboard_path: 'path_a') }
- let_it_be(:starred_dashboard_b) { create(:metrics_users_starred_dashboard, project: project, dashboard_path: 'path_b') }
- let_it_be(:starred_dashboard_c) { create(:metrics_users_starred_dashboard, dashboard_path: 'path_b') }
-
- describe '#for_project' do
- it 'selects only starred dashboards belonging to project' do
- expect(described_class.for_project(project)).to contain_exactly starred_dashboard_a, starred_dashboard_b
- end
- end
-
- describe '#for_project_dashboard' do
- it 'selects only starred dashboards belonging to project with given dashboard path' do
- expect(described_class.for_project_dashboard(project, 'path_b')).to contain_exactly starred_dashboard_b
- end
- end
- end
-end