Commit 09a03bae authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Refactor ErrorTracking test

parent 35dd5bb3
...@@ -8,16 +8,18 @@ RSpec.describe Gitlab::ErrorTracking do ...@@ -8,16 +8,18 @@ RSpec.describe Gitlab::ErrorTracking do
let(:exception) { RuntimeError.new('boom') } let(:exception) { RuntimeError.new('boom') }
let(:issue_url) { 'http://gitlab.com/gitlab-org/gitlab-foss/issues/1' } let(:issue_url) { 'http://gitlab.com/gitlab-org/gitlab-foss/issues/1' }
let(:user) { create(:user) }
let(:sentry_payload) do let(:sentry_payload) do
{ {
tags: { tags: {
program: 'test', program: 'test',
locale: 'en', locale: 'en',
feature_category: nil, feature_category: 'feature_a',
correlation_id: 'cid' correlation_id: 'cid'
}, },
user: { user: {
username: nil username: user.username
}, },
extra: { extra: {
some_other_info: 'info', some_other_info: 'info',
...@@ -32,9 +34,9 @@ RSpec.describe Gitlab::ErrorTracking do ...@@ -32,9 +34,9 @@ RSpec.describe Gitlab::ErrorTracking do
'exception.message' => 'boom', 'exception.message' => 'boom',
'tags.program' => 'test', 'tags.program' => 'test',
'tags.locale' => 'en', 'tags.locale' => 'en',
'tags.feature_category' => nil, 'tags.feature_category' => 'feature_a',
'tags.correlation_id' => 'cid', 'tags.correlation_id' => 'cid',
'user.username' => nil, 'user.username' => user.username,
'extra.some_other_info' => 'info', 'extra.some_other_info' => 'info',
'extra.issue_url' => 'http://gitlab.com/gitlab-org/gitlab-foss/issues/1' 'extra.issue_url' => 'http://gitlab.com/gitlab-org/gitlab-foss/issues/1'
} }
...@@ -52,6 +54,12 @@ RSpec.describe Gitlab::ErrorTracking do ...@@ -52,6 +54,12 @@ RSpec.describe Gitlab::ErrorTracking do
end end
end end
around do |example|
Gitlab::ApplicationContext.with_context(user: user, feature_category: 'feature_a') do
example.run
end
end
describe '.track_and_raise_for_dev_exception' do describe '.track_and_raise_for_dev_exception' do
context 'when exceptions for dev should be raised' do context 'when exceptions for dev should be raised' do
before do before do
......
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