How to set locale default_url_options for functional tests (Rails)

后端 未结 10 1762
予麋鹿
予麋鹿 2020-12-30 07:00

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={})
    {         


        
10条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 07:38

    With integration testing, I found that the above monkey patch needs to be different, this is what worked for me (Rails 2.3.4):

    class ActionController::Integration::Session
      def url_for_with_default_locale(options)
        options = { :locale => 'en' }.merge(options)
        url_for_without_default_locale(options)
      end
      alias_method_chain :url_for, :default_locale
    end
    

提交回复
热议问题