diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-27 14:49:43 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-27 14:53:59 -0300 |
commit | a87573d9e6610c72a93d4cc778e7703ca6d964e2 (patch) | |
tree | d69cdb78dee44aee415ce7c1cf88e6cb10bd56a5 /activerecord/test | |
parent | 35a9f7a6353ea12dd3103366e84ccc90123c3583 (diff) | |
parent | 0fa4c95d914d9f04553642f5181ee7c2cf4c6add (diff) | |
download | rails-a87573d9e6610c72a93d4cc778e7703ca6d964e2.tar.gz rails-a87573d9e6610c72a93d4cc778e7703ca6d964e2.tar.bz2 rails-a87573d9e6610c72a93d4cc778e7703ca6d964e2.zip |
Merge pull request #8639 from bogdan/valid-with-bang
Add AR::Base#valid! method
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/validations_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index a6e1dc72e5..55804f9576 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -78,6 +78,20 @@ class ValidationsTest < ActiveRecord::TestCase assert_equal r, invalid.record end + def test_validate_with_bang + assert_raise(ActiveRecord::RecordInvalid) do + WrongReply.new.validate! + end + end + + def test_validate_with_bang_and_context + assert_raise(ActiveRecord::RecordInvalid) do + WrongReply.new.validate!(:special_case) + end + r = WrongReply.new(:title => "Valid title", :author_name => "secret", :content => "Good") + assert r.validate!(:special_case) + end + def test_exception_on_create_bang_many assert_raise(ActiveRecord::RecordInvalid) do WrongReply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }]) |