diff options
Diffstat (limited to 'spec/lib/gitlab/tracking_spec.rb')
-rw-r--r-- | spec/lib/gitlab/tracking_spec.rb | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/spec/lib/gitlab/tracking_spec.rb b/spec/lib/gitlab/tracking_spec.rb index dd62c832f6f..028c985f3b3 100644 --- a/spec/lib/gitlab/tracking_spec.rb +++ b/spec/lib/gitlab/tracking_spec.rb @@ -90,15 +90,6 @@ RSpec.describe Gitlab::Tracking do it_behaves_like 'delegates to SnowplowMicro destination with proper options' end - - context "enabled with env variable" do - before do - allow(Gitlab.config).to receive(:snowplow_micro).and_raise(Settingslogic::MissingSetting) - stub_env('SNOWPLOW_MICRO_ENABLE', '1') - end - - it_behaves_like 'delegates to SnowplowMicro destination with proper options' - end end it 'when feature flag is disabled' do @@ -149,7 +140,6 @@ RSpec.describe Gitlab::Tracking do context 'when destination is Snowplow' do before do - stub_env('SNOWPLOW_MICRO_ENABLE', '0') allow(Rails.env).to receive(:development?).and_return(true) end @@ -158,7 +148,6 @@ RSpec.describe Gitlab::Tracking do context 'when destination is SnowplowMicro' do before do - stub_env('SNOWPLOW_MICRO_ENABLE', '1') allow(Rails.env).to receive(:development?).and_return(true) end @@ -181,7 +170,7 @@ RSpec.describe Gitlab::Tracking do let_it_be(:definition_action) { 'definition_action' } let_it_be(:definition_category) { 'definition_category' } let_it_be(:label_description) { 'definition label description' } - let_it_be(:test_definition) {{ 'category': definition_category, 'action': definition_action }} + let_it_be(:test_definition) { { 'category': definition_category, 'action': definition_action } } before do allow_next_instance_of(described_class) do |instance| @@ -212,4 +201,28 @@ RSpec.describe Gitlab::Tracking do project: project, user: user, namespace: namespace, extra_key_1: 'extra value 1') end end + + describe 'snowplow_micro_enabled?' do + before do + allow(Rails.env).to receive(:development?).and_return(true) + end + + it 'returns true when snowplow_micro is enabled' do + stub_config(snowplow_micro: { enabled: true }) + + expect(described_class).to be_snowplow_micro_enabled + end + + it 'returns false when snowplow_micro is disabled' do + stub_config(snowplow_micro: { enabled: false }) + + expect(described_class).not_to be_snowplow_micro_enabled + end + + it 'returns false when snowplow_micro is not configured' do + allow(Gitlab.config).to receive(:snowplow_micro).and_raise(Settingslogic::MissingSetting) + + expect(described_class).not_to be_snowplow_micro_enabled + end + end end |