diff options
Diffstat (limited to 'spec/lib/gitlab/utils/usage_data_spec.rb')
-rw-r--r-- | spec/lib/gitlab/utils/usage_data_spec.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/spec/lib/gitlab/utils/usage_data_spec.rb b/spec/lib/gitlab/utils/usage_data_spec.rb index 1d01d5c7e6a..e721b28ac29 100644 --- a/spec/lib/gitlab/utils/usage_data_spec.rb +++ b/spec/lib/gitlab/utils/usage_data_spec.rb @@ -8,8 +8,26 @@ RSpec.describe Gitlab::Utils::UsageData do describe '#add_metric' do let(:metric) { 'UuidMetric'} - it 'computes the metric value for given metric' do - expect(described_class.add_metric(metric)).to eq(Gitlab::CurrentSettings.uuid) + context 'with usage_data_instrumentation feature flag' do + context 'when enabled' do + before do + stub_feature_flags(usage_data_instrumentation: true) + end + + it 'returns -100 value to be overriden' do + expect(described_class.add_metric(metric)).to eq(-100) + end + end + + context 'when disabled' do + before do + stub_feature_flags(usage_data_instrumentation: false) + end + + it 'computes the metric value for given metric' do + expect(described_class.add_metric(metric)).to eq(Gitlab::CurrentSettings.uuid) + end + end end end @@ -52,7 +70,7 @@ RSpec.describe Gitlab::Utils::UsageData do let(:relation) { double(:relation, connection: double(:connection)) } before do - allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) # rubocop: disable Database/MultipleDatabases + allow(relation.connection).to receive(:transaction_open?).and_return(false) end it 'delegates counting to counter class instance' do @@ -104,7 +122,7 @@ RSpec.describe Gitlab::Utils::UsageData do let(:ci_builds_estimated_cardinality) { 2.0809220082170614 } before do - allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) # rubocop: disable Database/MultipleDatabases + allow(model.connection).to receive(:transaction_open?).and_return(false) end context 'different counting parameters' do |