<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/ardes/active_record/saved.rb</filename>
    </added>
    <added>
      <filename>spec/controllers/comments_controller_with_models_spec.rb</filename>
    </added>
    <added>
      <filename>spec/controllers/resource_saved_spec.rb</filename>
    </added>
    <added>
      <filename>spec/models/comment_saved_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+* API change: save_resource deprecated
+
+  So save_resource is now deprecated, just use resource.save
+  ActiveRecords can now be asked if they are saved?
+  
 * rspec compat:  Added new rake task to test that an RC controller passes the default rspec_scaffold
   controller specs.
 </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,7 @@ resources_controller works with rails 2.x and edge.
 
 * The SPECDOC lists the specifications
 * Coverage is 100% (C0), and the spec suite is quite comprehensive
+* Rspec's generated rspec_scaffold controller specs are tested against a simple rc controller (see rake spec:generate)
 
 RSpec is used for testing, so the tests are in &lt;tt&gt;spec/&lt;/tt&gt; rather than
 &lt;tt&gt;test/&lt;/tt&gt; Do rake --tasks for more details.</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -60,7 +60,7 @@ Rake::RDocTask.new(:doc) do |t|
   t.title    = &quot;#{plugin_name}&quot;
   t.template = ENV['RDOC_TEMPLATE']
   t.options  = ['--line-numbers', '--inline-source', '--all']
-  t.rdoc_files.include('README', 'SPECDOC', 'MIT-LICENSE', 'CHANGELOG')
+  t.rdoc_files.include('README.rdoc', 'SPECDOC', 'MIT-LICENSE', 'CHANGELOG')
   t.rdoc_files.include('lib/**/*.rb')
 end
 </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -256,6 +256,53 @@ Requesting /forums/3/posts/3/comments/1 using DELETE
 - should call destroy on the found comment
 - should redirect to the comments list
 
+CommentsController without stubs responding to GET index
+- should expose all comments as @comments
+
+CommentsController without stubs responding to GET index with mime type of xml
+- should render all comments as xml
+
+CommentsController without stubs responding to GET show
+- should expose the requested comment as @comment
+
+CommentsController without stubs responding to GET show with mime type of xml
+- should render the requested comment as xml
+
+CommentsController without stubs responding to GET new
+- should expose a new comment as @comment
+
+CommentsController without stubs responding to GET edit
+- should expose the requested comment as @comment
+
+CommentsController without stubs responding to POST create with valid params
+- should create a comment
+- should expose the newly created comment as @comment
+- should be resource_saved?
+- should redirect to the created comment
+
+CommentsController without stubs responding to POST create with invalid params
+- should not create a comment
+- should expose a newly created but unsaved comment as @comment
+- should not be resource_saved?
+- should re-render the 'new' template
+
+CommentsController without stubs responding to PUT udpate with valid params
+- should update the requested comment
+- should not contain errors on comment
+- should be resource_saved?
+- should expose the requested comment as @comment
+- should redirect to the comment
+
+CommentsController without stubs responding to PUT udpate with invalid params
+- should fail to update the requested comment
+- should not be resource_saved?
+- should expose the requested comment as @comment
+- should re-render the 'edit' template
+
+CommentsController without stubs responding to DELETE destroy
+- should delete the requested comment
+- should redirect to the comments list
+
 Routing shortcuts for ForumPosts (forums/2/posts/1) should map
 - resources_path to /forums/2/posts
 - resource_path to /forums/2/posts/1
@@ -575,6 +622,25 @@ Requesting /forums/2/owner using DELETE
 - should set the flash notice
 - should redirect to forums/2
 
+CommentsController#resource_saved Comment.new(&lt;invalid attrs&gt;)
+- should not be resource saved
+
+CommentsController#resource_saved Comment.new(&lt;invalid attrs&gt;).save
+- should not be resource saved
+
+CommentsController#resource_saved Comment.new(&lt;invalid attrs&gt;).save then update_attributes(&lt;valid attrs&gt;)
+- should be resource saved
+
+CommentsController#resource_saved Comment.find(&lt;id&gt;)
+- should be resource saved
+- .save should be saved
+
+CommentsController#resource_saved Comment.find(&lt;id&gt;) then update_attributes(&lt;invalid attrs&gt;)
+- should not be resource saved
+
+CommentsController#resource_saved Comment.find(&lt;id&gt;) then update_attributes(&lt;new valid attrs&gt;)
+- should be resource saved
+
 Routing shortcuts for Tags should map
 - resources_path to /tags
 - resource_path to /tags/2
@@ -768,6 +834,18 @@ UsersController handling PUT /users/dave
 UsersController handling DELETE /users/dave
 - should be unknown action
 
+(re: saved?) Comment.new(&lt;invalid attrs&gt;)
+- should not be validation attempted
+- should not be saved
+
+(re: saved?) Comment.new(&lt;invalid attrs&gt;).save
+- should be validation attempted
+- should not be saved
+
+(re: saved?) Comment.new(&lt;invalid attrs&gt;).save then update_attributes(&lt;valid attrs&gt;)
+- should be validation attempted
+- should be saved
+
 ActionView with resources_controller Helper
 - should forward #resource_name to controller
 - should forward #resources_name to controller
@@ -792,12 +870,6 @@ Helper#form_for_resource (when resource is existing record)
 Helper#remote_form_for_resource (when resource is existing record)
 - should call remote_form_for with update form options
 
-ResourcesController.load_enclosing_resources_filter_exists? when :find_filter defined
-- should call :find_filter with :load_enclosing_resources
-
-ResourcesController.load_enclosing_resources_filter_exists? when :find_filter not defined
-- should call :filter_chain
-
 #load_enclosing_resources for resources_controller_for :tags (when route_enclosing_names is [['users', false]])
 - should call load_wildcard once
 - should call Specification.new('user', :singleton =&gt; false, :as =&gt; nil)
@@ -839,6 +911,12 @@ ResourcesController.load_enclosing_resources_filter_exists? when :find_filter no
 - should call load_enclosing_resource_from_specification with user spec, then load_wildcard once with 'taggable'
 - should call Specification.new with ('comment', :singleton =&gt; false, :as =&gt; 'taggable')
 
+ResourcesController.load_enclosing_resources_filter_exists? when :find_filter defined
+- should call :find_filter with :load_enclosing_resources
+
+ResourcesController.load_enclosing_resources_filter_exists? when :find_filter not defined
+- should call :filter_chain
+
 ResourcesController (in general)
 - nested_in :foo, :polymorphic =&gt; true, :class =&gt; User should raise argument error (no options or block with polymorphic)
 - resources_controller_for :forums, :in =&gt; [:user, '*', '*', :comment] should raise argument error (no multiple wildcards in a row)
@@ -849,6 +927,9 @@ ResourcesController#enclosing_resource_name
 A controller's resource_service
 - may be explicitly set with #resource_service=
 
+deprecated methods
+- #save_resource should send resource.save
+
 #route_enclosing_names TagsController for named_route:
 - :tags should be []
 - :new_tag should be []
@@ -870,6 +951,6 @@ A controller's resource_service
 #route_enclosing_names Admin::Superduper::ForumsController for named_route:
 - :admin_superduper_forums should be []
 
-Finished in 5.097926 seconds
+Finished in 8.293483 seconds
 
-593 examples, 0 failures
+632 examples, 0 failures</diff>
      <filename>SPECDOC</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,7 @@ garlic do
   target '2.0-stable', :branch =&gt; 'origin/2-0-stable'
   target '2.1-stable', :branch =&gt; 'origin/2-1-stable'
   target '2.0.3', :tag =&gt; 'v2.0.3'
-  target '2.1.0', :tag =&gt; 'v2.1.0'
+  target '2.1.1', :tag =&gt; 'v2.1.1'
 
   all_targets do
     prepare do
@@ -36,8 +36,7 @@ garlic do
   
     run do
       cd &quot;vendor/plugins/resources_controller&quot; do
-        sh &quot;rake spec:rcov:verify&quot;
-        sh &quot;rake spec:generate&quot;
+        sh &quot;rake spec:rcov:verify &amp;&amp; rake spec:generate&quot;
       end
     end
   end</diff>
      <filename>garlic_example.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
 require 'ardes/resources_controller'
+ActionController::Base.extend Ardes::ResourcesController
 
-ActionController::Base.extend Ardes::ResourcesController
\ No newline at end of file
+require 'ardes/active_record/saved'
+ActiveRecord::Base.send :include, Ardes::ActiveRecord::Saved
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -665,18 +665,19 @@ module Ardes#:nodoc:
         @enclosing_collection_resources ||= []
       end
       
