Commit 6bde5f57 authored by Alan (Maciej) Paruszewski's avatar Alan (Maciej) Paruszewski Committed by Douglas Barbosa Alexandre

Improve response from Jira issue creation from vulnerability

This change fixes problem with response from GraphQL mutation that
creates issue in Jira.
parent 2c4280cf
...@@ -7,8 +7,6 @@ module Resolvers ...@@ -7,8 +7,6 @@ module Resolvers
type Types::ExternalIssueType, null: true type Types::ExternalIssueType, null: true
def resolve def resolve
return serialize_external_issue(object.external_issue, object.external_type) if object.external_issue.present?
BatchLoader::GraphQL.for(object.external_issue_key).batch(key: object.external_type) do |external_issue_keys, loader, args| BatchLoader::GraphQL.for(object.external_issue_key).batch(key: object.external_type) do |external_issue_keys, loader, args|
case args[:key] case args[:key]
when 'jira' when 'jira'
......
...@@ -18,7 +18,5 @@ module Vulnerabilities ...@@ -18,7 +18,5 @@ module Vulnerabilities
message: N_('already has a "created" issue link') message: N_('already has a "created" issue link')
}, },
if: :created? if: :created?
attr_accessor :external_issue
end end
end end
...@@ -21,7 +21,6 @@ module VulnerabilityExternalIssueLinks ...@@ -21,7 +21,6 @@ module VulnerabilityExternalIssueLinks
error(external_issue.errors.values) error(external_issue.errors.values)
else else
if external_issue_link.update(external_issue_key: external_issue.id) if external_issue_link.update(external_issue_key: external_issue.id)
external_issue_link.external_issue = external_issue
success success
else else
error(external_issue_link.errors.full_messages) error(external_issue_link.errors.full_messages)
......
---
title: Improve response from Jira issue creation from vulnerability
merge_request: 50150
author:
type: fixed
...@@ -98,10 +98,10 @@ RSpec.describe 'Creating an External Issue Link' do ...@@ -98,10 +98,10 @@ RSpec.describe 'Creating an External Issue Link' do
context 'and saving external issue link succeeds' do context 'and saving external issue link succeeds' do
let(:external_issue_id) { '10000' } let(:external_issue_id) { '10000' }
it 'creates the external issue link', :aggregate_failures do it 'creates the external issue link and returns nil for external issue to be fetched using query', :aggregate_failures do
expect { post_graphql_mutation(mutation, current_user: current_user) }.to change(Vulnerabilities::ExternalIssueLink, :count).by(1) expect { post_graphql_mutation(mutation, current_user: current_user) }.to change(Vulnerabilities::ExternalIssueLink, :count).by(1)
expect(mutation_response['errors']).to be_empty expect(mutation_response['errors']).to be_empty
expect(mutation_response.dig('externalIssueLink', 'externalIssue', 'relativeReference')).to eq('GV-5') expect(mutation_response.dig('externalIssueLink', 'externalIssue')).to be_nil
end 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