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 3413643 commit 596406f90a8037a08d59ce31cddfc16b5f12b6a1 @amatsuda amatsuda committed with jeremy Mar 19, 2009
Showing with 7 additions and 3 deletions.
  1. +7 −3 activerecord/test/cases/validations_test.rb
@@ -905,14 +905,18 @@ def test_validates_length_of_using_bignum
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_size_of_association

0 comments on commit 596406f

Please sign in to comment.