diff options
Diffstat (limited to 'spec/lib/gitlab/tracking_spec.rb')
-rw-r--r-- | spec/lib/gitlab/tracking_spec.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/lib/gitlab/tracking_spec.rb b/spec/lib/gitlab/tracking_spec.rb index ac052bd7a80..4d856205609 100644 --- a/spec/lib/gitlab/tracking_spec.rb +++ b/spec/lib/gitlab/tracking_spec.rb @@ -36,12 +36,12 @@ RSpec.describe Gitlab::Tracking do end describe '.event' do - before do - allow_any_instance_of(Gitlab::Tracking::Destinations::Snowplow).to receive(:event) - allow_any_instance_of(Gitlab::Tracking::Destinations::ProductAnalytics).to receive(:event) - end - shared_examples 'delegates to destination' do |klass| + before do + allow_any_instance_of(Gitlab::Tracking::Destinations::Snowplow).to receive(:event) + allow_any_instance_of(Gitlab::Tracking::Destinations::ProductAnalytics).to receive(:event) + end + it "delegates to #{klass} destination" do other_context = double(:context) @@ -51,7 +51,7 @@ RSpec.describe Gitlab::Tracking do expect(Gitlab::Tracking::StandardContext) .to receive(:new) - .with(project: project, user: user, namespace: namespace) + .with(project: project, user: user, namespace: namespace, extra_key_1: 'extra value 1', extra_key_2: 'extra value 2') .and_call_original expect_any_instance_of(klass).to receive(:event) do |_, category, action, args| @@ -66,21 +66,21 @@ RSpec.describe Gitlab::Tracking do end described_class.event('category', 'action', label: 'label', property: 'property', value: 1.5, - context: [other_context], project: project, user: user, namespace: namespace) + context: [other_context], project: project, user: user, namespace: namespace, + extra_key_1: 'extra value 1', extra_key_2: 'extra value 2') end end - include_examples 'delegates to destination', Gitlab::Tracking::Destinations::Snowplow - include_examples 'delegates to destination', Gitlab::Tracking::Destinations::ProductAnalytics - end + it_behaves_like 'delegates to destination', Gitlab::Tracking::Destinations::Snowplow + it_behaves_like 'delegates to destination', Gitlab::Tracking::Destinations::ProductAnalytics - describe '.self_describing_event' do - it 'delegates to snowplow destination' do - expect_any_instance_of(Gitlab::Tracking::Destinations::Snowplow) - .to receive(:self_describing_event) - .with('iglu:com.gitlab/foo/jsonschema/1-0-0', data: { foo: 'bar' }, context: nil) + it 'tracks errors' do + expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).with( + an_instance_of(ContractError), + snowplow_category: nil, snowplow_action: 'some_action' + ) - described_class.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', data: { foo: 'bar' }) + described_class.event(nil, 'some_action') end end end |