Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looking through how the controller test case generates the url there doesn't seem to be a direct way to have it use the defualt_url_options. The main block that actually does the url creationg (in the tests) looks like this (<a href="http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb" rel="nofollow noreferrer">http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb</a>):</p> <pre><code>private def build_request_uri(action, parameters) unless @request.env['REQUEST_URI'] options = @controller.__send__(:rewrite_options, parameters) options.update(:only_path =&gt; true, :action =&gt; action) url = ActionController::UrlRewriter.new(@request, parameters) @request.request_uri = url.rewrite(options) end end </code></pre> <p>This gets called by the process method which is in turn called by the get, post, head, or put methods. One way to maybe get what you are looking for might be to alias_chain the process method.</p> <pre><code>class ActionController::TestCase def process_with_default_locale(action, parameters = nil, session = nil, flash = nil, http_method = 'GET') parameters = {:locale=&gt;'en'}.merge(parameters||{}) process_without_default_locale(action, parameters, session, flash, http_method) end alias_method_chain :process, :default_locale end </code></pre> <p>You'll want to put that into your test helper, outside of the TestCase class I think. Let me know how it works for you, I haven't really tested it out so we'll see.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload