<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -27,7 +27,7 @@ UserStamp.updater_attribute   = :updater_id
 UserStamp.current_user_method = :current_user
 
 class UserStampSweeper &lt; ActionController::Caching::Sweeper
-  def before_save(record)
+  def before_validation(record)
     return unless current_user
     
     if record.respond_to?(UserStamp.creator_assignment_method) &amp;&amp; record.new_record?</diff>
      <filename>lib/user_stamp.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ class PostsController
   end
 end
 
-describe UserStampSweeper, &quot;#before_save&quot; do
+describe UserStampSweeper, &quot;#before_validation&quot; do
   before do
     UserStamp.creator_attribute   = :creator_id
     UserStamp.updater_attribute   = :updater_id
@@ -19,14 +19,14 @@ describe UserStampSweeper, &quot;#before_save&quot; do
     it &quot;should set creator_id if attribute exists&quot; do
       record = mock('Record', :creator_id= =&gt; nil, :updater_id= =&gt; nil, :new_record? =&gt; true)
       record.should_receive(:creator_id=).with(220).once
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
     
     it &quot;should NOT set creator_id if attribute does not exist&quot; do
       record = mock('Record', :new_record? =&gt; true, :updater_id= =&gt; nil, :respond_to? =&gt; false)
       record.should_receive(:respond_to?).with(&quot;creator_id=&quot;).and_return(false)
       record.should_not_receive(:creator_id=)
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
   end
   
@@ -34,31 +34,31 @@ describe UserStampSweeper, &quot;#before_save&quot; do
     it &quot;should NOT set creator_id if attribute exists&quot; do
       record = mock('Record', :creator_id= =&gt; nil, :updater_id= =&gt; nil, :new_record? =&gt; false)
       record.should_not_receive(:creator_id=)
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
     
     it &quot;should NOT set creator_id if attribute does not exist&quot; do
       record = mock('Record', :updater_id= =&gt; nil, :new_record? =&gt; false)
       record.should_not_receive(:creator_id=)
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
   end
   
   it &quot;should set updater_id if attribute exists&quot; do
     record = mock('Record', :creator_id= =&gt; nil, :updater_id= =&gt; nil, :new_record? =&gt; :false)
     record.should_receive(:updater_id=)
-    @sweeper.before_save(record)
+    @sweeper.before_validation(record)
   end
   
   it &quot;should NOT set updater_id if attribute does not exist&quot; do
     record = mock('Record', :creator_id= =&gt; nil, :updater_id= =&gt; nil, :new_record? =&gt; :false, :respond_to? =&gt; false)
     record.should_receive(:respond_to?).with(&quot;updater_id=&quot;).and_return(false)
     record.should_not_receive(:updater_id=)
-    @sweeper.before_save(record)
+    @sweeper.before_validation(record)
   end
 end
 
-describe UserStampSweeper, &quot;#before_save (with custom attribute names)&quot; do
+describe UserStampSweeper, &quot;#before_validation (with custom attribute names)&quot; do
   before do
     UserStamp.creator_attribute   = :created_by
     UserStamp.updater_attribute   = :updated_by
@@ -71,14 +71,14 @@ describe UserStampSweeper, &quot;#before_save (with custom attribute names)&quot; do
     it &quot;should set created_by if attribute exists&quot; do
       record = mock('Record', :created_by= =&gt; nil, :updated_by= =&gt; nil, :new_record? =&gt; true)
       record.should_receive(:created_by=).with(220).once
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
     
     it &quot;should NOT set created_by if attribute does not exist&quot; do
       record = mock('Record', :new_record? =&gt; true, :updated_by= =&gt; nil, :respond_to? =&gt; false)
       record.should_receive(:respond_to?).with(&quot;created_by=&quot;).and_return(false)
       record.should_not_receive(:created_by=)
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
   end
   
@@ -86,27 +86,27 @@ describe UserStampSweeper, &quot;#before_save (with custom attribute names)&quot; do
     it &quot;should NOT set created_by if attribute exists&quot; do
       record = mock('Record', :created_by= =&gt; nil, :updated_by= =&gt; nil, :new_record? =&gt; false)
       record.should_not_receive(:created_by=)
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
     
     it &quot;should NOT set created_by if attribute does not exist&quot; do
       record = mock('Record', :updated_by= =&gt; nil, :new_record? =&gt; false)
       record.should_not_receive(:created_by=)
-      @sweeper.before_save(record)
+      @sweeper.before_validation(record)
     end
   end
   
   it &quot;should set updated_by if attribute exists&quot; do
     record = mock('Record', :created_by= =&gt; nil, :updated_by= =&gt; nil, :new_record? =&gt; :false)
     record.should_receive(:updated_by=)
-    @sweeper.before_save(record)
+    @sweeper.before_validation(record)
   end
   
   it &quot;should NOT set updated_by if attribute does not exist&quot; do
     record = mock('Record', :created_by= =&gt; nil, :updated_by= =&gt; nil, :new_record? =&gt; :false, :respond_to? =&gt; false)
     record.should_receive(:respond_to?).with(&quot;updated_by=&quot;).and_return(false)
     record.should_not_receive(:updated_by=)
-    @sweeper.before_save(record)
+    @sweeper.before_validation(record)
   end
 end
 </diff>
      <filename>spec/user_stamp_sweeper_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>97f0a85f9241112182d6f43341e06aa3631b67d2</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/user_stamp/commit/93d38c83c18919220a83914e4ae5c930c2548ca8</url>
  <id>93d38c83c18919220a83914e4ae5c930c2548ca8</id>
  <committed-date>2009-03-11T11:03:54-07:00</committed-date>
  <authored-date>2009-03-11T11:03:54-07:00</authored-date>
  <message>Changed sweeper from before_save to before_validation. This allows using the stamped users in validations which is handy for simple authorization stuff.</message>
  <tree>d6266945e5757244668726e0867ec0b6e4b20995</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
