From 925ef8f4f0387e955823dc9db849d0ba24b1291d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 28 Sep 2008 08:05:55 +0000 Subject: [PATCH] Fixed: the default status is lost when reordering issue statuses (#1955). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1911 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue_status.rb | 4 ++-- test/unit/issue_status_test.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index ddff9c005..16c7bce91 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -25,8 +25,8 @@ class IssueStatus < ActiveRecord::Base validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i - def before_save - IssueStatus.update_all "is_default=#{connection.quoted_false}" if self.is_default? + def after_save + IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default? end # Returns the default status for new issues diff --git a/test/unit/issue_status_test.rb b/test/unit/issue_status_test.rb index 404bc36ba..b36112cd1 100644 --- a/test/unit/issue_status_test.rb +++ b/test/unit/issue_status_test.rb @@ -46,4 +46,11 @@ class IssueStatusTest < Test::Unit::TestCase assert_equal status, IssueStatus.default assert !IssueStatus.find(1).is_default end + + def test_reorder_should_not_clear_default_status + status = IssueStatus.default + status.move_to_bottom + status.reload + assert status.is_default? + end end -- 2.39.5