Commit 65e70047 authored by Marin Jankovski's avatar Marin Jankovski

Update the issue tracker attribute on issue tracker change.

parent c70dcd29
......@@ -17,6 +17,9 @@ class Projects::ServicesController < Projects::ApplicationController
def update
if @service.update_attributes(service_params)
if @service.activated? && @service.category == :issue_tracker
@project.update_attributes(issues_tracker: @service.to_param)
end
redirect_to edit_project_service_path(@project, @service.to_param),
notice: 'Successfully updated.'
else
......
......@@ -16,7 +16,7 @@ module IssuesHelper
def url_for_project_issues(project = @project)
return '' if project.nil?
if project.using_issue_tracker?
if project.default_issues_tracker?
project_issues_path(project)
else
project.external_issue_tracker.project_url
......@@ -26,7 +26,7 @@ module IssuesHelper
def url_for_new_issue(project = @project)
return '' if project.nil?
if project.using_issue_tracker?
if project.default_issues_tracker?
url = new_project_issue_path project_id: project
else
project.external_issue_tracker.new_issue_url
......@@ -36,7 +36,7 @@ module IssuesHelper
def url_for_issue(issue_iid, project = @project)
return '' if project.nil?
if project.using_issue_tracker?
if project.default_issues_tracker?
url = project_issue_url project_id: project, id: issue_iid
else
url = project.external_issue_tracker.issues_url
......
......@@ -308,11 +308,14 @@ class Project < ActiveRecord::Base
end
def default_issues_tracker?
self.issues_tracker == Project.issues_tracker.default_value
end
def external_issues_tracker_enabled?
external_issues_trackers.any?
if external_issue_tracker
false
else
unless self.issues_tracker == Project.issues_tracker.default_value
self.update_attributes(issues_tracker: Project.issues_tracker.default_value)
end
true
end
end
def external_issues_trackers
......@@ -323,10 +326,6 @@ 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.default_issues_tracker?
end
......
......@@ -208,7 +208,7 @@ module Gitlab
end
def reference_issue(identifier, project = @project, prefix_text = nil)
if project.using_issue_tracker?
if project.default_issues_tracker?
if project.issue_exists? identifier
url = url_for_issue(identifier, project)
title = title_for_issue(identifier, project)
......
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