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

This commit is contained in:
Patrick Derichs 2019-05-10 13:33:44 +00:00 committed by Rémy Coutable
parent 4c16ce1184
commit db453ffdbd
3 changed files with 13 additions and 0 deletions

View File

@ -265,6 +265,7 @@ class JiraService < IssueTrackerService
def find_remote_link(issue, url)
links = jira_request { issue.remotelink.all }
return unless links
links.find { |link| link.object["url"] == url }
end

View File

@ -0,0 +1,5 @@
---
title: 'Resolved JIRA service: NoMethodError: undefined method ''find'' for nil:NilClass'
merge_request: 28206
author:
type: fixed

View File

@ -166,6 +166,13 @@ describe JiraService do
).once
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
# for more information
it 'creates Remote Link reference in JIRA for comment' do