Commit ec337276 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'issue_tracker' of /home/git/repositories/gitlab/gitlabhq

parents fd39c80f 52739518
...@@ -16,7 +16,7 @@ module IssuesHelper ...@@ -16,7 +16,7 @@ module IssuesHelper
def url_for_project_issues def url_for_project_issues
return "" if @project.nil? return "" if @project.nil?
if @project.used_default_issues_tracker? if @project.used_default_issues_tracker? || !external_issues_tracker_enabled?
project_issues_path(@project) project_issues_path(@project)
else else
url = Gitlab.config.issues_tracker[@project.issues_tracker]["project_url"] url = Gitlab.config.issues_tracker[@project.issues_tracker]["project_url"]
...@@ -28,7 +28,7 @@ module IssuesHelper ...@@ -28,7 +28,7 @@ module IssuesHelper
def url_for_new_issue def url_for_new_issue
return "" if @project.nil? return "" if @project.nil?
if @project.used_default_issues_tracker? if @project.used_default_issues_tracker? || !external_issues_tracker_enabled?
url = new_project_issue_path project_id: @project url = new_project_issue_path project_id: @project
else else
url = Gitlab.config.issues_tracker[@project.issues_tracker]["new_issue_url"] url = Gitlab.config.issues_tracker[@project.issues_tracker]["new_issue_url"]
...@@ -40,7 +40,7 @@ module IssuesHelper ...@@ -40,7 +40,7 @@ module IssuesHelper
def url_for_issue(issue_iid) def url_for_issue(issue_iid)
return "" if @project.nil? return "" if @project.nil?
if @project.used_default_issues_tracker? if @project.used_default_issues_tracker? || !external_issues_tracker_enabled?
url = project_issue_url project_id: @project, id: issue_iid url = project_issue_url project_id: @project, id: issue_iid
else else
url = Gitlab.config.issues_tracker[@project.issues_tracker]["issues_url"] url = Gitlab.config.issues_tracker[@project.issues_tracker]["issues_url"]
...@@ -59,4 +59,13 @@ module IssuesHelper ...@@ -59,4 +59,13 @@ module IssuesHelper
"" ""
end end
end end
# Checks if issues_tracker setting exists in gitlab.yml
def external_issues_tracker_enabled?
if Gitlab.config.issues_tracker && Gitlab.config.issues_tracker.values.any?
true
else
false
end
end
end end
...@@ -47,6 +47,17 @@ describe IssuesHelper do ...@@ -47,6 +47,17 @@ describe IssuesHelper do
url_for_project_issues.should eq "" url_for_project_issues.should eq ""
end end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
Gitlab.config.stub(:issues_tracker).and_return(nil)
end
it "should return path to internal tracker" do
url_for_project_issues.should match(polymorphic_path([@project]))
end
end
end end
describe :url_for_issue do describe :url_for_issue do
...@@ -75,6 +86,17 @@ describe IssuesHelper do ...@@ -75,6 +86,17 @@ describe IssuesHelper do
url_for_issue(issue.iid).should eq "" url_for_issue(issue.iid).should eq ""
end end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
Gitlab.config.stub(:issues_tracker).and_return(nil)
end
it "should return internal path" do
url_for_issue(issue.iid).should match(polymorphic_path([@project, issue]))
end
end
end end
describe :url_for_new_issue do describe :url_for_new_issue do
...@@ -101,6 +123,17 @@ describe IssuesHelper do ...@@ -101,6 +123,17 @@ describe IssuesHelper do
url_for_new_issue.should eq "" url_for_new_issue.should eq ""
end end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
Gitlab.config.stub(:issues_tracker).and_return(nil)
end
it "should return internal path" do
url_for_new_issue.should match(new_project_issue_path(@project))
end
end
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