Commit dc00d719 authored by charlie ablett's avatar charlie ablett

Merge branch 'pl-spec-sentry-errors-request' into 'master'

Unquarantine spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb again

See merge request gitlab-org/gitlab!69288
parents b2c45ffd f6840649
......@@ -866,7 +866,6 @@ RSpec/AnyInstanceOf:
- 'spec/requests/api/ci/runner/runners_verify_post_spec.rb'
- 'spec/requests/api/graphql/gitlab_schema_spec.rb'
- 'spec/requests/api/graphql/project/error_tracking/sentry_detailed_error_request_spec.rb'
- 'spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb'
- 'spec/requests/api/graphql_spec.rb'
- 'spec/requests/api/helpers_spec.rb'
- 'spec/requests/api/internal/base_spec.rb'
......
......@@ -3,6 +3,7 @@ require 'spec_helper'
RSpec.describe 'sentry errors requests' do
include GraphqlHelpers
let_it_be(:project) { create(:project, :repository) }
let_it_be(:project_setting) { create(:project_error_tracking_setting, project: project) }
let_it_be(:current_user) { project.owner }
......@@ -30,7 +31,7 @@ RSpec.describe 'sentry errors requests' do
let(:error_data) { graphql_data.dig('project', 'sentryErrors', 'detailedError') }
it 'returns a successful response', :aggregate_failures, :quarantine do
it 'returns a successful response', :aggregate_failures do
post_graphql(query, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
......@@ -48,11 +49,9 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'reactive cache returns data' do
context 'when reactive cache returns data' do
before do
allow_any_instance_of(ErrorTracking::ProjectErrorTrackingSetting)
.to receive(:issue_details)
.and_return(issue: sentry_detailed_error)
stub_setting_for(:issue_details, issue: sentry_detailed_error)
post_graphql(query, current_user: current_user)
end
......@@ -72,7 +71,7 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'user does not have permission' do
context 'when user does not have permission' do
let(:current_user) { create(:user) }
it 'is expected to return an empty error' do
......@@ -81,11 +80,9 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'sentry api returns an error' do
context 'when sentry api returns an error' do
before do
expect_any_instance_of(ErrorTracking::ProjectErrorTrackingSetting)
.to receive(:issue_details)
.and_return(error: 'error message')
stub_setting_for(:issue_details, error: 'error message')
post_graphql(query, current_user: current_user)
end
......@@ -140,11 +137,11 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'reactive cache returns data' do
context 'when reactive cache returns data' do
before do
expect_any_instance_of(ErrorTracking::ProjectErrorTrackingSetting)
.to receive(:list_sentry_issues)
.and_return(issues: [sentry_error], pagination: pagination)
stub_setting_for(:list_sentry_issues,
issues: [sentry_error],
pagination: pagination)
post_graphql(query, current_user: current_user)
end
......@@ -177,11 +174,9 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'sentry api itself errors out' do
context 'when sentry api itself errors out' do
before do
expect_any_instance_of(ErrorTracking::ProjectErrorTrackingSetting)
.to receive(:list_sentry_issues)
.and_return(error: 'error message')
stub_setting_for(:list_sentry_issues, error: 'error message')
post_graphql(query, current_user: current_user)
end
......@@ -223,18 +218,16 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'reactive cache returns data' do
context 'when reactive cache returns data' do
before do
allow_any_instance_of(ErrorTracking::ProjectErrorTrackingSetting)
.to receive(:issue_latest_event)
.and_return(latest_event: sentry_stack_trace)
stub_setting_for(:issue_latest_event, latest_event: sentry_stack_trace)
post_graphql(query, current_user: current_user)
end
it_behaves_like 'setting stack trace error'
context 'user does not have permission' do
context 'when user does not have permission' do
let(:current_user) { create(:user) }
it 'is expected to return an empty error' do
......@@ -243,11 +236,9 @@ RSpec.describe 'sentry errors requests' do
end
end
context 'sentry api returns an error' do
context 'when sentry api returns an error' do
before do
expect_any_instance_of(ErrorTracking::ProjectErrorTrackingSetting)
.to receive(:issue_latest_event)
.and_return(error: 'error message')
stub_setting_for(:issue_latest_event, error: 'error message')
post_graphql(query, current_user: current_user)
end
......@@ -257,4 +248,12 @@ RSpec.describe 'sentry errors requests' do
end
end
end
private
def stub_setting_for(method, **return_value)
allow_next_found_instance_of(ErrorTracking::ProjectErrorTrackingSetting) do |setting|
allow(setting).to receive(method).and_return(**return_value)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment