Skip to content

Instantly share code, notes, and snippets.

@exocode
Last active January 3, 2016 01:39
Show Gist options
  • Save exocode/8390721 to your computer and use it in GitHub Desktop.
Save exocode/8390721 to your computer and use it in GitHub Desktop.
# workaround, to set default locale for ALL rspecs https://github.com/rspec/rspec-rails/issues/255
class ActionView::TestCase::TestController
def default_url_options(options={})
logged_in = options[ :controller ] =~ /admin/ ? 'members' : nil
{ locale: I18n.default_locale, logged_in: logged_in }
end
end
class ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
def call(t, args)
logged_in = @options[ :controller ] =~ /admin/ ? 'members' : nil
t.url_for(handle_positional_args(t, args, { locale: I18n.default_locale, logged_in: logged_in }.merge( @options ), @segment_keys))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment