Commit 685072f5 authored by Jarka Kadlecova's avatar Jarka Kadlecova

simplify url generation

parent 9a1ded1f
...@@ -256,16 +256,14 @@ class JiraService < IssueTrackerService ...@@ -256,16 +256,14 @@ class JiraService < IssueTrackerService
end end
def build_entity_url(entity_name, entity_id) def build_entity_url(entity_name, entity_id)
resource_url( polymorphic_url(
polymorphic_url( [
[ self.project.namespace.becomes(Namespace),
self.project.namespace.becomes(Namespace), self.project,
self.project, entity_name
entity_name ],
], id: entity_id,
id: entity_id, host: Settings.gitlab.base_url
routing_type: :path
)
) )
end end
end end
---
title: simplify url generation
merge_request:
author: Jarka Kadlecova
...@@ -69,6 +69,7 @@ describe JiraService, models: true do ...@@ -69,6 +69,7 @@ describe JiraService, models: true do
end end
describe "Execute" do describe "Execute" do
let(:custom_base_url) { 'http://custom_url' }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
...@@ -107,10 +108,12 @@ describe JiraService, models: true do ...@@ -107,10 +108,12 @@ describe JiraService, models: true do
end end
it "references the GitLab commit/merge request" do it "references the GitLab commit/merge request" do
@jira_service.execute(merge_request, ExternalIssue.new("JIRA-123", project)) stub_config_setting(base_url: custom_base_url)
stub_config_setting(url: custom_base_url)
@jira_service.execute(merge_request, ExternalIssue.new("JIRA-123", project))
expect(WebMock).to have_requested(:post, @comment_url).with( expect(WebMock).to have_requested(:post, @comment_url).with(
body: /#{Gitlab.config.gitlab.url}\/#{project.path_with_namespace}\/commit\/#{merge_request.diff_head_sha}/ body: /#{custom_base_url}\/#{project.path_with_namespace}\/commit\/#{merge_request.diff_head_sha}/
).once ).once
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