Locale, routes, tests and default locale

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’

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’})

Then, I define my test controller case like this

class Admin::SectionsControllerTest < BaseTestController
def test_index
get :index
assert_response :success

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs