public
Description: resources_controller rails plugin: rc makes RESTful controllers fun
Homepage: http://plugins.ardes.com/doc/resources_controller
Clone URL: git://github.com/ianwhite/resources_controller.git
Click here to lend your support to: resources_controller and make a donation at www.pledgie.com !
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 <ian.w.white@gmail.com>
Date:   Sun Sep 14 05:21:23 2008 +1000

    Docfixes, CHANGELOG, SPECDOC

commit e670fd2e18678d94292bc684e57f8bf64a2e2dc9
Author: Ian White <ian.w.white@gmail.com>
Date:   Sun Sep 14 05:09:24 2008 +1000

    Fixed logic error in AR.saved?

commit b3e2838e1515503820e49eaf7853099df33a0d8e
Author: Ian White <ian.w.white@gmail.com>
Date:   Sun Sep 14 05:05:29 2008 +1000

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

commit 3e649c53d06a788b5e70878b2cb7e386571fce31
Author: Ian White <ian.w.white@gmail.com>
Date:   Sun Sep 14 04:56:56 2008 +1000

    Fixed bug in init.rb

commit c72b1a917339b7ee94700d8eb6b6bd939ad7e4b2
Author: Ian White <ian.w.white@gmail.com>
Date:   Sun Sep 14 04:56:28 2008 +1000

    Fixed bug in init.rb

commit d5702c06d8d54b80dd011f79ff3d2ac782ce902e
Author: Ian White <ian.w.white@gmail.com>
Date:   Sun Sep 14 04:55:18 2008 +1000

    Added AR.saved? & 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 <ian.w.white@gmail.com>
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 <ian.w.white@gmail.com>
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 <ian.w.white@gmail.com>
Date:   Sat Sep 13 09:46:52 2008 +1000

    Small fix for comments_with_models spec

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

    Added specs for comments_controller which use real DB objects

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

    Fixing comments with models spec

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

    Added some controller specs with real models

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

    Updated 2.1.x target

commit b3c6d13a77aff7d831e136221ead8b7fa7bed4e1
Author: Ian White <ian.w.white@gmail.com>
Date:   Sat Sep 13 04:54:40 2008 +1000

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

    This reverts commit c21f35c35ef71576c99d412bc562ab10278c652b.
ianwhite (author)
Sat Sep 13 12:31:16 -0700 2008
commit  ceaf1b96a2ac9eb82250307029f36aed063326e0
tree    cb74ae8c084cf0158d83259b50e76c32ae45ecfa
parent  c21f35c35ef71576c99d412bc562ab10278c652b
...
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
0
@@ -1,3 +1,8 @@
0
+* API change: save_resource deprecated
0
+
0
+  So save_resource is now deprecated, just use resource.save
0
+  ActiveRecords can now be asked if they are saved?
0
+  
0
 * rspec compat:  Added new rake task to test that an RC controller passes the default rspec_scaffold
0
   controller specs.
0
 
...
14
15
16
 
17
18
19
...
14
15
16
17
18
19
20
0
@@ -14,6 +14,7 @@ resources_controller works with rails 2.x and edge.
0
 
0
 * The SPECDOC lists the specifications
0
 * Coverage is 100% (C0), and the spec suite is quite comprehensive
0
+* Rspec's generated rspec_scaffold controller specs are tested against a simple rc controller (see rake spec:generate)
0
 
0
 RSpec is used for testing, so the tests are in <tt>spec/</tt> rather than
0
 <tt>test/</tt> Do rake --tasks for more details.
...
60
61
62
63
 
64
65
66
...
60
61
62
 
63
64
65
66
0
@@ -60,7 +60,7 @@ Rake::RDocTask.new(:doc) do |t|
0
   t.title    = "#{plugin_name}"
0
   t.template = ENV['RDOC_TEMPLATE']
0
   t.options  = ['--line-numbers', '--inline-source', '--all']
0
-  t.rdoc_files.include('README', 'SPECDOC', 'MIT-LICENSE', 'CHANGELOG')
0
+  t.rdoc_files.include('README.rdoc', 'SPECDOC', 'MIT-LICENSE', 'CHANGELOG')
0
   t.rdoc_files.include('lib/**/*.rb')
0
 end
0
 
...
256
257
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
260
261
...
575
576
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
579
580
...
768
769
770
 
 
 
 
 
 
 
 
 
 
 
 
771
772
773
...
792
793
794
795
796
797
798
799
800
801
802
803
...
839
840
841
 
 
 
 
 
 
842
843
844
...
849
850
851
 
 
 
852
853
854
...
870
871
872
873
 
874
875
 
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
...
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
...
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
...
870
871
872
 
 
 
 
 
 
873
874
875
...
911
912
913
914
915
916
917
918
919
920
921
922
...
927
928
929
930
931
932
933
934
935
...
951
952
953
 
954
955
 
956
0
@@ -256,6 +256,53 @@ Requesting /forums/3/posts/3/comments/1 using DELETE
0
 - should call destroy on the found comment
0
 - should redirect to the comments list
0
 
0
+CommentsController without stubs responding to GET index
0
+- should expose all comments as @comments
0
+
0
+CommentsController without stubs responding to GET index with mime type of xml
0
+- should render all comments as xml
0
+
0
+CommentsController without stubs responding to GET show
0
+- should expose the requested comment as @comment
0
+
0
+CommentsController without stubs responding to GET show with mime type of xml
0
+- should render the requested comment as xml
0
+
0
+CommentsController without stubs responding to GET new
0
+- should expose a new comment as @comment
0
+
0
+CommentsController without stubs responding to GET edit
0
+- should expose the requested comment as @comment
0
+
0
+CommentsController without stubs responding to POST create with valid params
0
+- should create a comment
0
+- should expose the newly created comment as @comment
0
+- should be resource_saved?
0
+- should redirect to the created comment
0
+
0
+CommentsController without stubs responding to POST create with invalid params
0
+- should not create a comment
0
+- should expose a newly created but unsaved comment as @comment
0
+- should not be resource_saved?
0
+- should re-render the 'new' template
0
+
0
+CommentsController without stubs responding to PUT udpate with valid params
0
+- should update the requested comment
0
+- should not contain errors on comment
0
+- should be resource_saved?
0
+- should expose the requested comment as @comment
0
+- should redirect to the comment
0
+
0
+CommentsController without stubs responding to PUT udpate with invalid params
0
+- should fail to update the requested comment
0
+- should not be resource_saved?
0
+- should expose the requested comment as @comment
0
+- should re-render the 'edit' template
0
+
0
+CommentsController without stubs responding to DELETE destroy
0
+- should delete the requested comment
0
+- should redirect to the comments list
0
+
0
 Routing shortcuts for ForumPosts (forums/2/posts/1) should map
0
 - resources_path to /forums/2/posts
0
 - resource_path to /forums/2/posts/1
0
@@ -575,6 +622,25 @@ Requesting /forums/2/owner using DELETE
0
 - should set the flash notice
0
 - should redirect to forums/2
0
 
0
+CommentsController#resource_saved Comment.new(<invalid attrs>)
0
+- should not be resource saved
0
+
0
+CommentsController#resource_saved Comment.new(<invalid attrs>).save
0
+- should not be resource saved
0
+
0
+CommentsController#resource_saved Comment.new(<invalid attrs>).save then update_attributes(<valid attrs>)
0
+- should be resource saved
0
+
0
+CommentsController#resource_saved Comment.find(<id>)
0
+- should be resource saved
0
+- .save should be saved
0
+
0
+CommentsController#resource_saved Comment.find(<id>) then update_attributes(<invalid attrs>)
0
+- should not be resource saved
0
+
0
+CommentsController#resource_saved Comment.find(<id>) then update_attributes(<new valid attrs>)
0
+- should be resource saved
0
+
0
 Routing shortcuts for Tags should map
0
 - resources_path to /tags
0
 - resource_path to /tags/2
