debian-mirror-gitlab/spec/lib/sentry/client/issue_link_spec.rb

66 lines
2.3 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Sentry::Client::IssueLink do
2020-03-13 15:44:24 +05:30
include SentryClientHelpers
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(: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 }
2020-05-24 23:13:21 +05:30
let(:issue_link_sample_response) { Gitlab::Json.parse(fixture_file('sentry/global_integration_link_sample_response.json')) }
2020-03-13 15:44:24 +05:30
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) }
subject { client.create_issue_link(integration_id, sentry_issue_id, issue) }
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', :put
end
context 'when exception is raised' do
let(:sentry_request_url) { sentry_issue_link_url }
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 }
2020-05-24 23:13:21 +05:30
let(:issue_link_sample_response) { Gitlab::Json.parse(fixture_file('sentry/plugin_link_sample_response.json')) }
2020-03-13 15:44:24 +05:30
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