Permalink
Browse files

Test for circular reference while saving has_one relationship

  • Loading branch information...
1 parent a97cf75 commit 389d1c5b65568e316ac55aa6534e782648855b92 @AntiTyping committed Feb 16, 2012
Showing with 14 additions and 0 deletions.
  1. +12 −0 activerecord/test/cases/autosave_association_test.rb
  2. +2 −0 activerecord/test/models/face.rb
View
12 activerecord/test/cases/autosave_association_test.rb
@@ -3,8 +3,10 @@
require 'models/company'
require 'models/customer'
require 'models/developer'
+require 'models/face'
require 'models/invoice'
require 'models/line_item'
+require 'models/man'
require 'models/order'
require 'models/parrot'
require 'models/person'
@@ -880,6 +882,16 @@ def test_should_not_load_the_associated_model
end
end
+class TestAutosaveInverseAssociationOnAHasOneAssociation < ActiveRecord::TestCase
+ self.use_transactional_fixtures = false
+
+ def test_should_save_the_inverse_association_model
+ man = Man.new
+ man.build_face
+ man.face.save
+ end
+end
+
class TestAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
self.use_transactional_fixtures = false
View
2 activerecord/test/models/face.rb
@@ -4,4 +4,6 @@ class Face < ActiveRecord::Base
# These is a "broken" inverse_of for the purposes of testing
belongs_to :horrible_man, :class_name => 'Man', :inverse_of => :horrible_face
belongs_to :horrible_polymorphic_man, :polymorphic => true, :inverse_of => :horrible_polymorphic_face
+
+ accepts_nested_attributes_for :man
end

0 comments on commit 389d1c5

Please sign in to comment.