Forum: Ruby on Rails Passing object parameters to urls in tests

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Vahagn H. (Guest)
on 2008-11-16 15:29
I am wondering how to pass parameters to route declarations. I have an
app where one project belongs to a user. In one of my integration tests,
I want to check that the template being rendered is the one where the
"logged in user" can register a project:

get new_user_project_path(:user) #does not work
#assert_template '/users/:id/project/new' #id must be this user's id,
assert_template 'projects/new' #true, but must be /user/:id/project/new

rake routes says:

POST   /users/:user_id/project
{:action=>"create", :controller=>"projects"}

new_user_project GET   /users/:user_id/project/new
{:action=>"new", :controller=>"projects"}

This topic is locked and can not be replied to.