diff options
Diffstat (limited to 'spec/lib/gitlab/error_tracking')
-rw-r--r-- | spec/lib/gitlab/error_tracking/context_payload_generator_spec.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/lib/gitlab/error_tracking/context_payload_generator_spec.rb b/spec/lib/gitlab/error_tracking/context_payload_generator_spec.rb index 38745fe0cde..932c1b2fb4c 100644 --- a/spec/lib/gitlab/error_tracking/context_payload_generator_spec.rb +++ b/spec/lib/gitlab/error_tracking/context_payload_generator_spec.rb @@ -64,8 +64,11 @@ RSpec.describe Gitlab::ErrorTracking::ContextPayloadGenerator do end context 'when the GITLAB_SENTRY_EXTRA_TAGS env is a JSON hash' do - it 'includes those tags in all events' do + before do stub_env('GITLAB_SENTRY_EXTRA_TAGS', { foo: 'bar', baz: 'quux' }.to_json) + end + + it 'includes those tags in all events' do payload = {} Gitlab::ApplicationContext.with_context(feature_category: 'feature_a') do @@ -87,6 +90,26 @@ RSpec.describe Gitlab::ErrorTracking::ContextPayloadGenerator do generator.generate(exception, extra) end + + context 'with generated tags' do + it 'includes all tags' do + payload = {} + + Gitlab::ApplicationContext.with_context(feature_category: 'feature_a') do + payload = generator.generate(exception, extra, { 'mytag' => '123' }) + end + + expect(payload[:tags]).to eql( + correlation_id: 'cid', + locale: 'en', + program: 'test', + feature_category: 'feature_a', + 'foo' => 'bar', + 'baz' => 'quux', + 'mytag' => '123' + ) + end + end end context 'when the GITLAB_SENTRY_EXTRA_TAGS env is not a JSON hash' do |