2020-01-23 12:08:38 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-24 15:08:50 +00:00
|
|
|
RSpec.shared_context 'sentry error tracking context feature' do
|
2020-01-23 12:08:38 +00:00
|
|
|
include ReactiveCachingHelpers
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:project_error_tracking_settings) { create(:project_error_tracking_setting, project: project) }
|
|
|
|
let_it_be(:issue_response_body) { fixture_file('sentry/issue_sample_response.json') }
|
2020-04-30 18:09:38 +00:00
|
|
|
let_it_be(:issue_response) { Gitlab::Json.parse(issue_response_body) }
|
2020-01-23 12:08:38 +00:00
|
|
|
let_it_be(:event_response_body) { fixture_file('sentry/issue_latest_event_sample_response.json') }
|
2020-04-30 18:09:38 +00:00
|
|
|
let_it_be(:event_response) { Gitlab::Json.parse(event_response_body) }
|
2021-03-04 15:11:19 +00:00
|
|
|
let(:sentry_api_urls) { ErrorTracking::SentryClient::ApiUrls.new(project_error_tracking_settings.api_url) }
|
2020-01-23 12:08:38 +00:00
|
|
|
let(:issue_id) { issue_response['id'] }
|
2020-02-08 00:08:54 +00:00
|
|
|
let(:issue_seen) { 1.year.ago.utc }
|
2020-02-08 12:09:00 +00:00
|
|
|
let(:formatted_issue_seen) { issue_seen.strftime("%Y-%m-%d %-l:%M:%S%p %Z") }
|
2020-03-01 15:08:18 +00:00
|
|
|
let(:date_received) { 32.days.ago.utc }
|
2020-01-23 12:08:38 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
request_headers = { 'Authorization' => 'Bearer access_token_123', 'Content-Type' => 'application/json' }
|
|
|
|
response_headers = { 'Content-Type' => 'application/json' }
|
2020-02-08 00:08:54 +00:00
|
|
|
|
|
|
|
issue_response['firstSeen'] = issue_seen.iso8601(6)
|
|
|
|
issue_response['lastSeen'] = issue_seen.iso8601(6)
|
|
|
|
event_response['dateReceived'] = date_received.iso8601(6)
|
|
|
|
|
2020-01-23 12:08:38 +00:00
|
|
|
issue_url = sentry_api_urls.issue_url(issue_id).to_s
|
|
|
|
stub_request(:get, issue_url)
|
|
|
|
.with(headers: request_headers)
|
2020-02-08 00:08:54 +00:00
|
|
|
.to_return(status: 200, body: issue_response.to_json, headers: response_headers)
|
2020-01-23 12:08:38 +00:00
|
|
|
event_url = sentry_api_urls.issue_latest_event_url(issue_id).to_s
|
|
|
|
stub_request(:get, event_url)
|
|
|
|
.with(headers: request_headers)
|
2020-02-08 00:08:54 +00:00
|
|
|
.to_return(status: 200, body: event_response.to_json, headers: response_headers)
|
2020-01-23 12:08:38 +00:00
|
|
|
end
|
|
|
|
end
|