# Actions when testing resources with namespaces

**URL:** <https://www.ruby-forum.com/t/actions-when-testing-resources-with-namespaces/124661>\
**Category:** Rails\
**Created:** [December 31, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/actions-when-testing-resources-with-namespaces/124661 "2007-12-31T19:46:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSPablo\_FernSSSSnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@JSPablo\_FernSSSSnd](https://www.ruby-forum.com/u/JSPablo_FernSSSSnd)\
**Post date:** [December 31, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/actions-when-testing-resources-with-namespaces/124661/1 "2007-12-31T19:46:03Z")

</div>

Hello,

I have an admin tool in the namespace admin in this way:

map.namespace :admin do |admin|  
admin.resources :products  
end

and I’ve also have a

map.resources :products

except that the last one is nice (or tries to be) and the first one  
allows to  
edit, update, create and destroy.

For testing admin/products\_controller I have the following code:

class Admin::ProductsControllerTest \< ActionController::TestCase  
def test\_should\_create\_product  
assert\_difference(‘Product.count’) do  
post :create, :product =\> {}  
end  
assert\_redirected\_to admin\_product\_path(assigns(:product))  
end  
end

When I run the test I get

1. Error:  
test\_should\_create\_product(Admin::ProductsControllerTest):  
NoMethodError: undefined method `product\_url’ for  
#Admin::ProductsController:0xb7077684

Well, of course, product\_url doesn’t and should not exists. But post  
should be  
trying to run admin\_product\_url. How can I make that work?

Thank you.
