Commit 4a1898a6 authored by Tom Quirk's avatar Tom Quirk

Add gitlab_web_url to jira issue entity

parent 92757043
......@@ -3,6 +3,8 @@
module Integrations
module Jira
class IssueEntity < Grape::Entity
include RequestAwareEntity
expose :project_id do |_jira_issue, options|
options[:project].id
end
......@@ -61,6 +63,14 @@ module Integrations
"#{base_web_url(jira_issue)}/browse/#{jira_issue.key}"
end
expose :gitlab_web_url do |jira_issue|
if ::Feature.enabled?(:jira_issues_show_integration, options[:project], default_enabled: :yaml)
project_integrations_jira_issue_path(options[:project], jira_issue.key)
else
nil
end
end
expose :references do |jira_issue|
{
relative: jira_issue.key
......
......@@ -76,6 +76,7 @@ RSpec.describe Integrations::Jira::IssueEntity do
it 'returns URLs including context path' do
expect(subject[:author]).to include(web_url: 'http://jira.com/jira-sub-path/secure/ViewProfile.jspa?name=reporter@reporter.com')
expect(subject[:web_url]).to eq('http://jira.com/jira-sub-path/browse/GL-5')
expect(subject[:gitlab_web_url]).to eq(Gitlab::Routing.url_helpers.project_integrations_jira_issue_path(project, 'GL-5'))
end
end
end
......@@ -109,4 +110,14 @@ RSpec.describe Integrations::Jira::IssueEntity do
expect(subject).to include(labels: [])
end
end
context 'feature flag "jira_issues_show_integration" is disabled' do
before do
stub_feature_flags(jira_issues_show_integration: false)
end
it 'sets `gitlab_web_url` to nil' do
expect(subject[:gitlab_web_url]).to eq(nil)
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