# Locale, routes, tests and default locale

**URL:** <https://www.ruby-forum.com/t/locale-routes-tests-and-default-locale/153701>\
**Category:** Rails\
**Created:** [November 20, 2008, 9:29am UTC](https://www.ruby-forum.com/t/locale-routes-tests-and-default-locale/153701 "2008-11-20T09:29:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@bobm](https://www.ruby-forum.com/u/bobm)\
**Post date:** [November 20, 2008, 9:29am UTC](https://www.ruby-forum.com/t/locale-routes-tests-and-default-locale/153701/1 "2008-11-20T09:29:39Z")

</div>

Hi, I’m stuck in a maze :

routes.rb defines resources like this one  
map.namespace(:admin) do |admin|  
admin.resources :sections, :path\_prefix =\> ‘/:locale/admin’  
end

Then, in functionnal test I have to (for example)  
get :index, :locale =\> ‘en’

I need to provide the :locale for every test I write and I find this too  
much verbose for me. So I tried to write a base test controller that  
would add the locale parameter to every request.

class BaseTestController \< ActionController::TestCase  
def get method, options = {}  
get method, options.merge({:locale =\> ‘en’})  
end  
end

Then, I define my test controller case like this

class Admin::SectionsControllerTest \< BaseTestController  
def test\_index  
get :index  
assert\_response :success  
end  
end

Running the test I get error about get method beeing undefined in  
BaseTestController. And don’t understand why. There must be some  
introspect mechanism used by Rails but how can I do ?

Any idea ?

BTW : the default\_url\_options method is useless here as it only works  
with named routes and ignored by resources paths generator.
