2019-01-09 21:04:27 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ErrorTracking::ListIssuesService do
|
2020-01-21 09:08:43 +00:00
|
|
|
include_context 'sentry error tracking context'
|
|
|
|
|
2019-12-02 12:06:45 +00:00
|
|
|
let(:params) { { search_term: 'something', sort: 'last_seen', cursor: 'some-cursor' } }
|
2019-11-19 15:06:24 +00:00
|
|
|
let(:list_sentry_issues_args) do
|
|
|
|
{
|
|
|
|
issue_status: 'unresolved',
|
|
|
|
limit: 20,
|
2019-12-02 12:06:45 +00:00
|
|
|
search_term: 'something',
|
|
|
|
sort: 'last_seen',
|
|
|
|
cursor: 'some-cursor'
|
2019-11-19 15:06:24 +00:00
|
|
|
}
|
|
|
|
end
|
2019-01-09 21:04:27 +00:00
|
|
|
|
2019-11-19 15:06:24 +00:00
|
|
|
subject { described_class.new(project, user, params) }
|
2019-01-09 21:04:27 +00:00
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
context 'with authorized user' do
|
|
|
|
context 'when list_sentry_issues returns issues' do
|
|
|
|
let(:issues) { [:list, :of, :issues] }
|
|
|
|
|
|
|
|
before do
|
|
|
|
expect(error_tracking_setting)
|
2019-11-19 15:06:24 +00:00
|
|
|
.to receive(:list_sentry_issues)
|
|
|
|
.with(list_sentry_issues_args)
|
2019-12-02 12:06:45 +00:00
|
|
|
.and_return(issues: issues, pagination: {})
|
2019-01-09 21:04:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the issues' do
|
2019-12-02 12:06:45 +00:00
|
|
|
expect(result).to eq(status: :success, pagination: {}, issues: issues)
|
2019-01-09 21:04:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-08 21:06:38 +00:00
|
|
|
include_examples 'error tracking service data not ready', :list_sentry_issues
|
|
|
|
include_examples 'error tracking service sentry error handling', :list_sentry_issues
|
|
|
|
include_examples 'error tracking service http status handling', :list_sentry_issues
|
2019-01-09 21:04:27 +00:00
|
|
|
end
|
|
|
|
|
2019-11-08 21:06:38 +00:00
|
|
|
include_examples 'error tracking service unauthorized user'
|
|
|
|
include_examples 'error tracking service disabled'
|
2019-01-09 21:04:27 +00:00
|
|
|
end
|
2019-11-11 00:06:26 +00:00
|
|
|
|
|
|
|
describe '#external_url' do
|
|
|
|
it 'calls the project setting sentry_external_url' do
|
|
|
|
expect(error_tracking_setting).to receive(:sentry_external_url).and_return(sentry_url)
|
|
|
|
|
|
|
|
expect(subject.external_url).to eql sentry_url
|
|
|
|
end
|
|
|
|
end
|
2019-01-09 21:04:27 +00:00
|
|
|
end
|