summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/issue_status.rb4
-rw-r--r--test/unit/issue_status_test.rb7
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