0
@@ -768,6 +834,18 @@ UsersController handling PUT /users/dave
0
 UsersController handling DELETE /users/dave
0
 - should be unknown action
0
 
0
+(re: saved?) Comment.new(<invalid attrs>)
0
+- should not be validation attempted
0
+- should not be saved
0
+
0
+(re: saved?) Comment.new(<invalid attrs>).save
0
+- should be validation attempted
0
+- should not be saved
0
+
0
+(re: saved?) Comment.new(<invalid attrs>).save then update_attributes(<valid attrs>)
0
+- should be validation attempted
0
+- should be saved
0
+
0
 ActionView with resources_controller Helper
0
 - should forward #resource_name to controller
0
 - should forward #resources_name to controller
0
@@ -792,12 +870,6 @@ Helper#form_for_resource (when resource is existing record)
0
 Helper#remote_form_for_resource (when resource is existing record)
0
 - should call remote_form_for with update form options
0
 
0
-ResourcesController.load_enclosing_resources_filter_exists? when :find_filter defined
0
-- should call :find_filter with :load_enclosing_resources
0
-
0
-ResourcesController.load_enclosing_resources_filter_exists? when :find_filter not defined
0
-- should call :filter_chain
0
-
0
 #load_enclosing_resources for resources_controller_for :tags (when route_enclosing_names is [['users', false]])
0
 - should call load_wildcard once
0
 - should call Specification.new('user', :singleton => false, :as => nil)
0
@@ -839,6 +911,12 @@ ResourcesController.load_enclosing_resources_filter_exists? when :find_filter no
0
 - should call load_enclosing_resource_from_specification with user spec, then load_wildcard once with 'taggable'
0
 - should call Specification.new with ('comment', :singleton => false, :as => 'taggable')
0
 
0
+ResourcesController.load_enclosing_resources_filter_exists? when :find_filter defined
0
+- should call :find_filter with :load_enclosing_resources
0
+
0
+ResourcesController.load_enclosing_resources_filter_exists? when :find_filter not defined
0
+- should call :filter_chain
0
+
0
 ResourcesController (in general)
0
 - nested_in :foo, :polymorphic => true, :class => User should raise argument error (no options or block with polymorphic)
0
 - resources_controller_for :forums, :in => [:user, '*', '*', :comment] should raise argument error (no multiple wildcards in a row)
0
@@ -849,6 +927,9 @@ ResourcesController#enclosing_resource_name
0
 A controller's resource_service
0
 - may be explicitly set with #resource_service=
0
 
0
+deprecated methods
0
+- #save_resource should send resource.save
0
+
0
 #route_enclosing_names TagsController for named_route:
0
 - :tags should be []
0
 - :new_tag should be []
0
@@ -870,6 +951,6 @@ A controller's resource_service
0
 #route_enclosing_names Admin::Superduper::ForumsController for named_route:
0
 - :admin_superduper_forums should be []
0
 
0
-Finished in 5.097926 seconds
0
+Finished in 8.293483 seconds
0
 
0
-593 examples, 0 failures
0
+632 examples, 0 failures
...
23
24
25
26
 
27
28
29
...
36
37
38
39
40
 
41
42
43
...
23
24
25
 
26
27
28
29
...
36
37
38
 
 
39
40
41
42
0
@@ -23,7 +23,7 @@ garlic do
0
   target '2.0-stable', :branch => 'origin/2-0-stable'
0
   target '2.1-stable', :branch => 'origin/2-1-stable'
0
   target '2.0.3', :tag => 'v2.0.3'
0
-  target '2.1.0', :tag => 'v2.1.0'
0
+  target '2.1.1', :tag => 'v2.1.1'
0
 
0
   all_targets do
0
     prepare do
0
@@ -36,8 +36,7 @@ garlic do
0
   
0
     run do
0
       cd "vendor/plugins/resources_controller" do
0
-        sh "rake spec:rcov:verify"
0
-        sh "rake spec:generate"
0
+        sh "rake spec:rcov:verify && rake spec:generate"
0
       end
