aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/autosave_association_test.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-04-29 19:47:21 -0300
committerEmilio Tagua <miloops@gmail.com>2009-04-29 19:47:21 -0300
commitb0bd4f45fa9180793e3c35590c8a887ddfe43553 (patch)
treed1ab690267c5e4d9d04faca14d4695f163375086 /activerecord/test/cases/autosave_association_test.rb
parent19d2ff83db5232a816dee201800baf3924705b31 (diff)
parentdb892ea77563dadb6fbbd242be78ff87321d0bd1 (diff)
downloadrails-b0bd4f45fa9180793e3c35590c8a887ddfe43553.tar.gz
rails-b0bd4f45fa9180793e3c35590c8a887ddfe43553.tar.bz2
rails-b0bd4f45fa9180793e3c35590c8a887ddfe43553.zip
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/test/cases/autosave_association_test.rb')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 436f50d395..919b6f857c 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -38,6 +38,17 @@ class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase
end
class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase
+ def test_should_save_parent_but_not_invalid_child
+ firm = Firm.new(:name => 'GlobalMegaCorp')
+ assert firm.valid?
+
+ firm.build_account_using_primary_key
+ assert !firm.build_account_using_primary_key.valid?
+
+ assert firm.save
+ assert firm.account_using_primary_key.new_record?
+ end
+
def test_save_fails_for_invalid_has_one
firm = Firm.find(:first)
assert firm.valid?
@@ -126,6 +137,17 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas
end
class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
+ def test_should_save_parent_but_not_invalid_child
+ client = Client.new(:name => 'Joe (the Plumber)')
+ assert client.valid?
+
+ client.build_firm
+ assert !client.firm.valid?
+
+ assert client.save
+ assert client.firm.new_record?
+ end
+
def test_save_fails_for_invalid_belongs_to
assert log = AuditLog.create(:developer_id => 0, :message => "")