diff options
Diffstat (limited to 'spec/lib')
5 files changed, 44 insertions, 11 deletions
diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/edition_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/edition_metric_spec.rb new file mode 100644 index 00000000000..2e23b9f5a15 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/edition_metric_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::EditionMetric, feature_category: :service_ping do + before do + allow(Gitlab).to receive(:ee?).and_return(false) + end + + let(:expected_value) { 'CE' } + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all' } +end diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/installation_type_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/installation_type_metric_spec.rb new file mode 100644 index 00000000000..7b59536e7d2 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/installation_type_metric_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::InstallationTypeMetric, feature_category: :service_ping do + context 'when Rails.env is production' do + before do + allow(Rails).to receive_message_chain(:env, :production?).and_return(true) + end + + let(:expected_value) { Gitlab::INSTALLATION_TYPE } + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all' } + end + + context 'with Rails.env is not production' do + let(:expected_value) { 'gitlab-development-kit' } + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all' } + end +end diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/version_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/version_metric_spec.rb new file mode 100644 index 00000000000..1f93a9632d0 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/version_metric_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::VersionMetric, feature_category: :service_ping do + let(:expected_value) { Gitlab::VERSION } + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'database' } +end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index e88c89c74dc..4544cb2eb26 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -665,10 +665,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic subject { described_class.license_usage_data } it 'gathers license data' do - expect(subject[:uuid]).to eq(Gitlab::CurrentSettings.uuid) - expect(subject[:version]).to eq(Gitlab::VERSION) - expect(subject[:installation_type]).to eq('gitlab-development-kit') - expect(subject[:active_user_count]).to eq(User.active.size) expect(subject[:recorded_at]).to be_a(Time) end end diff --git a/spec/lib/service_ping/build_payload_spec.rb b/spec/lib/service_ping/build_payload_spec.rb index 6c37168f5a0..6699310681a 100644 --- a/spec/lib/service_ping/build_payload_spec.rb +++ b/spec/lib/service_ping/build_payload_spec.rb @@ -6,13 +6,7 @@ RSpec.describe ServicePing::BuildPayload, feature_category: :service_ping do describe '#execute', :without_license do subject(:service_ping_payload) { described_class.new.execute } - include_context 'stubbed service ping metrics definitions' do - let(:subscription_metrics) do - [ - metric_attributes('active_user_count', "subscription") - ] - end - end + include_context 'stubbed service ping metrics definitions' it_behaves_like 'complete service ping payload' end |