diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 12:06:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-06 12:06:39 +0300 |
commit | cd15d0e6c32da7f69689c7cff2e90aeda33b8318 (patch) | |
tree | 8343899f0873ab05f3eadca72c5f6e0a653a12ac /spec/graphql/resolvers | |
parent | dd6afb4b4785ed1889defc6d7bb8ef114dd4eb50 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/resolvers')
-rw-r--r-- | spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb b/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb new file mode 100644 index 00000000000..5e7f18636ec --- /dev/null +++ b/spec/graphql/resolvers/error_tracking/sentry_detailed_error_resolver_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Resolvers::ErrorTracking::SentryDetailedErrorResolver do + include GraphqlHelpers + + let_it_be(:project) { create(:project) } + let_it_be(:current_user) { create(:user) } + + let(:issue_details_service) { spy('ErrorTracking::IssueDetailsService') } + + before do + project.add_developer(current_user) + + allow(ErrorTracking::IssueDetailsService) + .to receive(:new) + .and_return issue_details_service + end + + describe '#resolve' do + let(:args) { { id: issue_global_id(1234) } } + it 'fetches the data via the sentry API' do + resolve_error(args) + + expect(issue_details_service).to have_received(:execute) + end + + context 'error matched' do + let(:detailed_error) { build(:detailed_error_tracking_error) } + + before do + allow(issue_details_service).to receive(:execute) + .and_return({ issue: detailed_error }) + end + + it 'resolves to a detailed error' do + expect(resolve_error(args)).to eq detailed_error + end + + it 'assigns the gitlab project' do + expect(resolve_error(args).gitlab_project).to eq project + end + end + + it 'resolves to nil if no match' do + allow(issue_details_service).to receive(:execute) + .and_return({ issue: nil }) + + result = resolve_error(args) + expect(result).to eq nil + end + end + + def resolve_error(args = {}, context = { current_user: current_user }) + resolve(described_class, obj: project, args: args, ctx: context) + end + + def issue_global_id(issue_id) + Gitlab::ErrorTracking::DetailedError.new(id: issue_id).to_global_id.to_s + end +end |