Commit f53b3166 authored by Luke Bennett's avatar Luke Bennett Committed by Mayra Cabrera

Disable tracking_attrs in development env

Also disable in test env.
parent 68a838d5
...@@ -6,7 +6,7 @@ module EE ...@@ -6,7 +6,7 @@ module EE
override :tracking_attrs override :tracking_attrs
def tracking_attrs(label, event, property) def tracking_attrs(label, event, property)
return {} unless snowplow_enabled? return {} unless tracking_enabled?
{ {
data: { data: {
...@@ -19,7 +19,8 @@ module EE ...@@ -19,7 +19,8 @@ module EE
private private
def snowplow_enabled? def tracking_enabled?
Rails.env.production? &&
::Gitlab::CurrentSettings.snowplow_enabled? ::Gitlab::CurrentSettings.snowplow_enabled?
end end
end end
......
...@@ -4,16 +4,32 @@ require 'spec_helper' ...@@ -4,16 +4,32 @@ require 'spec_helper'
describe EE::TrackingHelper do describe EE::TrackingHelper do
describe '#tracking_attrs' do describe '#tracking_attrs' do
it 'returns a hash of snowplow data attrs if snowplow is enabled' do using RSpec::Parameterized::TableSyntax
stub_application_setting(snowplow_enabled: true)
expect(helper.tracking_attrs('a', 'b', 'c')).to eq(data: { track_label: 'a', track_event: 'b', track_property: 'c' }) let(:input) { %w(a b c) }
let(:results) do
{
no_data: {},
with_data: { data: { track_label: 'a', track_event: 'b', track_property: 'c' } }
}
end end
it 'returns an empty hash if snowplow is disabled' do where(:snowplow_enabled, :environment, :result) do
stub_application_setting(snowplow_enabled: false) true | 'production' | :with_data
false | 'production' | :no_data
true | 'development' | :no_data
false | 'development' | :no_data
true | 'test' | :no_data
false | 'test' | :no_data
end
with_them do
it 'returns a hash' do
stub_application_setting(snowplow_enabled: snowplow_enabled)
allow(Rails).to receive(:env).and_return(environment.inquiry)
expect(helper.tracking_attrs('a', 'b', 'c')).to eq({}) expect(helper.tracking_attrs(*input)).to eq(results[result])
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment