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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
242dfb8324501cb3b020625639044377?d=identicon&s=25 Vahagn Hayrapetyan (vahagn)
on 2008-11-16 14: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,
how?
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"}

Thanks,
Vahagn
This topic is locked and can not be replied to.