aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations_test.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-01 11:28:31 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-01 11:34:17 -0200
commit26861e95064c57159486a02709ca0f2436596062 (patch)
tree1d91c0e7bf09e42238939b471a7901de21414780 /activemodel/test/cases/validations_test.rb
parent0b5edb32cf53873c975f0c656f356dd3f440233c (diff)
downloadrails-26861e95064c57159486a02709ca0f2436596062.tar.gz
rails-26861e95064c57159486a02709ca0f2436596062.tar.bz2
rails-26861e95064c57159486a02709ca0f2436596062.zip
Generate strict validation error messages with attribute name
Diffstat (limited to 'activemodel/test/cases/validations_test.rb')
-rw-r--r--activemodel/test/cases/validations_test.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb
index fe5358a9d0..0b1de62a48 100644
--- a/activemodel/test/cases/validations_test.rb
+++ b/activemodel/test/cases/validations_test.rb
@@ -310,7 +310,7 @@ class ValidationsTest < ActiveModel::TestCase
end
def test_strict_validation_particular_validator
- Topic.validates :title, :presence => {:strict => true}
+ Topic.validates :title, :presence => { :strict => true }
assert_raises ActiveModel::StrictValidationFailed do
Topic.new.valid?
end
@@ -330,9 +330,18 @@ class ValidationsTest < ActiveModel::TestCase
end
end
+ def test_strict_validation_error_message
+ Topic.validates :title, :strict => true, :presence => true
+
+ exception = assert_raises(ActiveModel::StrictValidationFailed) do
+ Topic.new.valid?
+ end
+ assert_equal "Title can't be blank", exception.message
+ end
+
def test_does_not_modify_options_argument
- options = {:presence => true}
+ options = { :presence => true }
Topic.validates :title, options
- assert_equal({:presence => true}, options)
+ assert_equal({ :presence => true }, options)
end
end