Commit 45b017f9 authored by Arturo Herrero's avatar Arturo Herrero

Restrict JiraService#find_issue options

This restrict the options and encapsulates the Jira options inside
JiraService class.
parent 67b531f5
......@@ -159,7 +159,10 @@ class JiraService < IssueTrackerService
# support any events.
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) }
end
......
......@@ -66,7 +66,7 @@ module Projects
def issue_json
::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
def finder
......
......@@ -210,7 +210,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do
it 'returns JSON response' do
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
expect_next_instance_of(Integrations::Jira::IssueDetailSerializer) do |serializer|
......
......@@ -463,7 +463,7 @@ RSpec.describe JiraService do
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
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)
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