blob: 17548e2081d65f03516278d8ba4f2c6ef3432d5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# frozen_string_literal: true
require 'spec_helper'
describe Sentry::Client::Issue do
include SentryClientHelpers
let(:token) { 'test-token' }
let(:client) { Sentry::Client.new(sentry_url, token) }
describe '#issue_details' do
let(:issue_sample_response) do
Gitlab::Utils.deep_indifferent_access(
JSON.parse(fixture_file('sentry/issue_sample_response.json'))
)
end
let(:issue_id) { 503504 }
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0' }
let(:sentry_request_url) { "#{sentry_url}/issues/#{issue_id}/" }
let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: issue_sample_response) }
subject { client.issue_details(issue_id: issue_id) }
it_behaves_like 'calls sentry api'
it 'escapes issue ID' do
allow(CGI).to receive(:escape).and_call_original
subject
expect(CGI).to have_received(:escape).with(issue_id.to_s)
end
context 'error object created from sentry response' do
using RSpec::Parameterized::TableSyntax
where(:error_object, :sentry_response) do
:id | :id
:first_seen | :firstSeen
:last_seen | :lastSeen
:title | :title
:type | :type
:user_count | :userCount
:count | :count
:message | [:metadata, :value]
:culprit | :culprit
:short_id | :shortId
:status | :status
:frequency | [:stats, '24h']
:project_id | [:project, :id]
:project_name | [:project, :name]
:project_slug | [:project, :slug]
:first_release_last_commit | [:firstRelease, :lastCommit]
:last_release_last_commit | [:lastRelease, :lastCommit]
:first_release_short_version | [:firstRelease, :shortVersion]
:last_release_short_version | [:lastRelease, :shortVersion]
end
with_them do
it do
expect(subject.public_send(error_object)).to eq(issue_sample_response.dig(*sentry_response))
end
end
it 'has a correct external URL' do
expect(subject.external_url).to eq('https://sentrytest.gitlab.com/api/0/issues/503504')
end
it 'issue has a correct external base url' do
expect(subject.external_base_url).to eq('https://sentrytest.gitlab.com/api/0')
end
it 'has a correct GitLab issue url' do
expect(subject.gitlab_issue).to eq('https://gitlab.com/gitlab-org/gitlab/issues/1')
end
end
end
end
|