0
     end
0
   end
...
1
 
2
3
4
 
 
5
...
1
2
3
 
4
5
6
7
0
@@ -1,3 +1,5 @@
0
 require 'ardes/resources_controller'
0
+ActionController::Base.extend Ardes::ResourcesController
0
 
0
-ActionController::Base.extend Ardes::ResourcesController
0
\ No newline at end of file
0
+require 'ardes/active_record/saved'
0
+ActiveRecord::Base.send :include, Ardes::ActiveRecord::Saved
0
\ No newline at end of file
...
665
666
667
668
669
670
671
672
673
674
 
 
 
 
 
 
675
676
 
677
678
 
679
 
680
681
682
...
665
666
667
 
 
 
 
 
 
 
668
669
670
671
672
673
674
675
676
677
 
678
679
680
681
682
683
0
@@ -665,18 +665,19 @@ module Ardes#:nodoc:
0
         @enclosing_collection_resources ||= []
0
       end
0
       
0
-      # Returns self.resource.save and caches the result for future calls.
0
-      # This is useful when you want to know outside of an action whether the resource was saved.
0
-      #
0
-      # Pass true to ignore the cached value
0
-      def resource_saved?(reload = false)
0
-        save_resource if reload || @resource_saved.nil?
0
-        @resource_saved
0
+      # Has the resource been saved successfully?
0
+      # If the record has not had validation attempted, it is saved.
0
+      # Returns true if the record is not new, and there are no errors
0
+      def resource_saved?
0
+        resource.save unless resource.validation_attempted?
0
+        resource.saved?
0
       end
0
       
0
+      # DEPRECATED: just use resource.save
0
       def save_resource
0
-        @resource_saved = resource.save
0
+        resource.save
0
       end
0
+      deprecate :save_resource => 'Use resource.save'
0
       
0
     private
0
       # returns the route that was used to invoke this controller and current action.  The path is found first from params[:resource_path]
...
93
94
95
96
 
97
98
 
99
100
101
...
114
115
116
117
118
 
119
120
 
121
122
123
...
93
94
95
 
96
97
 
98
99
100
101
...
114
115
116
 
 
117
118
 
119
120
121
122
0
@@ -93,9 +93,9 @@ module Ardes#:nodoc:
0
       # POST /events.xml
0
       def create
0
         self.resource = new_resource
0
-
0
+        
0
         respond_to do |format|
0
-          if resource_saved?
0
+          if resource.save
0
             format.html do
0
               flash[:notice] = "#{resource_name.humanize} was successfully created."
0
               redirect_to resource_url
0
@@ -114,10 +114,9 @@ module Ardes#:nodoc:
0
       # PUT /events/1.xml
0
       def update
0
         self.resource = find_resource
0
-        resource.attributes = params[resource_name]
0
-
0
+        
0
         respond_to do |format|
0
-          if resource_saved?
0
+          if resource.update_attributes(params[resource_name])
0
             format.html do
0
               flash[:notice] = "#{resource_name.humanize} was successfully updated."
0
               redirect_to resource_url
...
156
157
158
 
 
159
160
161
162
163
164
165
166
167
...
156
157
158
159
160
161
162
163
164
165
 
166
167
168
0
@@ -156,12 +156,13 @@ class Post < ActiveRecord::Base
0
 end
0
 
0
 class Comment < ActiveRecord::Base
0
+  validates_presence_of :user, :post
0
+  
0
   belongs_to :user
0
   belongs_to :post
0
   has_many :tags, :as => :taggable
0
 end
0
 
0
-
0
 ##############
0
 # Controllers
0
 ##############
...
309
310
311
312
 
313
314
315
...
309
310
311
 
312
313
314
315
0
@@ -309,7 +309,7 @@ describe "Requesting /users/dave/addresses/1 using PUT" do
0
   end
0
 
0
   it "should update the found address" do
0
-    @address.should_receive(:attributes=)
0
+    @address.should_receive(:update_attributes).and_return(true)
0
     do_update
0
   end
0
 
