Commit 7c701acf authored by Marin Jankovski's avatar Marin Jankovski

Do a check which issue tracker is used inside the project.

parent 103a1bb0
......@@ -16,7 +16,7 @@ module IssuesHelper
def url_for_project_issues(project = @project)
return '' if project.nil?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
if project.using_issue_tracker?
project_issues_path(project)
else
url = Gitlab.config.issues_tracker[project.issues_tracker]['project_url']
......@@ -28,7 +28,7 @@ module IssuesHelper
def url_for_new_issue(project = @project)
return '' if project.nil?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
if project.using_issue_tracker?
url = new_project_issue_path project_id: project
else
issues_tracker = Gitlab.config.issues_tracker[project.issues_tracker]
......@@ -41,7 +41,7 @@ module IssuesHelper
def url_for_issue(issue_iid, project = @project)
return '' if project.nil?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
if project.using_issue_tracker?
url = project_issue_url project_id: project, id: issue_iid
else
url = Gitlab.config.issues_tracker[project.issues_tracker]['issues_url']
......@@ -54,7 +54,7 @@ module IssuesHelper
def title_for_issue(issue_iid, project = @project)
return '' if project.nil?
if project.used_default_issues_tracker?
if project.default_issues_tracker?
issue = project.issues.where(iid: issue_iid).first
return issue.title if issue
end
......
......@@ -298,14 +298,14 @@ class Project < ActiveRecord::Base
end
def issue_exists?(issue_id)
if used_default_issues_tracker?
if default_issues_tracker?
self.issues.where(iid: issue_id).first.present?
else
true
end
end
def used_default_issues_tracker?
def default_issues_tracker?
self.issues_tracker == Project.issues_tracker.default_value
end
......@@ -321,8 +321,12 @@ class Project < ActiveRecord::Base
@external_issues_tracker ||= external_issues_trackers.select(&:activated?).first
end
def using_issue_tracker?
default_issues_tracker? || !external_issues_tracker_enabled?
end
def can_have_issues_tracker_id?
self.issues_enabled && !self.used_default_issues_tracker?
self.issues_enabled && !self.default_issues_tracker?
end
def build_missing_services
......
......@@ -39,7 +39,7 @@
%i.fa.fa-exclamation-circle
%span
Issues
- if @project.used_default_issues_tracker?
- if @project.default_issues_tracker?
%span.count.issue_counter= @project.issues.opened.count
- if project_nav_tab? :merge_requests
......
......@@ -208,7 +208,7 @@ module Gitlab
end
def reference_issue(identifier, project = @project, prefix_text = nil)
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
if project.using_issue_tracker?
if project.issue_exists? identifier
url = url_for_issue(identifier, project)
title = title_for_issue(identifier, project)
......
......@@ -195,16 +195,16 @@ describe Project do
end
end
describe :used_default_issues_tracker? do
describe :default_issues_tracker? do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
it "should be true if used internal tracker" do
project.used_default_issues_tracker?.should be_true
project.default_issues_tracker?.should be_true
end
it "should be false if used other tracker" do
ext_project.used_default_issues_tracker?.should be_false
ext_project.default_issues_tracker?.should be_false
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