<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -69,11 +69,13 @@ module NestedAssignment
   
   # deep saving of any new, changed, or deleted records.
   def create_or_update_with_associated(*args)
+    without_recursion(:create_or_update){
     self.class.transaction do
       create_or_update_without_associated(*args) &amp;&amp;
-        without_recursion(:create_or_update){modified_associated.all?{|a| a.save(*args)}} &amp;&amp;
+        modified_associated.all?{|a| a.save(*args)} &amp;&amp;
         deletable_associated.all?{|a| a.destroy}
     end
+    }
   end
   
   # Without this, we may not save deeply nested and changed records.</diff>
      <filename>lib/nested_assignment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,4 +52,8 @@ module PluginTestModels
     
     validates_presence_of :name
   end
+  
+  class Event &lt; ActiveRecord::Base
+    belongs_to :entity, :polymorphic =&gt; true
+  end
 end</diff>
      <filename>test/db/models.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,4 +34,9 @@ ActiveRecord::Schema.define(:version =&gt; 1) do
     t.column :user_id, :integer
   end
 
+  create_table :events, :force =&gt; true do |t|
+    t.column :entity_id, :integer
+    t.column :entity_type, :string
+    t.column :name, :string
+  end
 end</diff>
      <filename>test/db/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -37,28 +37,41 @@ class NestedAssignmentSavingTest &lt; ActiveSupport::TestCase
     assert_equal &quot;difficult&quot;, @user.reload.tasks[0].tags[0].name
   end
   
-  def test_saving_with_recursive_references
-    # This recursive situation is a little contrived. A more likely example would be
-    # a new associated record that refers back to the first. For example, suppose you
-    # store events, and after the user modifies his name you wish to store the fact.
-    # You may do something like `Event.create(:user =&gt; self, :change =&gt; 'name')`. This
-    # would create a recursive reference such as here.
+  def test_saving!
     @user = users(:bob)
-    @user.name = &quot;william&quot;
     @user.tasks[0].name = &quot;research&quot;
-    @user.tasks[0].user = @user
-    assert_nothing_raised do
-      @user.save
+    @user.save!
+    assert_equal &quot;research&quot;, @user.reload.tasks[0].name
+  end
+  
+  class UserWithEvent &lt; User
+    after_save do |user|
+      PluginTestModels::Event.create(:entity =&gt; user)
+    end
+  end
+  
+  def test_saving_a_modified_record_that_spawns_an_associated_record
+    @user = UserWithEvent.find(:first)
+    @user.name = &quot;william&quot;
+    assert_difference &quot;Event.count&quot;, 1 do
+      assert_nothing_raised do
+        @user.save
+      end
     end
     @user.reload
     assert_equal &quot;william&quot;, @user.name
-    assert_equal &quot;research&quot;, @user.tasks[0].name
   end
   
-  def test_saving!
-    @user = users(:bob)
-    @user.tasks[0].name = &quot;research&quot;
-    @user.save!
-    assert_equal &quot;research&quot;, @user.reload.tasks[0].name
+  class UserWithResave &lt; User
+    after_create do |user|
+      user.update_attribute(:name, &quot;#{user.name} (verified)&quot;)
+    end
+  end
+  
+  def test_saving_a_new_record_with_a_single_resave
+    @user = UserWithResave.new
+    @user.name = &quot;george&quot;
+    @user.save
+    assert_equal &quot;george (verified)&quot;, @user.reload.name
   end
 end</diff>
      <filename>test/unit/nested_assignment_saving_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ed595a7da8f40a894eab7cb542ab0c0b60f0c759</id>
    </parent>
  </parents>
  <author>
    <name>Lance Ivy</name>
    <email>lance@cainlevy.net</email>
  </author>
  <url>http://github.com/cainlevy/nested_assignment/commit/5828485d657c1a8f468f4ea64f3ba273fff532b0</url>
  <id>5828485d657c1a8f468f4ea64f3ba273fff532b0</id>
  <committed-date>2008-12-17T20:17:16-08:00</committed-date>
  <authored-date>2008-12-17T20:17:16-08:00</authored-date>
  <message>writing test coverage for two conflicting saving patterns this plugin needs to support.</message>
  <tree>c258e98ae239821714c04e38a0e4765d3b612bd5</tree>
  <committer>
    <name>Lance Ivy</name>
    <email>lance@cainlevy.net</email>
  </committer>
</commit>
