From: Jean-Philippe Lang Date: Sun, 28 Sep 2008 08:05:55 +0000 (+0000) Subject: Fixed: the default status is lost when reordering issue statuses (#1955). X-Git-Tag: 0.8.0-RC1~186 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=925ef8f4f0387e955823dc9db849d0ba24b1291d;p=redmine.git 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 --- 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