1. 08 10月, 2015 1 次提交
    • M
      Fix mounted engine named routes regression · bcfbd8ba
      Matthew Erhard 提交于
      When generating the url for a mounted engine through its proxy, the path should be the sum of three parts:
      
      1. Any `SCRIPT_NAME` request header or the value of `ActionDispatch::Routing::RouteSet#relative_url_root`.
      2. A prefix (the engine's mounted path).
      3. The path of the named route inside the engine.
      
      Since commit https://github.com/rails/rails/commit/44ff0313c121f528a68b3bd21d6c7a96f313e3d3, this has been broken. Step 2 has been changed to:
      
      2. A prefix (the value of `ActionDispatch::Routing::RouteSet#relative_url_root` + the engine's mounted path).
      
      The value of `ActionDispatch::Routing::RouteSet#relative_url_root` is taken into account in step 1 of the route generation and should be ignored when generating the mounted engine's prefix in step 2.
      
      This commit fixes the regression by having `ActionDispatch::Routing::RouteSet#url_for` check `options[:relative_url_root]` before falling back to `ActionDispatch::Routing::RouteSet#relative_url_root`. The prefix generating code then sets `options[:relative_url_root]` to an empty string. This empty string is used instead of `ActionDispatch::Routing::RouteSet#relative_url_root` and avoids the duplicate `relative_url_root` value in the final result.
      
      This resolves #20920 and resolves #21459
      bcfbd8ba
  2. 26 8月, 2015 4 次提交
  3. 25 8月, 2015 5 次提交
  4. 23 8月, 2015 2 次提交
    • D
      Remove unused block arguments · dbfab584
      deepj 提交于
      dbfab584
    • E
      Fix Railties test failure for asset routes · f15a2609
      eileencodes 提交于
      Since none of the action pack tests failed without this conditional it
      didn't seem necessary. This fixes the build because it correctly returns
      a 404 instead of a 500 for the asset routes test.
      
      Test that was failing was in the `assets_test.rb` file and was the test
      named `test_assets_routes_are_not_drawn_when_compilation_is_disabled`.
      f15a2609
  5. 22 8月, 2015 2 次提交
    • E
      Refactor to remove controller class from route to request · 4276b214
      eileencodes 提交于
      This refactoring moves the controller class name that was on the route
      set to the request. The purpose of this refactoring is for changes we
      need to move controller tests to integration tests, mainly being able to
      access the controller on the request instead of having to go through
      the router.
      
      [Eileen M. Uchitelle & Aaron Patterson]
      4276b214
    • E
      Remove unnecessary caching · ec9c6d58
      eileencodes 提交于
      `ActiveSupport::Dependencies.constantize(const_name)` calls
      `Reference.new` which is defined as
      `ActiveSupport::Dependencies.constantize(const_name)` meaning this call
      is already cached and we're doing caching that isn't necessary.
      ec9c6d58
  6. 19 8月, 2015 1 次提交
  7. 15 8月, 2015 6 次提交
  8. 14 8月, 2015 5 次提交
  9. 10 8月, 2015 3 次提交
  10. 09 8月, 2015 5 次提交
    • A
      stop calling `scope` internally · f3606895
      Aaron Patterson 提交于
      we need to get a grip on what `scope` actually does.  This commit
      removes some of the internal calls to `scope`.  Eventually we should add
      public facing methods that provide the API that `scope` is trying to
      accomplish.
      f3606895
    • A
      remove useless conditional · 5a18b853
      Aaron Patterson 提交于
      `prepare_params!` would raise an exception if `params` wasn't
      initialized, so it must always be available.  Remove the existence
      conditional from the `controller` method.
      5a18b853
    • A
      eliminate assignment in conditional · 1b73d53a
      Aaron Patterson 提交于
      The method we called already has the conditional we need.  Just add an
      else block so that we don't need two tests.
      1b73d53a
    • A
      Remove `defaults` hash from `Dispatcher` · dc1b937d
      Aaron Patterson 提交于
      `Dispatcher` doesn't need to hold on to the defaults hash.  It only used
      the hash to determine whether or not it should raise an exception if
      there is a name error.  We can pass that in further up the stack and
      alleviate Dispatcher from knowing about that hash.
      dc1b937d
    • A
      replace each with each_key when only the key is needed · 725f9bf3
      Aaron Lasseigne 提交于
      Using each_key is faster and more intention revealing.
      
      Calculating -------------------------------------
                      each    31.378k i/100ms
                  each_key    33.790k i/100ms
      -------------------------------------------------
                      each    450.225k (± 7.0%) i/s -      2.259M
                  each_key    494.459k (± 6.3%) i/s -      2.467M
      
      Comparison:
                  each_key:   494459.4 i/s
                      each:   450225.1 i/s - 1.10x slower
      725f9bf3
  11. 08 8月, 2015 3 次提交
  12. 02 8月, 2015 1 次提交
    • B
      Use #start_with? and #[] for speed · 113f8a6c
      Benjamin Quorning 提交于
      While the readability may be slightly worse, the speed improvement is
      significant: Twice as fast when there's no leading "/" to remove, and
      over 4 times as fast when there is a leading "/".
      
      Benchmark:
      
          require 'benchmark/ips'
      
          def match(controller)
            if controller
              if m = controller.match(/\A\/(?<controller_without_leading_slash>.*)/)
                m[:controller_without_leading_slash]
              else
                controller
              end
            end
          end
      
          def start_with(controller)
            if controller
              if controller.start_with?('/'.freeze)
                controller[1..-1]
              else
                controller
              end
            end
          end
      
          Benchmark.ips do |x|
            x.report("match") { match("no_leading_slash") }
            x.report("start_with") { start_with("no_leading_slash") }
      
            x.compare!
          end
      
          Benchmark.ips do |x|
            x.report("match") { match("/a_leading_slash") }
            x.report("start_with") { start_with("/a_leading_slash") }
      
            x.compare!
          end
      
      Result (Ruby 2.2.2):
      
          Calculating -------------------------------------
                         match    70.324k i/100ms
                    start_with   111.264k i/100ms
          -------------------------------------------------
                         match      1.468M (± 7.1%) i/s -      7.314M
                    start_with      3.787M (± 3.5%) i/s -     18.915M
      
          Comparison:
                    start_with:  3787389.4 i/s
                         match:  1467636.4 i/s - 2.58x slower
      
          Calculating -------------------------------------
                         match    36.694k i/100ms
                    start_with    86.071k i/100ms
          -------------------------------------------------
                         match    532.795k (± 4.7%) i/s -      2.679M
                    start_with      2.518M (± 5.8%) i/s -     12.566M
      
          Comparison:
                    start_with:  2518366.8 i/s
                         match:   532794.5 i/s - 4.73x slower
      113f8a6c
  13. 01 8月, 2015 1 次提交
    • Y
      Remove duplicated `Array#to_param` · 0069965a
      yui-knk 提交于
      `Array#to_param` is defind in active_support/core_ext/object/to_query.rb,
      so we can call `to_param` if value is_a Array.
      0069965a
  14. 31 7月, 2015 1 次提交
    • S
      Avoid hash duplication by skipping mutation · 1993e2cc
      schneems 提交于
      If we don't mutate the `recall` hash, then there's no reason to duplicate it. While this change doesn't get rid of that many objects, each hash object it gets rid of was massive.
      
      Saves 888 string objects per request, 206,013 bytes (thats 0.2 mb which is kinda a lot).
      1993e2cc