Commit 01031763 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '294155-improve-jira-service-find-issue' into 'master'

Restrict JiraService#find_issue options

See merge request gitlab-org/gitlab!53742
parents 8db25775 45b017f9
...@@ -159,7 +159,10 @@ class JiraService < IssueTrackerService ...@@ -159,7 +159,10 @@ class JiraService < IssueTrackerService
# support any events. # support any events.
end end
def find_issue(issue_key, options = {}) def find_issue(issue_key, rendered_fields: false)
options = {}
options = options.merge(expand: 'renderedFields') if rendered_fields
jira_request { client.Issue.find(issue_key, options) } jira_request { client.Issue.find(issue_key, options) }
end end
......
...@@ -66,7 +66,7 @@ module Projects ...@@ -66,7 +66,7 @@ module Projects
def issue_json def issue_json
::Integrations::Jira::IssueDetailSerializer.new ::Integrations::Jira::IssueDetailSerializer.new
.represent(project.jira_service.find_issue(params[:id], { expand: 'renderedFields' }), project: project) .represent(project.jira_service.find_issue(params[:id], rendered_fields: true), project: project)
end end
def finder def finder
......
...@@ -210,7 +210,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do ...@@ -210,7 +210,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do
it 'returns JSON response' do it 'returns JSON response' do
expect_next_found_instance_of(JiraService) do |service| expect_next_found_instance_of(JiraService) do |service|
expect(service).to receive(:find_issue).with('1', { expand: 'renderedFields' }).and_return(jira_issue) expect(service).to receive(:find_issue).with('1', rendered_fields: true).and_return(jira_issue)
end end
expect_next_instance_of(Integrations::Jira::IssueDetailSerializer) do |serializer| expect_next_instance_of(Integrations::Jira::IssueDetailSerializer) do |serializer|
......
...@@ -463,7 +463,7 @@ RSpec.describe JiraService do ...@@ -463,7 +463,7 @@ RSpec.describe JiraService do
let(:issue_url) { "#{url}/rest/api/2/issue/#{issue_key}?expand=renderedFields" } let(:issue_url) { "#{url}/rest/api/2/issue/#{issue_key}?expand=renderedFields" }
it 'calls the Jira API with the options to get the issue' do it 'calls the Jira API with the options to get the issue' do
jira_service.find_issue(issue_key, { expand: 'renderedFields' }) jira_service.find_issue(issue_key, rendered_fields: true)
expect(WebMock).to have_requested(:get, issue_url) expect(WebMock).to have_requested(:get, issue_url)
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