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