diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/lib/gitlab/tracking/standard_context_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/lib/gitlab/tracking/standard_context_spec.rb')
-rw-r--r-- | spec/lib/gitlab/tracking/standard_context_spec.rb | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/spec/lib/gitlab/tracking/standard_context_spec.rb b/spec/lib/gitlab/tracking/standard_context_spec.rb index acf7aeb303a..7a0a4f0cc46 100644 --- a/spec/lib/gitlab/tracking/standard_context_spec.rb +++ b/spec/lib/gitlab/tracking/standard_context_spec.rb @@ -9,47 +9,48 @@ RSpec.describe Gitlab::Tracking::StandardContext do let(:snowplow_context) { subject.to_context } describe '#to_context' do - context 'with no arguments' do - it 'creates a Snowplow context with no data' do - snowplow_context.to_json[:data].each do |_, v| - expect(v).to be_nil + context 'environment' do + shared_examples 'contains environment' do |expected_environment| + it 'contains environment' do + expect(snowplow_context.to_json.dig(:data, :environment)).to eq(expected_environment) end end - end - context 'with extra data' do - subject { described_class.new(foo: 'bar') } - - it 'creates a Snowplow context with the given data' do - expect(snowplow_context.to_json.dig(:data, :foo)).to eq('bar') + context 'development or test' do + include_examples 'contains environment', 'development' end - end - context 'with namespace' do - subject { described_class.new(namespace: namespace) } + context 'staging' do + before do + allow(Gitlab).to receive(:staging?).and_return(true) + end - it 'creates a Snowplow context using the given data' do - expect(snowplow_context.to_json.dig(:data, :namespace_id)).to eq(namespace.id) - expect(snowplow_context.to_json.dig(:data, :project_id)).to be_nil + include_examples 'contains environment', 'staging' end - end - context 'with project' do - subject { described_class.new(project: project) } + context 'production' do + before do + allow(Gitlab).to receive(:com_and_canary?).and_return(true) + end - it 'creates a Snowplow context using the given data' do - expect(snowplow_context.to_json.dig(:data, :namespace_id)).to eq(project.namespace.id) - expect(snowplow_context.to_json.dig(:data, :project_id)).to eq(project.id) + include_examples 'contains environment', 'production' end end - context 'with project and namespace' do - subject { described_class.new(namespace: namespace, project: project) } + it 'contains source' do + expect(snowplow_context.to_json.dig(:data, :source)).to eq(described_class::GITLAB_RAILS_SOURCE) + end + + context 'with extra data' do + subject { described_class.new(foo: 'bar') } - it 'creates a Snowplow context using the given data' do - expect(snowplow_context.to_json.dig(:data, :namespace_id)).to eq(namespace.id) - expect(snowplow_context.to_json.dig(:data, :project_id)).to eq(project.id) + it 'creates a Snowplow context with the given data' do + expect(snowplow_context.to_json.dig(:data, :foo)).to eq('bar') end end + + it 'does not contain any ids' do + expect(snowplow_context.to_json[:data].keys).not_to include(:user_id, :project_id, :namespace_id) + end end end |