Rspec nested resource.

0 views
Skip to first unread message

Mathieu Rousseau

unread,
Apr 28, 2009, 12:10:17 AM4/28/09
to resource_...@googlegroups.com
Hello, 

I have a user resource and a task resource. a task belongs to a user and user has many tasks.
I'm using rspec and resource_controller created a bunch of tests automatically.
My route looks like this:
map.resources :users, :has_many => :tasks

And so the tests in my tasks_routing_spec.rb broke. I changed them FROM :
    it "should map { :controller => 'tasks', :action => 'show', :id => '1'} to /tasks/1" do
      route_for(:controller => "tasks", :action => "show", :id => "1").should == "/tasks/1"
    end

TO:

    it "should map { :controller => 'tasks', :action => 'show', :id => '1', :user_id => '1'} to /users/1/tasks/1" do
      route_for(:controller => "tasks", :action => "show", :id => "1", :user_id => "1").should == "/users/1/tasks/1"
    end

I'm doing this manually and I'd like to know if there is a "better"/"automatic" way to do this?

Thanks
Reply all
Reply to author
Forward
0 new messages