<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/ardes/active_record/saved.rb</filename>
    </added>
    <added>
      <filename>spec/models/comment_saved_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,11 @@
+* API change: save_resource and resource_saved? deprecated
+
+  ActiveRecord::Base now has a saved? and attempted_save? method, which makes response_for much easier
+  to write, and leaves less artefacts in the controller instance.
+  
+  So save_resource, and resource_saved? are now deprecated, just use resource.save, and resource.saved?
+  instead.  See response_for_resources_controller if you're into response_for.
+  
 * 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>@@ -13,6 +13,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>@@ -768,6 +768,26 @@ 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 attempted save
+- should not be saved
+
+(re: saved?) Comment.new(&lt;invalid attrs&gt;).save
+- should be attempted save
+- should not be saved
+
+(re: saved?) Comment.new(&lt;invalid attrs&gt;).save then update_attributes(&lt;valid attrs&gt;)
+- should be attempted save
+- should be saved
+
+(re: saved?) Comment.new(&lt;invalid attrs&gt;).save then update_attributes(&lt;valid attrs&gt;).reload
+- should not be attempted save
+- should not be saved
+
+(re: saved?) Comment.new(&lt;invalid attrs&gt;).save then update_attributes(&lt;valid attrs&gt;).reload.save
+- should be attempted save
+- should be saved
+
 ActionView with resources_controller Helper
 - should forward #resource_name to controller
 - should forward #resources_name to controller
@@ -792,12 +812,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 +853,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 +869,10 @@ ResourcesController#enclosing_resource_name
 A controller's resource_service
 - may be explicitly set with #resource_service=
 
+deprecated methods
+- #save_resource should send resource.save
+- #resource_saved? should send resource.saved?
+
 #route_enclosing_names TagsController for named_route:
 - :tags should be []
 - :new_tag should be []
@@ -870,6 +894,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.867688 seconds
 
-593 examples, 0 failures
+605 examples, 0 failures</diff>
      <filename>SPECDOC</filename>
    </modified>
    <modified>
      <diff>@@ -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'
+require 'ardes/active_record/saved'
+ActiveRecord::Base.send :include, Ardes::ActiveRecord::Saved
 
-ActionController::Base.extend Ardes::ResourcesController
\ No newline at end of file
+require 'ardes/resources_controller'
+ActionController::Base.extend Ardes::ResourcesController</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -665,18 +665,23 @@ module Ardes#:nodoc:
         @enclosing_collection_resources ||= []
       end
       
+      # DEPRECATED: just use resource.saved?
+      #
       # 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
+        resource.save unless resource.attempted_save?
+        resource.saved?
       end
+      deprecate :resource_saved? =&gt; 'Use resource.saved?'
       
+      # 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,25 @@ 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
+  
+  it &quot;#resource_saved? should send resource.saved?&quot; do
+    ActiveSupport::Deprecation.silence do
+      @controller.resource.should_receive(:saved?)
+      @controller.resource_saved?
+    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>633fe459e681a3dd3c24434d431ef4f0600b45eb</id>
    </parent>
  </parents>
  <author>
    <name>Ian White</name>
    <email>ian.w.white@gmail.com</email>
  </author>
  <url>http://github.com/ianwhite/resources_controller/commit/2f496874436e334346d4b0d8029a055c6821c93b</url>
  <id>2f496874436e334346d4b0d8029a055c6821c93b</id>
  <committed-date>2008-09-08T03:46:15-07:00</committed-date>
  <authored-date>2008-09-08T03:46:15-07:00</authored-date>
  <message>API change: save_resource and resource_saved? deprecated

  ActiveRecord::Base now has a saved? and attempted_save? method, which makes response_for much easier
  to write, and leaves less artefacts in the controller instance.

  So save_resource, and resource_saved? are now deprecated, just use resource.save, and resource.saved?
  instead.  See response_for_resources_controller if you're into response_for.</message>
  <tree>502fe0e15d5956c4aa2ff9f2bb869d86e7116540</tree>
  <committer>
    <name>Ian White</name>
    <email>ian.w.white@gmail.com</email>
  </committer>
</commit>
