small medium large xlarge

Generic-user-small
09 Nov 2007, 03:15
Bill Barnard (4 posts)

I’m trying out the RESTful ideas from Chap. 20. I wanted to see whether the unit test ideas would work with the nested comment resources (inside the articles) to be sure I understood both the routing & testing issues. Testing the articles_controller routing works as expected, but the comments_controller routing does not.

For example (inside a Test::Unit::TestCase):

assert_recognizes({ :controller => "comments", :action => "create",
                    :article_id => "1"},
                  { :path => "/articles/1/comments", :method => "post"})

passes as expected, but

assert_recognizes({ :controller => "commments", :action => "edit",
                    :article_id => "1", :id => "99"},
                  { :path => "/articles/1/commments/99;edit"})

fails with:

ActionController::RoutingError: no route found to match "/articles/1/commments/99;edit" with {:method=>:get}

Perhaps assert_recognizes does not know how to handle the nested resources?

You must be logged in to comment