How to set locale default_url_options for functional tests (Rails)
- by insane.dreamer
In my application_controller, I have the following set to include the locale with all paths generated by url_for:
def default_url_options(options={})
{ :locale => I18n.locale }
end
My resource routes then have a :path_prefix = "/:locale"
Works fine on the site.
But when it comes to my functional tests, the :locale is not passed with the generated urls, and therefore they all fail. I can get around it by adding the locale to the url in my tests, like so:
get :new, :locale => 'en'
But I don't want to have to manually add the locale to every functional test.
I tried adding the default_url_options def above to test_helper, but it seems to have no effect.
Is there any way I can change the default_url_options to include the locale for all my tests?
Thanks.