-      # Returns self.resource.save and caches the result for future calls.
-      # This is useful when you want to know outside of an action whether the resource was saved.
-      #
-      # Pass true to ignore the cached value
-      def resource_saved?(reload = false)
-        save_resource if reload || @resource_saved.nil?
-        @resource_saved
+      # Has the resource been saved successfully?
+      # If the record has not had validation attempted, it is saved.
+      # Returns true if the record is not new, and there are no errors
+      def resource_saved?
+        resource.save unless resource.validation_attempted?
+        resource.saved?
       end
       
+      # DEPRECATED: just use resource.save
       def save_resource
-        @resource_saved = resource.save
+        resource.save
       end
+      deprecate :save_resource =&gt; 'Use resource.save'
       
     private
       # returns the route that was used to invoke this controller and current action.  The path is found first from params[:resource_path]</diff>
      <filename>lib/ardes/resources_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -93,9 +93,9 @@ module Ardes#:nodoc:
       # POST /events.xml
       def create
         self.resource = new_resource
-
+        
         respond_to do |format|
-          if resource_saved?
+          if resource.save
             format.html do
               flash[:notice] = &quot;#{resource_name.humanize} was successfully created.&quot;
               redirect_to resource_url
@@ -114,10 +114,9 @@ module Ardes#:nodoc:
       # PUT /events/1.xml
       def update
         self.resource = find_resource
-        resource.attributes = params[resource_name]
-
+        
         respond_to do |format|
-          if resource_saved?
+          if resource.update_attributes(params[resource_name])
             format.html do
               flash[:notice] = &quot;#{resource_name.humanize} was successfully updated.&quot;
               redirect_to resource_url</diff>
      <filename>lib/ardes/resources_controller/actions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -156,12 +156,13 @@ class Post &lt; ActiveRecord::Base
 end
 
 class Comment &lt; ActiveRecord::Base
+  validates_presence_of :user, :post
+  
   belongs_to :user
   belongs_to :post
   has_many :tags, :as =&gt; :taggable
 end
 
-
 ##############
 # Controllers
 ##############</diff>
      <filename>spec/app.rb</filename>
    </modified>
    <modified>
      <diff>@@ -309,7 +309,7 @@ describe &quot;Requesting /users/dave/addresses/1 using PUT&quot; do
   end
 
   it &quot;should update the found address&quot; do
-    @address.should_receive(:attributes=)
+    @address.should_receive(:update_attributes).and_return(true)
     do_update
   end
 </diff>
      <filename>spec/controllers/addresses_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -522,7 +522,7 @@ describe &quot;Requesting /admin/forums/1 using PUT&quot; do
   end
 
   it &quot;should update the found forum&quot; do
-    @mock_forum.should_receive(:attributes=)
+    @mock_forum.should_receive(:update_attributes).and_return(true)
     do_update
     assigns(:forum).should == @mock_forum
   end
@@ -558,7 +558,7 @@ describe &quot;Requesting /admin/forums/1 using XHR PUT&quot; do
   end
 
   it &quot;should update the found forum&quot; do
-    @mock_forum.should_receive(:attributes=)
+    @mock_forum.should_receive(:update_attributes).and_return(true)
     do_update
     assigns(:forum).should == @mock_forum
   end
@@ -579,7 +579,7 @@ describe &quot;Requesting /admin/forums/1 using XHR PUT&quot; do
   end
   
   it &quot;should render edit.rjs, on unsuccessful save&quot; do
-    @mock_forum.stub!(:save).and_return(false)
+    @mock_forum.stub!(:update_attributes).and_return(false)
     do_update
     response.should render_template('edit')
   end</diff>
      <filename>spec/controllers/admin_forums_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -77,7 +77,7 @@ describe &quot;resource_service in CommentsController&quot; do
   before(:each) do
     @forum          = Forum.create
     @post           = Post.create :forum_id =&gt; @forum.id
-    @comment        = Comment.create :post_id =&gt; @post.id
+    @comment        = Comment.create :post_id =&gt; @post.id, :user =&gt; User.create
     @other_post     = Post.create :forum_id =&gt; @forum.id
     @other_comment  = Comment.create :post_id =&gt; @other_post.id
     
@@ -342,7 +342,7 @@ describe &quot;Requesting /forums/3/posts/3/comments/1 using PUT&quot; do
   end
 
   it &quot;should update the found comment&quot; do
-    @comment.should_receive(:attributes=)
+    @comment.should_receive(:update_attributes).and_return(true)
     do_update
   end
 </diff>
      <filename>spec/controllers/comments_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -395,7 +395,7 @@ describe &quot;Requesting /forums/2/posts/1 using PUT&quot; do
   end
 
   it &quot;should update the found post&quot; do
-    @post.should_receive(:attributes=)
+    @post.should_receive(:update_attributes)
     do_update
   end
 </diff>
      <filename>spec/controllers/forum_posts_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -599,7 +599,7 @@ describe &quot;Requesting /forums/1 using PUT&quot; do
   end
 
   it &quot;should update the found forum&quot; do
-    @mock_forum.should_receive(:attributes=)
+    @mock_forum.should_receive(:update_attributes)
     do_update
     assigns(:forum).should == @mock_forum
   end
@@ -635,7 +635,7 @@ describe &quot;Requesting /forums/1 using XHR PUT&quot; do
   end
 
   it &quot;should update the found forum&quot; do
-    @mock_forum.should_receive(:attributes=)
+    @mock_forum.should_receive(:update_attributes)
     do_update
     assigns(:forum).should == @mock_forum
   end
@@ -656,7 +656,7 @@ describe &quot;Requesting /forums/1 using XHR PUT&quot; do
   end
   
   it &quot;should render edit.rjs, on unsuccessful save&quot; do
-    @mock_forum.stub!(:save).and_return(false)
+    @mock_forum.stub!(:update_attributes).and_return(false)
     do_update
     response.should render_template('edit')
   end</diff>
      <filename>spec/controllers/forums_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,10 +52,9 @@ describe InfosController, &quot; (its actions)&quot; do
   end
   
   it &quot;PUT /account/info should be successful&quot; do
-    @info.stub!(:attributes=)
-    @info.stub!(:save)
+    @info.stub!(:update_attributes).and_return(true)
     put :update
-    response.should be_success
+    response.should be_redirect
   end
   
   it &quot;GET /account/info/new should raise UnknownAction&quot; do</diff>
      <filename>spec/controllers/infos_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -220,8 +220,7 @@ describe &quot;Requesting /forums/2/owner using PUT&quot; do
 
   before(:each) do
     setup_mocks
-    @owner.stub!(:save).and_return(true)
-    @owner.stub!(:attributes=)
+    @owner.stub!(:update_attributes).and_return(true)
   end
   
   def do_update
@@ -239,7 +238,7 @@ describe &quot;Requesting /forums/2/owner using PUT&quot; do
   end
 
   it &quot;should update the owner&quot; do
-    @owner.should_receive(:attributes=).with('name' =&gt; 'Fred')
+    @owner.should_receive(:update_attributes).with('name' =&gt; 'Fred')
     do_update
   end
 </diff>
      <filename>spec/controllers/owners_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -71,7 +71,7 @@ describe &quot;resource_service in TagsController via Forum, Post and Comment&quot; do
   before(:each) do
     @forum         = Forum.create
     @post          = Post.create :forum_id =&gt; @forum.id
-    @comment       = Comment.create :post_id =&gt; @post.id
+    @comment       = Comment.create :post_id =&gt; @post.id, :user =&gt; User.create!
     @tag           = Tag.create :taggable_id =&gt; @comment.id, :taggable_type =&gt; 'Comment'
     @other_comment = Comment.create :post_id =&gt; @forum.id
     @other_tag     = Tag.create :taggable_id =&gt; @other_comment.id, :taggable_type =&gt; 'Comment'</diff>
      <filename>spec/controllers/tags_controller_via_forum_post_comment_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -235,14 +235,12 @@ describe UsersController, &quot;handling PUT /users/dave&quot; do
   end
   
   def put_with_successful_update
-    @user.should_receive(:attributes=).once.ordered
-    @user.should_receive(:save).once.ordered.and_return(true)
+    @user.should_receive(:update_attributes).and_return(true)
     put :update, :id =&gt; &quot;dave&quot;
   end
   
   def put_with_failed_update
-    @user.should_receive(:attributes=).once.ordered
-    @user.should_receive(:save).once.ordered.and_return(false)
+    @user.should_receive(:update_attributes).and_return(false)
     put :update, :id =&gt; &quot;dave&quot;
   end
   </diff>
      <filename>spec/controllers/users_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,4 +40,18 @@ describe &quot;A controller's resource_service&quot; do
     @controller.resource_service = 'foo'
     @controller.resource_service.should == 'foo'
   end
