summaryrefslogtreecommitdiff
path: root/spec/lib/sentry/client
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/sentry/client')
-rw-r--r--spec/lib/sentry/client/issue_link_spec.rb38
-rw-r--r--spec/lib/sentry/client/issue_spec.rb4
2 files changed, 33 insertions, 9 deletions
diff --git a/spec/lib/sentry/client/issue_link_spec.rb b/spec/lib/sentry/client/issue_link_spec.rb
index 35a69be6de5..3434e93365e 100644
--- a/spec/lib/sentry/client/issue_link_spec.rb
+++ b/spec/lib/sentry/client/issue_link_spec.rb
@@ -5,18 +5,18 @@ require 'spec_helper'
describe Sentry::Client::IssueLink do
include SentryClientHelpers
- let(:error_tracking_setting) { create(:project_error_tracking_setting, api_url: sentry_url) }
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
- let(:client) { error_tracking_setting.sentry_client }
+ let_it_be(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
+ let_it_be(:error_tracking_setting) { create(:project_error_tracking_setting, api_url: sentry_url) }
+ let_it_be(:issue) { create(:issue, project: error_tracking_setting.project) }
- let(:issue_link_sample_response) { JSON.parse(fixture_file('sentry/issue_link_sample_response.json')) }
+ let(:client) { error_tracking_setting.sentry_client }
+ let(:sentry_issue_id) { 11111111 }
describe '#create_issue_link' do
+ let(:sentry_issue_link_url) { "https://sentrytest.gitlab.com/api/0/groups/#{sentry_issue_id}/integrations/#{integration_id}/" }
let(:integration_id) { 44444 }
- let(:sentry_issue_id) { 11111111 }
- let(:issue) { create(:issue, project: error_tracking_setting.project) }
- let(:sentry_issue_link_url) { "https://sentrytest.gitlab.com/api/0/groups/#{sentry_issue_id}/integrations/#{integration_id}/" }
+ let(:issue_link_sample_response) { JSON.parse(fixture_file('sentry/global_integration_link_sample_response.json')) }
let(:sentry_api_response) { issue_link_sample_response }
let!(:sentry_api_request) { stub_sentry_request(sentry_issue_link_url, :put, body: sentry_api_response, status: 201) }
@@ -37,5 +37,29 @@ describe Sentry::Client::IssueLink do
it_behaves_like 'maps Sentry exceptions', :put
end
+
+ context 'when integration_id is not provided' do
+ let(:sentry_issue_link_url) { "https://sentrytest.gitlab.com/api/0/issues/#{sentry_issue_id}/plugins/gitlab/link/" }
+ let(:integration_id) { nil }
+
+ let(:issue_link_sample_response) { JSON.parse(fixture_file('sentry/plugin_link_sample_response.json')) }
+ let!(:sentry_api_request) { stub_sentry_request(sentry_issue_link_url, :post, body: sentry_api_response) }
+
+ it_behaves_like 'calls sentry api'
+
+ it { is_expected.to be_present }
+
+ context 'redirects' do
+ let(:sentry_api_url) { sentry_issue_link_url }
+
+ it_behaves_like 'no Sentry redirects', :post
+ end
+
+ context 'when exception is raised' do
+ let(:sentry_request_url) { sentry_issue_link_url }
+
+ it_behaves_like 'maps Sentry exceptions', :post
+ end
+ end
end
end
diff --git a/spec/lib/sentry/client/issue_spec.rb b/spec/lib/sentry/client/issue_spec.rb
index 2762c5b5cb9..061ebcfdc06 100644
--- a/spec/lib/sentry/client/issue_spec.rb
+++ b/spec/lib/sentry/client/issue_spec.rb
@@ -8,7 +8,7 @@ describe Sentry::Client::Issue do
let(:token) { 'test-token' }
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0' }
let(:client) { Sentry::Client.new(sentry_url, token) }
- let(:issue_id) { 11 }
+ let(:issue_id) { 503504 }
describe '#list_issues' do
shared_examples 'issues have correct return type' do |klass|
@@ -243,7 +243,7 @@ describe Sentry::Client::Issue do
end
it 'has a correct external URL' do
- expect(subject.external_url).to eq('https://sentrytest.gitlab.com/api/0/issues/11')
+ expect(subject.external_url).to eq('https://sentrytest.gitlab.com/api/0/issues/503504')
end
it 'issue has a correct external base url' do