I have googled and browsed through spec-users archives, but didn''t find anything different. I used rspec scaffold command to generate a mvc for groups, I used nested controller so I could have a separate interface for admin. the specs are the same as generated, so I won''t post the whole thing. I did put the nested routes names on the calls to the name routes: it "should redirect to the new group on successful save" do post_with_successful_save response.should redirect_to(admin_group_url("1")) end the error: 1) ''Admin::GroupsController handling POST /admin/groups should redirect to the new group on successful save'' FAILED expected redirect to "http://test.host/admin/groups/1", got redirect to "http:// test.host/groups/1" ./spec/controllers/admin/groups_controller_spec.rb:246: test log: Processing GroupsController#update (for 0.0.0.0 at 2007-10-27 21:53:44) [PUT] Session ID: Parameters: {"action"=>"update", "id"=>"1", "controller"=>"admin/groups"} Redirected to http://test.host/groups/1 Completed in 0.00061 (1647 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://test.host/admin/groups/1] it get redirected to http://test.host/groups/1 instead of admin/groups/1 It does work in the interface, which makes me believe that its not in rails but something in rspec: dev log: Processing GroupsController#create (for 127.0.0.1 at 2007-10-27 22:04:00) [POST] Session ID: 082b2f0103579493d5aa2a2851b4e721 Parameters: {"commit"=>"Create", "action"=>"create", "controller"=>"admin/groups", "group"=>{...}} SQL (0.000337) INSERT INTO groups (...) Redirected to http://127.0.0.1:3000/admin/groups/4 Completed in 0.02443 (40 reqs/sec) | DB: 0.00034 (1%) | 302 Found [http://127.0.0.1/admin/groups] it works... so the route works.. but not in the test? here''s whats in my routes.rb map.resources :groups, :controller => ''admin/groups'', :name_prefix => "admin_", :path_prefix => "admin" any ideas? the groups_url(id) is the only route that is failing in the test. thanks :) -- http://rubygeek.com - my blog featuring: Ruby, PHP and Perl http://DevChix.com - boys can''t have all the fun
Your routes.rb looks funky. Are you running edge rails? It''s worthwhile if you''re set on restful stuff. I don''t think the name_prefix and path_prefix stuff is really necessary. My nested routes read more like map.resources :groups groups.resources :admins end ''rake routes > /tmp/routes'' is really useful when working out routing issues. If you''re still learning restful routes, grab a copy of the beast forum source code. There''s a model diagram somewhere on flickr also. That was a huge help when I was getting my head around nested routes. - Andy Nola Stowe-5 wrote:> > I have googled and browsed through spec-users archives, but didn''t > find anything different. > > I used rspec scaffold command to generate a mvc for groups, I used > nested controller so I could have a separate interface for admin. > > the specs are the same as generated, so I won''t post the whole thing. > I did put the nested routes names on the calls to the name routes: > > it "should redirect to the new group on successful save" do > post_with_successful_save > response.should redirect_to(admin_group_url("1")) > end > > the error: > 1) > ''Admin::GroupsController handling POST /admin/groups should redirect to > the new > group on successful save'' FAILED > expected redirect to "http://test.host/admin/groups/1", got redirect to > "http:// > test.host/groups/1" > ./spec/controllers/admin/groups_controller_spec.rb:246: > > > > test log: > > Processing GroupsController#update (for 0.0.0.0 at 2007-10-27 21:53:44) > [PUT] > Session ID: > Parameters: {"action"=>"update", "id"=>"1", > "controller"=>"admin/groups"} > Redirected to http://test.host/groups/1 > Completed in 0.00061 (1647 reqs/sec) | DB: 0.00000 (0%) | 302 Found > [http://test.host/admin/groups/1] > > it get redirected to http://test.host/groups/1 instead of admin/groups/1 > > It does work in the interface, which makes me believe that its not in > rails but something in rspec: > dev log: > > Processing GroupsController#create (for 127.0.0.1 at 2007-10-27 22:04:00) > [POST] > Session ID: 082b2f0103579493d5aa2a2851b4e721 > Parameters: {"commit"=>"Create", "action"=>"create", > "controller"=>"admin/groups", "group"=>{...}} > SQL (0.000337) INSERT INTO groups (...) > Redirected to http://127.0.0.1:3000/admin/groups/4 > Completed in 0.02443 (40 reqs/sec) | DB: 0.00034 (1%) | 302 Found > [http://127.0.0.1/admin/groups] > > it works... so the route works.. but not in the test? > > here''s whats in my routes.rb > map.resources :groups, :controller => ''admin/groups'', > :name_prefix => "admin_", > :path_prefix => "admin" > > > any ideas? the groups_url(id) is the only route that is failing in the > test. > > thanks :) > > -- > http://rubygeek.com - my blog featuring: Ruby, PHP and Perl > http://DevChix.com - boys can''t have all the fun > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > >-- View this message in context: http://www.nabble.com/failing-test-with-nested-controller-routes-tf4705370.html#a13450365 Sent from the rspec-users mailing list archive at Nabble.com.
I don''t think I can use edge rails now...they want to use latest stable version. I think if I were using Rails 2.0, i''d use a namespace for this. I basically just want my group CRUD to be controllers/admin/groups_controller,rb but, it works otherwise, just the tests for group_url(id) fail so I think thats kind of weird. here''s my routes: admin_groups GET /admin/groups/ {:action=>"index", :controller=>"admin/groups"} formatted_admin_groups GET /admin/groups.:format/ {:action=>"index", :controller=>"admin/groups"} POST /admin/groups/ {:action=>"create", :controller=>"admin/groups"} POST /admin/groups.:format/ {:action=>"create", :controller=>"admin/groups"} admin_new_group GET /admin/groups/new/ {:action=>"new", :controller=>"admin/groups"} formatted_admin_new_group GET /admin/groups/new.:format/ {:action=>"new", :controller=>"admin/groups"} admin_edit_group GET /admin/groups/:id;edit/ {:action=>"edit", :controller=>"admin/groups"} formatted_admin_edit_group GET /admin/groups/:id.:format;edit/ {:action=>"edit", :controller=>"admin/groups"} admin_group GET /admin/groups/:id/ {:action=>"show", :controller=>"admin/groups"} formatted_admin_group GET /admin/groups/:id.:format/ {:action=>"show", :controller=>"admin/groups"} PUT /admin/groups/:id/ {:action=>"update", :controller=>"admin/groups"} PUT /admin/groups/:id.:format/ {:action=>"update", :controller=>"admin/groups"} DELETE /admin/groups/:id/ {:action=>"destroy", :controller=>"admin/groups"} DELETE /admin/groups/:id.:format/ {:action=>"destroy", :controller=>"admin/groups"} On 10/28/07, Andy Watts <andywatts at yahoo.com> wrote:> > Your routes.rb looks funky. Are you running edge rails? > It''s worthwhile if you''re set on restful stuff. > I don''t think the name_prefix and path_prefix stuff is really necessary. > > My nested routes read more like > map.resources :groups > groups.resources :admins > end > > ''rake routes > /tmp/routes'' is really useful when working out routing > issues. > If you''re still learning restful routes, grab a copy of the beast forum > source code. > There''s a model diagram somewhere on flickr also. > That was a huge help when I was getting my head around nested routes. > > - Andy > > > > Nola Stowe-5 wrote: > > > > I have googled and browsed through spec-users archives, but didn''t > > find anything different. > > > > I used rspec scaffold command to generate a mvc for groups, I used > > nested controller so I could have a separate interface for admin. > > > > the specs are the same as generated, so I won''t post the whole thing. > > I did put the nested routes names on the calls to the name routes: > > > > it "should redirect to the new group on successful save" do > > post_with_successful_save > > response.should redirect_to(admin_group_url("1")) > > end > > > > the error: > > 1) > > ''Admin::GroupsController handling POST /admin/groups should redirect to > > the new > > group on successful save'' FAILED > > expected redirect to "http://test.host/admin/groups/1", got redirect to > > "http:// > > test.host/groups/1" > > ./spec/controllers/admin/groups_controller_spec.rb:246: > > > > > > > > test log: > > > > Processing GroupsController#update (for 0.0.0.0 at 2007-10-27 21:53:44) > > [PUT] > > Session ID: > > Parameters: {"action"=>"update", "id"=>"1", > > "controller"=>"admin/groups"} > > Redirected to http://test.host/groups/1 > > Completed in 0.00061 (1647 reqs/sec) | DB: 0.00000 (0%) | 302 Found > > [http://test.host/admin/groups/1] > > > > it get redirected to http://test.host/groups/1 instead of admin/groups/1 > > > > It does work in the interface, which makes me believe that its not in > > rails but something in rspec: > > dev log: > > > > Processing GroupsController#create (for 127.0.0.1 at 2007-10-27 22:04:00) > > [POST] > > Session ID: 082b2f0103579493d5aa2a2851b4e721 > > Parameters: {"commit"=>"Create", "action"=>"create", > > "controller"=>"admin/groups", "group"=>{...}} > > SQL (0.000337) INSERT INTO groups (...) > > Redirected to http://127.0.0.1:3000/admin/groups/4 > > Completed in 0.02443 (40 reqs/sec) | DB: 0.00034 (1%) | 302 Found > > [http://127.0.0.1/admin/groups] > > > > it works... so the route works.. but not in the test? > > > > here''s whats in my routes.rb > > map.resources :groups, :controller => ''admin/groups'', > > :name_prefix => "admin_", > > :path_prefix => "admin" > > > > > > any ideas? the groups_url(id) is the only route that is failing in the > > test. > > > > thanks :) > > > > -- > > http://rubygeek.com - my blog featuring: Ruby, PHP and Perl > > http://DevChix.com - boys can''t have all the fun > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > View this message in context: http://www.nabble.com/failing-test-with-nested-controller-routes-tf4705370.html#a13450365 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- http://rubygeek.com - my blog featuring: Ruby, PHP and Perl http://DevChix.com - boys can''t have all the fun