Permalink
Browse files

Fix default_error_messages back to the original message

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent b22c951 commit 68b2b730e46de8415ece93701ea40434ae080353 @amatsuda amatsuda committed with jeremy Mar 19, 2009
Showing with 6 additions and 3 deletions.
  1. +6 −3 activerecord/test/cases/validations_test.rb
@@ -149,15 +149,18 @@ def test_throw_away_typing
end
def test_validates_length_with_globally_modified_error_message
- ActiveSupport::Deprecation.silence do
- ActiveRecord::Errors.default_error_messages[:too_short] = 'tu est trops petit hombre {{count}}'
- end
+ defaults = ActiveSupport::Deprecation.silence { ActiveRecord::Errors.default_error_messages }
+ original_message = defaults[:too_short]
+ defaults[:too_short] = 'tu est trops petit hombre {{count}}'
Topic.validates_length_of :title, :minimum => 10
t = Topic.create(:title => 'too short')
assert !t.valid?
assert_equal ['tu est trops petit hombre 10'], t.errors[:title]
+
+ ensure
+ defaults[:too_short] = original_message
end
def test_validates_acceptance_of_as_database_column

0 comments on commit 68b2b73

Please sign in to comment.