diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-12 03:09:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-12 03:09:44 +0300 |
commit | 88544d284c0a25d45ea51c1817fcab1c7e99afe7 (patch) | |
tree | 7ae1c1fb6982eadb803de5f80e069fac8574e84d /spec/models/analytics | |
parent | 15f6e7bab546b32b7ada8aa2019b06b7bda12c1d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/analytics')
-rw-r--r-- | spec/models/analytics/instance_statistics/measurement_spec.rb | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/spec/models/analytics/instance_statistics/measurement_spec.rb b/spec/models/analytics/instance_statistics/measurement_spec.rb index e95207c23f3..dbb16c5ffbe 100644 --- a/spec/models/analytics/instance_statistics/measurement_spec.rb +++ b/spec/models/analytics/instance_statistics/measurement_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Analytics::InstanceStatistics::Measurement, type: :model do describe 'identifiers enum' do it 'maps to the correct values' do - expect(described_class.identifiers).to eq({ + identifiers = { projects: 1, users: 2, issues: 3, @@ -24,8 +24,11 @@ RSpec.describe Analytics::InstanceStatistics::Measurement, type: :model do pipelines_succeeded: 7, pipelines_failed: 8, pipelines_canceled: 9, - pipelines_skipped: 10 - }.with_indifferent_access) + pipelines_skipped: 10, + billable_users: 11 + } + + expect(described_class.identifiers).to eq(identifiers.with_indifferent_access) end end @@ -75,11 +78,41 @@ RSpec.describe Analytics::InstanceStatistics::Measurement, type: :model do end end - describe '#measurement_identifier_values' do - let(:expected_count) { Analytics::InstanceStatistics::Measurement.identifiers.size } + describe '.identifier_query_mapping' do + subject { described_class.identifier_query_mapping } + + it { is_expected.to be_a Hash } + end + + describe '.identifier_min_max_queries' do + subject { described_class.identifier_min_max_queries } + + it { is_expected.to be_a Hash } + end + + describe '.measurement_identifier_values' do + let(:expected_count) { described_class.identifiers.size } subject { described_class.measurement_identifier_values.count } it { is_expected.to eq(expected_count) } end + + describe '.find_latest_or_fallback' do + subject(:count) { described_class.find_latest_or_fallback(:pipelines_skipped).count } + + context 'with instance statistics' do + let!(:measurement) { create(:instance_statistics_measurement, :pipelines_skipped_count) } + + it 'returns the latest stored measurement' do + expect(count).to eq measurement.count + end + end + + context 'without instance statistics' do + it 'returns the realtime query of the measurement' do + expect(count).to eq 0 + end + end + end end |