How to set locale default_url_options for functional tests (Rails)

后端 未结 10 1699
予麋鹿
予麋鹿 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:23

    For Rails 5, I found this simple solution In test_helper.rb based on action_dispatch/testing/integration.rb

    module ActionDispatch::Integration
      class Session
        def default_url_options
          { locale: I18n.locale }
        end
      end
    end
    

提交回复
热议问题