Commit 86f6f5a9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'redmine-fix'

parents 7de26f19 0d9f8494
v 7.2.0
- Improve Redmine integration
v 7.1.0
- Synchronize LDAP-enabled GitLab administrators with an LDAP group (Marvin Frick, sponsored by SinnerSchrader)
- Synchronize SSH keys with LDAP (Oleg Girko (Jolla) and Marvin Frick (SinnerSchrader))
......
......@@ -338,6 +338,10 @@ class Project < ActiveRecord::Base
self.issues_tracker == "jira"
end
def redmine_tracker?
self.issues_tracker == "redmine"
end
# For compatibility with old code
def code
path
......
......@@ -192,8 +192,10 @@ module Gitlab
link_to("##{identifier}", url, options)
end
else
reference_jira_issue(identifier, project) if project.jira_tracker?
elsif project.redmine_tracker?
reference_redmine_issue(identifier, project)
elsif project.jira_tracker?
reference_jira_issue(identifier, project)
end
end
......@@ -239,5 +241,16 @@ module Gitlab
)
link_to("#{identifier}", url, options)
end
def reference_redmine_issue(identifier, project = @project)
url = url_for_issue(identifier)
title = Gitlab.config.issues_tracker[project.issues_tracker]["title"]
options = html_options.merge(
title: "Issue in #{title}",
class: "gfm gfm-issue #{html_options[:class]}"
)
link_to("rm##{identifier}", url, options)
end
end
end
......@@ -229,6 +229,52 @@ describe GitlabMarkdownHelper do
end
end
describe "referencing a Redmine issue" do
let(:actual) { "Reference to Redmine ##{issue.iid}" }
let(:expected) { "http://redmine.example/issues/#{issue.iid}" }
let(:reference) { "##{issue.iid}" }
before do
issue_tracker_config = { "redmine" => { "title" => "Redmine tracker", "issues_url" => "http://redmine.example/issues/:id" } }
Gitlab.config.stub(:issues_tracker).and_return(issue_tracker_config)
@project.stub(:issues_tracker).and_return("redmine")
@project.stub(:issues_tracker_id).and_return("REDMINE")
end
it "should link using a valid id" do
gfm(actual).should match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
# Append some text to the end of the reference
gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
gfm(actual).should match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
invalid_reference = actual.gsub(/(\d+)$/, "r45")
gfm(invalid_reference).should == invalid_reference
end
it "should include a title attribute" do
title = "Issue in Redmine tracker"
gfm(actual).should match(/title="#{title}"/)
end
it "should include standard gfm classes" do
gfm(actual).should match(/class="\s?gfm gfm-issue\s?"/)
end
end
describe "referencing a merge request" do
let(:object) { merge_request }
let(:reference) { "!#{merge_request.iid}" }
......
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