diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-04-06 02:32:51 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-04-06 02:32:51 +0000 |
commit | 7ddc8f2e1bc9c818b622373a8c85bd679533cefd (patch) | |
tree | 683b5c10891b4e7704404fcf3de81da08f02a54b /activerecord/test | |
parent | 9bc75fd007d56d818b8620569410a20aa92c9fc5 (diff) | |
download | rails-7ddc8f2e1bc9c818b622373a8c85bd679533cefd.tar.gz rails-7ddc8f2e1bc9c818b622373a8c85bd679533cefd.tar.bz2 rails-7ddc8f2e1bc9c818b622373a8c85bd679533cefd.zip |
Ensure that save on parent object fails for invalid has_one association. Closes #10518. [Pratik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9232 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/cases/associations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 22a6bfc3a5..6aa9010f48 100755 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -433,6 +433,18 @@ class HasOneAssociationsTest < ActiveRecord::TestCase assert_equal a, firm.account assert_equal a, firm.account(true) end + + def test_save_fails_for_invalid_has_one + firm = Firm.find(:first) + assert firm.valid? + + firm.account = Account.new + + assert !firm.account.valid? + assert !firm.valid? + assert !firm.save + assert_equal "is invalid", firm.errors.on("account") + end def test_assignment_before_either_saved firm = Firm.new("name" => "GlobalMegaCorp") |