...
522
523
524
525
 
526
527
528
...
558
559
560
561
 
562
563
564
...
579
580
581
582
 
583
584
585
...
522
523
524
 
525
526
527
528
...
558
559
560
 
561
562
563
564
...
579
580
581
 
582
583
584
585
0
@@ -522,7 +522,7 @@ describe "Requesting /admin/forums/1 using PUT" do
0
   end
0
 
0
   it "should update the found forum" do
0
-    @mock_forum.should_receive(:attributes=)
0
+    @mock_forum.should_receive(:update_attributes).and_return(true)
0
     do_update
0
     assigns(:forum).should == @mock_forum
0
   end
0
@@ -558,7 +558,7 @@ describe "Requesting /admin/forums/1 using XHR PUT" do
0
   end
0
 
0
   it "should update the found forum" do
0
-    @mock_forum.should_receive(:attributes=)
0
+    @mock_forum.should_receive(:update_attributes).and_return(true)
0
     do_update
0
     assigns(:forum).should == @mock_forum
0
   end
0
@@ -579,7 +579,7 @@ describe "Requesting /admin/forums/1 using XHR PUT" do
0
   end
0
   
0
   it "should render edit.rjs, on unsuccessful save" do
0
-    @mock_forum.stub!(:save).and_return(false)
0
+    @mock_forum.stub!(:update_attributes).and_return(false)
0
     do_update
0
     response.should render_template('edit')
0
   end
...
77
78
79
80
 
81
82
83
...
342
343
344
345
 
346
347
348
...
77
78
79
 
80
81
82
83
...
342
343
344
 
345
346
347
348
0
@@ -77,7 +77,7 @@ describe "resource_service in CommentsController" do
0
   before(:each) do
0
     @forum          = Forum.create
0
     @post           = Post.create :forum_id => @forum.id
0
-    @comment        = Comment.create :post_id => @post.id
0
+    @comment        = Comment.create :post_id => @post.id, :user => User.create
0
     @other_post     = Post.create :forum_id => @forum.id
0
     @other_comment  = Comment.create :post_id => @other_post.id
0
     
0
@@ -342,7 +342,7 @@ describe "Requesting /forums/3/posts/3/comments/1 using PUT" do
0
   end
0
 
0
   it "should update the found comment" do
0
-    @comment.should_receive(:attributes=)
0
+    @comment.should_receive(:update_attributes).and_return(true)
0
     do_update
0
   end
0
 
...
395
396
397
398
 
399
400
401
...
395
396
397
 
398
399
400
401
0
@@ -395,7 +395,7 @@ describe "Requesting /forums/2/posts/1 using PUT" do
0
   end
0
 
0
   it "should update the found post" do
0
-    @post.should_receive(:attributes=)
0
+    @post.should_receive(:update_attributes)
0
     do_update
0
   end
0
 
...
599
600
601
602
 
603
604
605
...
635
636
637
638
 
639
640
641
...
656
657
658
659
 
660
661
662
...
599
600
601
 
602
603
604
605
...
635
636
637
 
638
639
640
641
...
656
657
658
 
659
660
661
662
0
@@ -599,7 +599,7 @@ describe "Requesting /forums/1 using PUT" do
0
   end
0
 
0
   it "should update the found forum" do
0
-    @mock_forum.should_receive(:attributes=)
0
+    @mock_forum.should_receive(:update_attributes)
0
     do_update
0
     assigns(:forum).should == @mock_forum
0
   end
0
@@ -635,7 +635,7 @@ describe "Requesting /forums/1 using XHR PUT" do
0
   end
0
 
0
   it "should update the found forum" do
0
-    @mock_forum.should_receive(:attributes=)
0
+    @mock_forum.should_receive(:update_attributes)
0
     do_update
0
     assigns(:forum).should == @mock_forum
0
   end
0
@@ -656,7 +656,7 @@ describe "Requesting /forums/1 using XHR PUT" do
0
   end
0
   
0
   it "should render edit.rjs, on unsuccessful save" do
