Commit 23e6ca22 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '60180-jira-service-fix-nil-on-find-call-pderichs' into 'master'

Resolve "JIRA service: NoMethodError: undefined method `find' for nil:NilClass"

Closes #60180

See merge request gitlab-org/gitlab-ce!28206
parents 4c16ce11 db453ffd
...@@ -265,6 +265,7 @@ class JiraService < IssueTrackerService ...@@ -265,6 +265,7 @@ class JiraService < IssueTrackerService
def find_remote_link(issue, url) def find_remote_link(issue, url)
links = jira_request { issue.remotelink.all } links = jira_request { issue.remotelink.all }
return unless links
links.find { |link| link.object["url"] == url } links.find { |link| link.object["url"] == url }
end end
......
---
title: 'Resolved JIRA service: NoMethodError: undefined method ''find'' for nil:NilClass'
merge_request: 28206
author:
type: fixed
...@@ -166,6 +166,13 @@ describe JiraService do ...@@ -166,6 +166,13 @@ describe JiraService do
).once ).once
end end
it 'does not fail if remote_link.all on issue returns nil' do
allow(JIRA::Resource::Remotelink).to receive(:all).and_return(nil)
expect { @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project)) }
.not_to raise_error(NoMethodError)
end
# Check https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links # Check https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links
# for more information # for more information
it 'creates Remote Link reference in JIRA for comment' do it 'creates Remote Link reference in JIRA for comment' do
......
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