Merge pull request #3396 from Andrew8xx8/issue-button-fix
New issue button was not follows to external tracker if it is selected. ...
This commit is contained in:
commit
c918000bc2
|
@ -48,19 +48,31 @@ module IssuesHelper
|
|||
if @project.used_default_issues_tracker?
|
||||
project_issues_filter_path(@project)
|
||||
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)
|
||||
.gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
|
||||
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)
|
||||
return "" if @project.nil?
|
||||
|
||||
if @project.used_default_issues_tracker?
|
||||
url = project_issue_url project_id: @project, id: issue_id
|
||||
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)
|
||||
.gsub(':project_id', @project.id.to_s)
|
||||
.gsub(':issues_tracker_id', @project.issues_tracker_id.to_s)
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
= link_to new_project_merge_request_path(@project), title: "New Merge Request", class: "btn-small btn grouped" do
|
||||
Merge Request
|
||||
- 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
|
||||
|
|
|
@ -46,12 +46,19 @@ production: &base
|
|||
# ## :project_id - GitLab project identifier
|
||||
# ## :issues_tracker_id - Project Name or Id in external issue tracker
|
||||
# project_url: "http://redmine.sample/projects/:issues_tracker_id"
|
||||
#
|
||||
# ## If not nil, links from /#\d/ entities from commit messages will replaced with this
|
||||
# ## Use placeholders:
|
||||
# ## :project_id - GitLab project identifier
|
||||
# ## :issues_tracker_id - Project Name or Id in external issue tracker
|
||||
# ## :id - Issue id (from commit messages)
|
||||
# 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:
|
||||
|
@ -152,6 +159,7 @@ test:
|
|||
redmine:
|
||||
project_url: "http://redmine/projects/:issues_tracker_id"
|
||||
issues_url: "http://redmine/:project_id/:issues_tracker_id/:id"
|
||||
new_issue_url: "http://redmine/projects/:issues_tracker_id/insues/new"
|
||||
|
||||
staging:
|
||||
<<: *base
|
||||
|
|
|
@ -76,4 +76,31 @@ describe IssuesHelper do
|
|||
url_for_issue(issue.id).should eq ""
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue