summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBrian Kintz <elmugrat@gmail.com>2016-09-01 01:50:27 -0400
committerRémy Coutable <remy@rymai.me>2016-11-02 13:35:14 +0100
commit6419fe366a83314258f24d4ee2852a461b590c61 (patch)
treed087d02bc93809e0bdaeb34c8ab4ee5815ff9174 /spec
parentd7859912b2a4a5d0f8aee63b393080ec03f5bbc2 (diff)
downloadgitlab-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>
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_services/jira_service_spec.rb22
1 files changed, 22 insertions, 0 deletions
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))