Commit c918000b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #3396 from Andrew8xx8/issue-button-fix

New issue button was not follows to external tracker if it is selected. ...
parents 6005ec89 5e6f45b0
...@@ -48,19 +48,31 @@ module IssuesHelper ...@@ -48,19 +48,31 @@ module IssuesHelper
if @project.used_default_issues_tracker? if @project.used_default_issues_tracker?
project_issues_filter_path(@project) project_issues_filter_path(@project)
else else
url = Settings[:issues_tracker][@project.issues_tracker]["project_url"] url = Gitlab.config.issues_tracker[@project.issues_tracker]["project_url"]
url.gsub(':project_id', @project.id.to_s) url.gsub(':project_id', @project.id.to_s)
.gsub(':issues_tracker_id', @project.issues_tracker_id.to_s) .gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
end end
end end
def url_for_new_issue
return "" if @project.nil?
if @project.used_default_issues_tracker?
url = new_project_issue_path project_id: @project
else
url = Gitlab.config.issues_tracker[@project.issues_tracker]["new_issue_url"]
url.gsub(':project_id', @project.id.to_s)
.gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
end
end
def url_for_issue(issue_id) def url_for_issue(issue_id)
return "" if @project.nil? return "" if @project.nil?
if @project.used_default_issues_tracker? if @project.used_default_issues_tracker?
url = project_issue_url project_id: @project, id: issue_id url = project_issue_url project_id: @project, id: issue_id
else else
url = Settings[:issues_tracker][@project.issues_tracker]["issues_url"] url = Gitlab.config.issues_tracker[@project.issues_tracker]["issues_url"]
url.gsub(':id', issue_id.to_s) url.gsub(':id', issue_id.to_s)
.gsub(':project_id', @project.id.to_s) .gsub(':project_id', @project.id.to_s)
.gsub(':issues_tracker_id', @project.issues_tracker_id.to_s) .gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
......
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
= link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn-small btn grouped" do = link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn-small btn grouped" do
Merge Request Merge Request
- if @project.issues_enabled && can?(current_user, :write_issue, @project) - if @project.issues_enabled && can?(current_user, :write_issue, @project)
= link_to new_project_issue_path(@project), title: "New Issue", class: "btn-small btn grouped" do = link_to url_for_new_issue, title: "New Issue", class: "btn-small btn grouped" do
Issue Issue
...@@ -46,12 +46,19 @@ production: &base ...@@ -46,12 +46,19 @@ production: &base
# ## :project_id - GitLab project identifier # ## :project_id - GitLab project identifier
# ## :issues_tracker_id - Project Name or Id in external issue tracker # ## :issues_tracker_id - Project Name or Id in external issue tracker
# project_url: "http://redmine.sample/projects/:issues_tracker_id" # project_url: "http://redmine.sample/projects/:issues_tracker_id"
#
# ## If not nil, links from /#\d/ entities from commit messages will replaced with this # ## If not nil, links from /#\d/ entities from commit messages will replaced with this
# ## Use placeholders: # ## Use placeholders:
# ## :project_id - GitLab project identifier # ## :project_id - GitLab project identifier
# ## :issues_tracker_id - Project Name or Id in external issue tracker # ## :issues_tracker_id - Project Name or Id in external issue tracker
# ## :id - Issue id (from commit messages) # ## :id - Issue id (from commit messages)
# issues_url: "http://redmine.sample/issues/:id" # issues_url: "http://redmine.sample/issues/:id"
#
# ## If not nil, linkis to creating new issues will be replaced with this
# ## Use placeholders:
# ## :project_id - GitLab project identifier
# ## :issues_tracker_id - Project Name or Id in external issue tracker
# new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new"
## Gravatar ## Gravatar
gravatar: gravatar:
...@@ -152,6 +159,7 @@ test: ...@@ -152,6 +159,7 @@ test:
redmine: redmine:
project_url: "http://redmine/projects/:issues_tracker_id" project_url: "http://redmine/projects/:issues_tracker_id"
issues_url: "http://redmine/:project_id/:issues_tracker_id/:id" issues_url: "http://redmine/:project_id/:issues_tracker_id/:id"
new_issue_url: "http://redmine/projects/:issues_tracker_id/insues/new"
staging: staging:
<<: *base <<: *base
...@@ -76,4 +76,31 @@ describe IssuesHelper do ...@@ -76,4 +76,31 @@ describe IssuesHelper do
url_for_issue(issue.id).should eq "" url_for_issue(issue.id).should eq ""
end end
end end
describe :url_for_new_issue do
let(:issues_url) { Gitlab.config.issues_tracker.redmine.new_issue_url}
let(:ext_expected) do
issues_url.gsub(':project_id', ext_project.id.to_s)
.gsub(':issues_tracker_id', ext_project.issues_tracker_id.to_s)
end
let(:int_expected) { new_project_issue_path(project) }
it "should return internal path if used internal tracker" do
@project = project
url_for_new_issue.should match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
url_for_new_issue.should match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
url_for_new_issue.should eq ""
end
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