diff options
author | Brian Kintz <elmugrat@gmail.com> | 2016-09-01 01:50:27 -0400 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-11-02 13:35:14 +0100 |
commit | 6419fe366a83314258f24d4ee2852a461b590c61 (patch) | |
tree | d087d02bc93809e0bdaeb34c8ab4ee5815ff9174 | |
parent | d7859912b2a4a5d0f8aee63b393080ec03f5bbc2 (diff) | |
download | gitlab-ce-6419fe366a83314258f24d4ee2852a461b590c61.tar.gz |
Use the server's base URL without relative URL part when creating links in JIRA
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | app/models/project_services/jira_service.rb | 2 | ||||
-rw-r--r-- | spec/models/project_services/jira_service_spec.rb | 22 |
3 files changed, 24 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d6ddc580f7e..840640a23e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Please view this file on the master branch, on stable branches it's out of date. - Do not show tooltip for active element !7105 (winniehell) - Escape ref and path for relative links !6050 (winniehell) - Fixed link typo on /help/ui to Alerts section. !6915 (Sam Rose) +- Fix broken issue/merge request links in JIRA comments. !6143 (Brian Kintz) - Fix filtering of milestones with quotes in title (airatshigapov) - Refactor less readable existance checking code from CoffeeScript !6289 (jlogandavison) - Update mail_room and enable sentinel support to Reply By Email (!7101) diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index 5bcf199d468..0a493b7a12b 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -237,7 +237,7 @@ class JiraService < IssueTrackerService end def resource_url(resource) - "#{Settings.gitlab['url'].chomp("/")}#{resource}" + "#{Settings.gitlab.base_url.chomp("/")}#{resource}" end def build_entity_url(entity_name, entity_id) diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index a9f637147d1..a3e9adae4e2 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +include Gitlab::Routing.url_helpers describe JiraService, models: true do describe "Associations" do @@ -66,6 +67,27 @@ describe JiraService, models: true do ).once end + it "references the GitLab commit/merge request" do + @jira_service.execute(merge_request, ExternalIssue.new("JIRA-123", project)) + + expect(WebMock).to have_requested(:post, @comment_url).with( + body: /#{Gitlab.config.gitlab.url}\/#{project.path_with_namespace}\/commit\/#{merge_request.diff_head_sha}/ + ).once + end + + it "references the GitLab commit/merge request (relative URL)" do + stub_config_setting(relative_url_root: '/gitlab') + stub_config_setting(url: Settings.send(:build_gitlab_url)) + + Project.default_url_options[:script_name] = "/gitlab" + + @jira_service.execute(merge_request, ExternalIssue.new("JIRA-123", project)) + + expect(WebMock).to have_requested(:post, @comment_url).with( + body: /#{Gitlab.config.gitlab.url}\/#{project.path_with_namespace}\/commit\/#{merge_request.diff_head_sha}/ + ).once + end + it "calls the api with jira_issue_transition_id" do @jira_service.jira_issue_transition_id = 'this-is-a-custom-id' @jira_service.execute(merge_request, ExternalIssue.new("JIRA-123", project)) |