0
-    @mock_forum.stub!(:save).and_return(false)
0
+    @mock_forum.stub!(:update_attributes).and_return(false)
0
     do_update
0
     response.should render_template('edit')
0
   end
...
52
53
54
55
56
 
57
58
 
59
60
61
...
52
53
54
 
 
55
56
 
57
58
59
60
0
@@ -52,10 +52,9 @@ describe InfosController, " (its actions)" do
0
   end
0
   
0
   it "PUT /account/info should be successful" do
0
-    @info.stub!(:attributes=)
0
-    @info.stub!(:save)
0
+    @info.stub!(:update_attributes).and_return(true)
0
     put :update
0
-    response.should be_success
0
+    response.should be_redirect
0
   end
0
   
0
   it "GET /account/info/new should raise UnknownAction" do
...
220
221
222
223
224
 
225
226
227
...
239
240
241
242
 
243
244
245
...
220
221
222
 
 
223
224
225
226
...
238
239
240
 
241
242
243
244
0
@@ -220,8 +220,7 @@ describe "Requesting /forums/2/owner using PUT" do
0
 
0
   before(:each) do
0
     setup_mocks
0
-    @owner.stub!(:save).and_return(true)
0
-    @owner.stub!(:attributes=)
0
+    @owner.stub!(:update_attributes).and_return(true)
0
   end
0
   
0
   def do_update
0
@@ -239,7 +238,7 @@ describe "Requesting /forums/2/owner using PUT" do
0
   end
0
 
0
   it "should update the owner" do
0
-    @owner.should_receive(:attributes=).with('name' => 'Fred')
0
+    @owner.should_receive(:update_attributes).with('name' => 'Fred')
0
     do_update
0
   end
0
 
...
71
72
73
74
 
75
76
77
...
71
72
73
 
74
75
76
77
0
@@ -71,7 +71,7 @@ describe "resource_service in TagsController via Forum, Post and Comment" do
0
   before(:each) do
0
     @forum         = Forum.create
0
     @post          = Post.create :forum_id => @forum.id
0
-    @comment       = Comment.create :post_id => @post.id
0
+    @comment       = Comment.create :post_id => @post.id, :user => User.create!
0
     @tag           = Tag.create :taggable_id => @comment.id, :taggable_type => 'Comment'
0
     @other_comment = Comment.create :post_id => @forum.id
0
     @other_tag     = Tag.create :taggable_id => @other_comment.id, :taggable_type => 'Comment'
...
235
236
237
238
239
 
240
241
242
243
244
245
 
246
247
248
...
235
236
237
 
 
238
239
240
241
242
 
 
243
244
245
246
0
@@ -235,14 +235,12 @@ describe UsersController, "handling PUT /users/dave" do
0
   end
0
   
0
   def put_with_successful_update
0
-    @user.should_receive(:attributes=).once.ordered
0
-    @user.should_receive(:save).once.ordered.and_return(true)
0
+    @user.should_receive(:update_attributes).and_return(true)
0
     put :update, :id => "dave"
0
   end
0
   
0
   def put_with_failed_update
0
-    @user.should_receive(:attributes=).once.ordered
0
-    @user.should_receive(:save).once.ordered.and_return(false)
0
+    @user.should_receive(:update_attributes).and_return(false)
0
     put :update, :id => "dave"
0
   end
0
   
...
40
41
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
44
...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
0
@@ -40,4 +40,18 @@ describe "A controller's resource_service" do
0
     @controller.resource_service = 'foo'
0
     @controller.resource_service.should == 'foo'
0
   end
0
+end
0
+
0
+describe "deprecated methods" do
0
+  before do 
0
+    @controller = ForumsController.new
0
+    @controller.resource = Forum.new
0
+  end
0
+  
0
+  it "#save_resource should send resource.save" do
0
+    ActiveSupport::Deprecation.silence do
0
+      @controller.resource.should_receive :save
0
+      @controller.save_resource
0
+    end
0
+  end
0
 end
0
\ No newline at end of file

Comments