diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2015-01-26 22:39:32 +0300 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2015-01-26 22:39:32 +0300 |
commit | 65e700472b471242475eb9d9e3a340c6ce24615a (patch) | |
tree | 1e859b9989e8f570e4bbe229335bde295c977241 /app | |
parent | c70dcd290704777104a136bd038dffc68daec4ab (diff) |
Update the issue tracker attribute on issue tracker change.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/services_controller.rb | 3 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 6 | ||||
-rw-r--r-- | app/models/project.rb | 17 |
3 files changed, 14 insertions, 12 deletions
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 15f47ed9c9f..a2cb4ae1ae9 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -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 diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index cfbbed842cd..2bf430f9142 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -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 diff --git a/app/models/project.rb b/app/models/project.rb index 20b9a5a34dc..de31f14b98e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 |