]> source.dussan.org Git - redmine.git/commitdiff
Fixed: the default status is lost when reordering issue statuses (#1955).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 28 Sep 2008 08:05:55 +0000 (08:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 28 Sep 2008 08:05:55 +0000 (08:05 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1911 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_status.rb
test/unit/issue_status_test.rb

index ddff9c0050d5aa83a08bb84cd4b0d8be603848ae..16c7bce91ca152074c7dde595f41162e59b703f2 100644 (file)
@@ -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
index 404bc36bad47c878b48bb03dfc9ad1610b03c90a..b36112cd165192557e23f2c29a7429a195c3281f 100644 (file)
@@ -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