Latest changes to RC:

0 views
Skip to first unread message

Ian White

unread,
Sep 19, 2009, 3:47:02 PM9/19/09
to resources_controller
Hi people,

Driven by the issue that tomtt reported on this list, I have made some
changes to RC under the hood.

From the changelog:

RC no longer uses the route that invoked the controller to figure out
wildcard enclosing resources.
this change means that you will no longer get those pesky
'NoRecognizedRoute' errors when your controller is invoked by another
route, such as a :controller/:action/:id route.

My quick and dirty tests show that this change makes RC a bit quicker.

It also means that RC is a lot more relaxed about how it gets invoked.

(All of the above only applies to RC's automatic loading of enclosing
resources.)

For your tests, if you want to test that a controller is invoked using
a particular path, then you can just stub :request_path on the
controller.

Here's an example:

routes.rb

map.resources :posts
map.resource :account, :has_many => :posts

Let's say you want to test the case where PostsController is invoked
in the nesting account context. You would do this:

@controller.stub!(:request_path).and_return('/account/posts/1')
get :show, :id => 1
# test that the @posts assoc is grabbed from @account.psosts


Any questions, probs, let me know

CHeers,
Ian
Reply all
Reply to author
Forward
0 new messages