+end
+
+describe &quot;deprecated methods&quot; do
+  before do 
+    @controller = ForumsController.new
+    @controller.resource = Forum.new
+  end
+  
+  it &quot;#save_resource should send resource.save&quot; do
+    ActiveSupport::Deprecation.silence do
+      @controller.resource.should_receive :save
+      @controller.save_resource
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/specs/resources_controller_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c21f35c35ef71576c99d412bc562ab10278c652b</id>
    </parent>
  </parents>
  <author>
    <name>Ian White</name>
    <email>ian.w.white@gmail.com</email>
  </author>
  <url>http://github.com/ianwhite/resources_controller/commit/ceaf1b96a2ac9eb82250307029f36aed063326e0</url>
  <id>ceaf1b96a2ac9eb82250307029f36aed063326e0</id>
  <committed-date>2008-09-13T12:35:48-07:00</committed-date>
  <authored-date>2008-09-13T12:31:16-07:00</authored-date>
  <message>The reason for the reversion in c21f35c has been fixed.  Thanks Jason Lee for the bug report.

The problem was that I had changed resource_saved?'s behaviour to *not* saving the model if it had
already been saved.  In the future resource_saved? will be deprecated, but not yet.

BTW.  All of these changes to resource_saved? behaviour is aimed at making RC drop in compatible with
rspec's generated controller specs (try rake spec:generate).

To do that I need the default update action to use :update_attributes. This meant that the old strategy
of keeping track of saves by using save_resource wont work.  Instead, we keep track by looking at the
AR's state (see lib/ardes/active_record/saved.rb) which is a far better solution anyway.

Squashed commit of the following:

commit f8a589f9b3711140fa7e125a42681acc1ad97e10
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sun Sep 14 05:21:23 2008 +1000

    Docfixes, CHANGELOG, SPECDOC

commit e670fd2e18678d94292bc684e57f8bf64a2e2dc9
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sun Sep 14 05:09:24 2008 +1000

    Fixed logic error in AR.saved?

commit b3e2838e1515503820e49eaf7853099df33a0d8e
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sun Sep 14 05:05:29 2008 +1000

    Adding specs for AR.saved? and AR.validation_attempted?

commit 3e649c53d06a788b5e70878b2cb7e386571fce31
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sun Sep 14 04:56:56 2008 +1000

    Fixed bug in init.rb

commit c72b1a917339b7ee94700d8eb6b6bd939ad7e4b2
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sun Sep 14 04:56:28 2008 +1000

    Fixed bug in init.rb

commit d5702c06d8d54b80dd011f79ff3d2ac782ce902e
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sun Sep 14 04:55:18 2008 +1000

    Added AR.saved? &amp; AR.validation_atempted? convenience methods.  Returned save_resource?'s behaviour to that of saving the record if it has not had save attempted

commit af11af7848811da5ca87efdd8eb678251c5bd6d5
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 09:58:15 2008 +1000

    Added resource_saved? specs, and removed .first and .last for BC in specs to 2.0.x

commit 5efb59f7c0fb8be72b12b5476291e59e6af658c0
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 09:57:30 2008 +1000

    Added resource_saved? specs, and removed .first and .last for BC in specs to 2.0.x

commit 8b73130de97ab87369ec395be4ee696de76e773a
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 09:46:52 2008 +1000

    Small fix for comments_with_models spec

commit 3a2426cd00fa945d155d4f3ebff6ccc48a7b0cf2
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 09:29:26 2008 +1000

    Added specs for comments_controller which use real DB objects

commit 79a93132f6e49a556775e6508a5773686ccd6332
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 06:27:51 2008 +1000

    Fixing comments with models spec

commit 05f551f5755e6db41a83dde0c9b0db99a4e168d8
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 06:24:19 2008 +1000

    Added some controller specs with real models

commit 6163aba8c5315598d173cd205bc2d69286ae4271
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 06:02:36 2008 +1000

    Updated 2.1.x target

commit b3c6d13a77aff7d831e136221ead8b7fa7bed4e1
Author: Ian White &lt;ian.w.white@gmail.com&gt;
Date:   Sat Sep 13 04:54:40 2008 +1000

    Add resource_saved stuff back in (2f49687, 7423cf1)

    This reverts commit c21f35c35ef71576c99d412bc562ab10278c652b.</message>
  <tree>cb74ae8c084cf0158d83259b50e76c32ae45ecfa</tree>
  <committer>
    <name>Ian White</name>
    <email>ian.w.white@gmail.com</email>
  </committer>
</commit>
