Commit Graph

14697 Commits

Author SHA1 Message Date
Ryuta Kamizono abf0465b09 Merge pull request #38051 from Shopify/actionpack-6-0-stable-ruby-2.7-warnings
Fix Ruby 2.7 warnings in Action Pack 6.0
2019-12-20 23:02:54 +09:00
Rafael França e36d4a0381
Merge pull request #38026 from Edouard-chin/ec-av-base-loadorder
Don't require "action_view/base" in action pack:
2019-12-19 13:40:56 -03:00
Edouard CHIN 88ee52f9d9 Don't require "action_view/base" in action pack:
- ### Problem

  ActionPack requires "action_view/base" at boot time, this
  causes a variety of issue that I described in detail in #38024.

  There is no real reason to require av/base in the
  ActionDispatch::Debugexceptions class.

  ### Solution

  Like any other components (such as ActiveRecord, ActiveJob...),
  ActionView::Base shouldn't be loaded at boot time.

  Here are the two main changes needed for this:

  1) Actionview has a special initializer that needs to run
     before the app is fully booted (adding a executor needs to be done
     before application is done booting)
  63ec70e700/actionview/lib/action_view/railtie.rb (L81-L84)

     That initializer used a lazy load hooks but we can't do that anymore
     because Action::Base view won't be triggered during booting process.
     When it will get triggered, (presumably on the first request),
     it's too late to add an executor.

  ------------------------------------------------

  2) Compare to other components, ActionView doesn't use `Base` for
     configuration flag. A lot of flags ares instead set on modules
     (FormHelper, FormTagHelper).
     The problem is that those module depends on AV::Base to be
     loaded, as otherwise configuration set by the user aren't applied.
     (Since the lazy load hooks hasn't been triggered)
     63ec70e700/actionview/lib/action_view/railtie.rb (L66-L69)

     We shouldn't wait for AB::Base to be loaded in order to set these
     configuration. However, we need to do it inside an
     `after_initialize` block in order to let application
     set it to the value they want.

  Closes #28538

  Co-authored-by: betesh <iybetesh@gmail.com>"
2019-12-19 17:28:24 +01:00
Genadi Samokovarov 7465b383ea
Fix DebugExceptions crash on nil Exception#annoted_source_code
The issue was reported in #29537. We expect Exception#annoted_source_code
to return an `Array`, but this contract may not be followed by all the
implementers.

Fixes #29537.
2019-12-19 12:43:08 -03:00
Rafael Mendonça França 9804f8f9ce
Fix cop violations 2019-12-18 17:07:44 -03:00
Rafael Mendonça França 92ec9f270d
Fix possible information leak / session hijacking vulnerability.
The `ActionDispatch::Session::MemcacheStore` is still vulnerable
given it requires the gem dalli to be updated as well.

CVE-2019-16782
2019-12-18 17:01:09 -03:00
Ryuta Kamizono 72af0bbc3d Fix typos 2019-12-18 16:47:18 +09:00
Rafael Mendonça França c135b922cf
Merge pull request #32143 from sambostock/bubble-up-session-assertions
Delegate child session assertions to parent session
2019-12-17 21:47:58 -03:00
Chris Seelus c694d3ff12
Style actionable errors button 2019-12-17 21:22:31 -03:00
Rafael França c00a543162
Merge pull request #36829 from st0012/fix-28850
Respect Content-Type header passed in head method
2019-12-17 19:24:16 -03:00
Eugene Kenny ee525ff663 Load framework test files in deterministic order
`Dir.glob` doesn't guarantee the order of its results:

https://ruby-doc.org/core-2.6.5/Dir.html#method-c-glob

> Case sensitivity depends on your system (File::FNM_CASEFOLD is
> ignored), as does the order in which the results are returned.

Minitest stores a list of all test cases in the order that they were
defined; it shuffles them before they're run, but doesn't sort them:

https://github.com/seattlerb/minitest/blob/v5.13.0/lib/minitest.rb#L1048
https://github.com/seattlerb/minitest/blob/v5.13.0/lib/minitest.rb#L156

This means that the order in which framework tests run is platform
dependent, and running a test command that failed in CI locally won't
necessarily reproduce the error, even when the same seed is provided.

`Rake::FileList` resolves glob patterns to a sorted list of files:

https://github.com/ruby/rake/blob/v13.0.1/lib/rake/file_list.rb#L408

By using `Rake::FileList` instead of `Dir.glob`, framework tests will
always run in the same order when given the same seed, and reproducing
order dependent CI failures will be easier.
2019-12-16 16:55:06 +00:00
Kasper Timm Hansen cd1aeda0a9
Merge pull request #28297
Closes #28297
2019-12-15 01:38:52 +01:00
Cédric Fabianski 7ccaa125ba
Add SameSite protection to every written cookie
Enabling `SameSite` cookie protection is an addition to CSRF protection,
where cookies won't be sent by browsers in cross-site POST requests when set to `:lax`.

`:strict` disables cookies being sent in cross-site GET or POST requests.

Passing `:none` disables this protection and is the same as previous versions albeit a `; SameSite=None` is appended to the cookie.

See upgrade instructions in config/initializers/new_framework_defaults_6_1.rb.

More info [here](https://tools.ietf.org/html/draft-west-first-party-cookies-07)

_NB: Technically already possible as Rack supports SameSite protection, this is to ensure it's applied to all cookies_
2019-12-15 01:37:24 +01:00
Kasper Timm Hansen 629da1621a
[ci skip] Fix a typo in the comment 2019-12-15 00:36:28 +01:00
John Hawthorn b6fa3ff874 Add regression test for url_helpers duplication
This adds a regression test that previously failed checking controllers
don't have multiple ancestors which include url_helpers or path_helpers.

This is checked by digging through the ancestors and seeing if they
include either the url_helpers_module or path_helpers_module and making
sure only one ancestor does that.

We usually don't test performance changes (and also would not prefer to
test implementation this closely), but because this has regressed in the
past, and I think it would be relatively easy to accidentally introduce
again, I think we should test this one.
2019-12-13 15:59:46 -08:00
John Hawthorn 37e778b6b4 Cache routes.url_helpers built modules
Previously, every time this was called it would return a new module.

Every time a new controller is built, it had one of these module
included onto it (see AbstractController::Railties::RoutesHelper).
Because each time this was a new module we would end up with a different
copy being included on each controller. This would also include a
different copy on a controller than on its superclass (ex.
ApplicationController). Furthermore, each generated module also extended
the url helper modules.

    +--------------+     +-------------+
    |              |     |             |
    | path_helpers |     | url_helpers | (named routes added here)
    |              |     |             |
    +------+----+--+     +----+--+-----+
           ^    ^             ^  ^
           |    |             |  |
           |  +---------------+  |
           |  | |                |
           |  | +-----------+    |
           |  |             |    |
    +------+--+---+      +--+----+-----+
    |             |      |             |
    | (singleton) +------+ url_helpers | (duplicated for each controller)
    |             |      |             |
    +-------------+      +-----+-------+
                               ^
                               |
                               |
                     +---------+-------+
                     |                 |
                     | UsersController |
                     |                 |
                     +-----------------+

The result of this is that when named routes were added to the two
top-level modules, defining those methods became extremely slow because
Ruby has to invalidate the class method caches on all of the generated
modules as well as each controller. Furthermore because there were
multiple paths up the inheritance chain (ex. one through
UsersController's generated module and one through
ApplicationController's genereated module) it would end up invaliding
the classes multiple times (ideally Ruby would be smarter about this,
but it's much easier to solve in Rails).

Caching this module means that all controllers should include the same
module and defining these named routes should be 3-4x faster.

This method can generate two different modules, based on whether
supports_path is truthy, so those are cached separately.
2019-12-13 15:58:28 -08:00
Manfred Stienstra 65093ccb8d
Prefer double-quoted strings. 2019-12-13 17:19:32 +01:00
Manfred Stienstra 20545cde66
Prevent NoMethodError on named route in integration test.
After performing a request on a Metal controller the
controller instance on the integration session becomes
an instance of that Metal controller.

The next call to a named route that requires url_options
will throw a NoMethodError because a Metal controller
does not respond to url_options.

This changes the url_options method on the integration
session to check for the url_options method before
attempting to call it.
2019-12-13 11:20:01 +01:00
Aaron Patterson fa292703e1
Merge pull request #37075 from woahdae/fix-multiple-choice-route-options
Fix route from "(:a)(foo/:b)" when only given :b
2019-12-12 12:34:30 -08:00
Aaron Patterson 285cc00128
Merge pull request #37073 from woahdae/fix-hierarchical-route-options
Fix route from "(:a)(:b)" when given only :a or :b
2019-12-12 12:25:19 -08:00
Eileen M. Uchitelle e36097a950
Merge pull request #37919 from joelhawksley/controller-render-in
Render objects that respond_to render_in in controllers
2019-12-10 09:18:26 -05:00
Tanbir Hasan 15365de5a4
Fix docs about etag 2019-12-10 15:55:16 +06:00
Joel Hawksley 20a83f52d7
Render objects that respond_to render_in in controllers
In https://github.com/rails/rails/pull/36388,
we supported passing objects that `respond_to` `render_in`
to `render`, but _only_ in views.

This change does the same for controllers, as Rails
generally gives the expectation that `render` behaves
the same in both contexts.

Co-authored-by: Aaron Patterson <tenderlove@github.com>
2019-12-09 16:43:18 -07:00
Joel Hawksley 4fbb1e9f5b
Add test case 2019-12-09 15:37:27 -07:00
Rafael Mendonça França 737fb59eb3
Fix Rubocop violation 2019-12-09 12:14:24 -03:00
Rafael Mendonça França e67fdc5aeb
Revert "Merge pull request #37504 from utilum/no_implicit_conversion_of_nil"
This reverts commit 4e105385d0, reversing
changes made to 62b4383909.

The change in Ruby that made those changes required was reverted in
8852fa8760
2019-12-09 11:50:39 -03:00
Rafael França 758e4f8406
Merge pull request #37892 from Edouard-chin/ec-bring-back-drawing-external-routes
Bring back feature that allows loading external route files:
2019-12-06 11:10:26 -03:00
Carlos Antonio da Silva 732cfd2781 Remove extraneous `begin..end` around single `case` statement 2019-12-06 10:33:16 -03:00
Edouard CHIN 33bf253282 Bring back feature that allows loading external route iles:
= This feature existed back in 2012 5e7d6bba79
  but got reverted with the incentive that there was a better approach.
  After discussions, we agreed that it's a useful feature for apps
  that have a really large set of routes.

  Co-authored-by: Yehuda Katz <wycats@gmail.com>
2019-12-06 14:20:12 +01:00
Ryuta Kamizono 3ae38069e9
Merge pull request #37792 from glaszig/fix/actiondispatch/non-headless-driver-options
system tests: properly set driver options for non-headless drivers
2019-12-06 13:41:50 +09:00
Ryuta Kamizono 868bf88354
Merge pull request #37744 from seejohnrun/around_action-docs
Add guide for inline around_action
2019-12-05 11:38:33 +09:00
Jean Boussier 54878cd44b Distinguish missing controller exceptions from unrelated NameError
Fix: https://github.com/rails/rails/issues/37650

The classic autoloader used to totally unregister any constant that
failed midway. Which mean `"SomeConst".constantize` was idempotent.

However Zeitwerk rely on normal `Kernel#require` behavior, which mean
that if an exception is raised during a class/module definition,
it will be left incompletely defined. For instance:

```ruby
class FooController
  ::DoesNotExist

  def index
  end
end
```

Will leave `FooController` defined, but without its `index` method.

Because of this, when silencing a NameError, it's important
to make sure the missing constant is really the one we were trying
to load.
2019-12-04 16:11:54 +01:00
glaszig 769188e1c3 forward system test driver options configured
in initializer block to the selenium driver
for non-headless browsers

* refactored browser options initialization.
* improved method names in AD::SystemTesting::Browser
* improved AD::SystemTest driver tests
2019-12-04 15:57:00 +01:00
Austin Story 23b738225f Add request to the payload for notifications to redirect_to.action_controller.
This change will allow subscribers to the notification to report on anything related to the request that they might need
2019-12-01 08:31:41 -05:00
yuuji.yaginuma b275a95dd2 Call `MonitorMixin` initializer before use methods provided by `MonitorMixin`
`MonitorMixin` setup internal variables in `initialize`, so need to call
that before use.
`ActionController::Live::Buffer` only use methods that do not depend on those
internal variables, so works expertly.

But since Ruby 2.7, methods that were not originally the case also depend on
internal variables. As a result, some tests fail in Ruby 2.7.
https://buildkite.com/rails/rails/builds/65193#02e136eb-edea-4367-aee0-77e0a82f8531/990-1200

I'm not sure if this should be considered Ruby incompatible, but I fixed
this because its usage is wrong.

Related to [Feature #16255: Make `monitor.rb` built-in](https://bugs.ruby-lang.org/issues/16255)
2019-11-28 12:14:54 +09:00
Ryuta Kamizono d558febe32 Auto-correct rubocop offences 2019-11-24 09:54:47 +09:00
Ryuta Kamizono 214f439343 Fixup CHANGELOGs [ci skip] 2019-11-24 09:20:00 +09:00
Rafael Mendonça França 4fe767535d
Merge pull request #37617 from Edouard-chin/ec-respond-to-contenttype
Modify respond_to behaviour always setting the response's content type based on the request format
2019-11-22 14:28:42 -05:00
Eileen M. Uchitelle 786ece692c
Merge pull request #37757 from chalofa/system-routes-for-mount-engines
[regresion] Allow using mountable engine route helpers in System Tests (v6.0.1)
2019-11-21 14:02:54 -05:00
Eileen M. Uchitelle 4135f2d572
Merge pull request #37743 from bquorning/accept-header-comment
Add comment to BROWSER_LIKE_ACCEPTS regex
2019-11-21 14:01:59 -05:00
Carlos Antonio da Silva 223c706b89
Merge pull request #37696 from sidonath/fix-failure-screenshot-path
Prevent nesting failure screenshots into dirs
2019-11-21 15:17:11 -03:00
Edouard CHIN 42c515764a Modify respond_to behaviour always setting the request's content type:
- `respond_to any` doesn't allow to specify a content type and
  the content type in the response will be based on the request
  format.

  ```ruby
    def my_action
      respond_to do |format|
        format.html { render(html: 'hello') }
        format.any { render(json: { foo: 'bar'}) }
      end
    end

    get('my_action.csv')
    # Before this patch, content type was `text/csv'
    # Ather this patch, content type is correctly set to whateve we did in the `format.any` block
  ```

  If the client specify the type of data he wants but the server
  doesn't know how to handle it and return plain text (or whatever)
  I don't think it make sense to falsey claim that we are returning
  a `text/csv` a response where in fact we are returning something else.

  Fix #37345
2019-11-21 14:40:42 +01:00
Takumi Shotoku ea303d012e Allow system tests using Rack::Test to run without Chrome (#37476)
* Allow system tests using Rack::Test to run without Chrome

If you require "action_dispatch/system_test_case", the driven_by method
will be executed immediately.

* https://github.com/rails/rails/blob/v6.0.0/actionpack/lib/action_dispatch/system_test_case.rb#L162

Then the preload method is called in SystemTesting::Driver#initialize.

* https://github.com/rails/rails/blob/v6.0.0/actionpack/lib/action_dispatch/system_testing/driver.rb#L13
* https://github.com/rails/rails/blob/v6.0.0/actionpack/lib/action_dispatch/system_testing/browser.rb#L46-L63

Therefore, a "Webdrivers::BrowserNotFound" error occurs in the browser
preloading when you run system tests witout Chrome.

This commit avoid the error by lazy configuring the driver.

ref: #37410

* Don't preload the browser with :rack_test

If users specify `driven_by(:rack_test)`, it uses Chrome by default arguments.
However, `Rack::Test` does not use a browser and does not need to be preloaded.

Furthermore, it occurs `Webdrivers::BrowserNotFound` when run in
a container (or a machine) without Chrome.
2019-11-21 07:49:03 +09:00
Chalo Fernandez fa83cbca14 Allow using mountable engine route helpers in System Tests 2019-11-20 15:19:31 -06:00
John Crepezzi 012b1e3281 Add guide for inline around_action
This commit adds a test to ensure the behavior of inline `around_action`
calls, as well as a change to the guides to call out this alternate use of
`around_action`.

Closes #37616
2019-11-20 12:03:41 -05:00
Damir Zekić 3c3b80eb96 Remove slashes and backslashes from image paths
When a test method name includes a slash (e.g. `test "signup on the
/signup page"`) the screenshot is generated in the nested directory on
systems that use slash as a directory separator (e.g. a screenshot
called `signup_page.png` is generated within `failures_signup_on_the_`).

Nesting screenshots causes an issue with `tmp:clear` rake task:

```
== Removing old logs and tempfiles ==
rails aborted!
Errno::EISDIR: Is a directory @ apply2files - tmp/screenshots/failures_signup_on_the_
/var/lib/gems/2.5.0/gems/railties-5.2.3/lib/rails/tasks/tmp.rake:41:in `block (3 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
...
Tasks: TOP => tmp:clear => tmp:screenshots:clear
```

While the error could be prevented by changing `tmp:clear` task, there's
no reason to generate deep directory structures for tests using slashes.

To prevent a similar problem on Windows, we'll also "sanitize"
backslashes.

Replacing the problamatic characters with dashes seems to be a safe
workaround, although dash is very arbitrary choice in this case.

Co-Authored-By: Louis-Michel Couture <louim_1@hotmail.com>
2019-11-19 20:06:47 +01:00
Younes SERRAJ 34b6e8c0ae Add params.member? to mimic Hash behavior 2019-11-19 16:03:01 +01:00
Benjamin Quorning 39e3a75e93 Add comment to BROWSER_LIKE_ACCEPTS [ci skip]
The concept of treating Accept header lists including "*/*" as
identifying the request as coming from a browser, and allowing the mime
negotiation to fall back to a HTML response, was introduced in commits
1310231c15 and dc5300adb6.

I am adding the comment (based on the commit messages of the two commits
mentioned) because it is far from obvious why this regex exists and what
it does.

Co-authored-by: Matthew Riddle <mriddle89@gmail.com>
2019-11-18 15:16:00 +01:00
George Claghorn b5c6f33f0d Provide the whole response 2019-11-16 08:17:01 -05:00
Ryuta Kamizono ad767034c9 Address all possible `Performance/StartWith` / `Performance/EndWith` violations
rubocop-performance v1.5.1 includes bug fixes for that cops.

https://github.com/rubocop-hq/rubocop-performance/releases/tag/v1.5.1
2019-11-14 03:20:29 +09:00
Ryuta Kamizono 081dfef95a Remove redundant `env.delete` in `scrub_env!`
It is a part of `env.delete_if { |k, v| k.match?(/^(action_dispatch|rack)\.request/) }`.
2019-11-14 03:04:49 +09:00
Rafael Mendonça França 63256bc5d7
Controller can be symbols as well
Symbol doesn't respond to `start_with?` so we need to change it to
string before doing the comparison.
2019-11-08 15:51:40 -05:00
utilum 8424f34289 Append missing 's' to #silence_warning call 2019-11-07 11:25:57 +02:00
George Claghorn cbdea0ef38 Add load hook for ActionDispatch::Request 2019-11-06 15:50:23 -05:00
Tatsuya Hoshino 41f0fb8c6e Remove needless `require "pp"`
In Ruby 2.5 and later, `Kernel#pp` is automatically loaded.

https://bugs.ruby-lang.org/issues/14123

This changes remove the needless `require "pp"`.
2019-11-06 22:50:53 +09:00
George Claghorn 32b99f9358 Provide the whole request 2019-11-04 18:32:03 -05:00
Rafael França 4e105385d0
Merge pull request #37504 from utilum/no_implicit_conversion_of_nil
TypeError Regexp#match?(nil) in Ruby Head
2019-11-04 15:18:41 -05:00
George Claghorn 8ec75a142e Add :uuid to process_action.action_controller payloads 2019-11-04 10:30:38 -05:00
George Claghorn 722259444a Add :location to process_action.action_controller payloads 2019-11-04 07:46:48 -05:00
utilum 2ca6830831 TypeError Regexp#match?(nil) in Ruby Head
Aa of ruby/ruby@2a22a6b2d8 calling
`Regexp#match?(nil)` raises an exception.

[utilum, eregon, eugeneius]
2019-11-03 09:26:46 +02:00
Martin Bjeldbak Madsen e8a881a753
Add two cross links to methods in docs [skip ci] 2019-10-15 22:31:24 +10:00
Orien Madgwick 493edf044f Add bug tracker/documentation/mailing list URIs to the gemspecs 2019-10-11 20:47:19 -04:00
Jean Boussier a707072ffa Implicitly assert no exception is raised in block assertions 2019-10-07 11:01:24 +02:00
Kasper Timm Hansen eca6c273fe
[ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
norm bf14a8e235 Updated `ActionDispatch::Request.remote_ip=`
Updated the setter to clear the value in the `@remote_ip` instance
variable before setting the header that the value is derived from in the
getter.
2019-10-06 14:33:04 -07:00
Greg Myers 918ebcbb61 Allow OPTIONS verb in mapper (#37370)
* Allow OPTIONS verb in mapper

* Update actionpack/lib/action_dispatch/routing/mapper.rb
2019-10-05 17:56:53 +02:00
Greg Myers bd40a2e780 Support the OPTIONS Http Verb in Integration tests (#37369)
* Support the OPTIONS Http Verb

ActionDispatch::Integration::Session#process already lists OPTIONS as a valid verb symbol to pass

* Update actionpack/lib/action_dispatch/testing/integration.rb
2019-10-05 17:55:47 +02:00
Juanjo Bazán b24190807d update https urls [ci skip] 2019-10-03 11:01:32 +02:00
Masaki Hara 89f5789aad Delay ActionDispatch::Response configuration to load-time
It fixes the problem in propagating return_only_media_type_on_content_type
and fixes the corresponding test being ineffective.

The mentioned test addes the following line:
...config.action_dispatch.return_only_media_type_on_content_type = true
to the config and checks if it takes effect. However, in this scenario,
the value is already true before this line.
Moreover, the users are supposed to flip this from true to false in real
situations.

This commit flips the config in the test, making it to fail as
expected. The next commit will fix the failure.

In order for return_only_media_type_on_content_type to appropriately
take effect on ActionDispatch::Response, we want to know when
ActionDispatch::Response is loaded.
As load hooks for ActionDispatch would be too broad, the appropriate
registry is for ActionDispatch::Response itself.

Looking into other examples, a hook name is a full class name in
snake case with `_base` suffix omitted, if any. Therefore, in this case,
:action_dispatch_response seems appropriate.
2019-10-01 17:42:05 +09:00
Ryuta Kamizono bc7ed042c4 Use String#+@ before mutating the result of Symbol#to_s
Follow up #37303.

https://buildkite.com/rails/rails/builds/63957#dc16cd12-10a2-435c-9b64-b8332114d92a/981-1293
2019-09-28 15:53:20 +09:00
Gannon McGibbon 63783fdba2
Merge pull request #34893 from gmcgibbon/add_gotcha_note_to_helper_method_docs
Add note about view contexts to ActionController::Helpers.helpers
2019-09-27 14:17:46 -04:00
George Claghorn 75a53297c7
Add ActionController::Base.log_at
Allow setting a different log level per request.
2019-09-24 13:47:34 -04:00
Takayuki Nakata 1da65ab6ce Fix typo in actionpack changelog, `a HTTP` -> `an HTTP` [ci skip] 2019-09-24 08:33:10 +09:00
Nobuyoshi Nakada 477e71b6b6
Reduce stat(2) calls
`File.file?` and other predicates for permissions can use same
stat(2) call result.
2019-09-22 18:23:09 +09:00
Ryuta Kamizono 19a2d5c112
Merge pull request #37228 from eugeneius/action_dispatch_response_autoload
Allow ActionDispatch::Response to be autoloaded
2019-09-18 15:29:53 +09:00
Akira Matsuda 5c07e1a3f4 Reduce Hash allocations
Merging multiple Hashes in Ruby < 2.6 is so hard...
2019-09-18 14:37:27 +09:00
Akira Matsuda a221ee84da String#force_encoding destructively updates the hash values 2019-09-18 14:37:27 +09:00
Akira Matsuda 2db4c0203a Reduce object allocations in Journey 2019-09-18 14:37:27 +09:00
Eugene Kenny aaa9b669f8 Allow ActionDispatch::Response to be autoloaded
Similar to b744372f2d, this defers loading
`ActionDispatch::Response` until after initialization, which will allow
applications to boot a bit faster in development but also paves the way
for `return_only_media_type_on_content_type` to work correctly when set
from `new_framework_defaults_6_0.rb`.

Benchmark:

    $ cat test.rb
    require "bundler/setup"
    before = ObjectSpace.each_object(Module).count
    start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    require "action_controller"
    finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    after = ObjectSpace.each_object(Module).count
    puts "took #{finish - start} and created #{after - before} modules"

Before:

    $ ruby test.rb
    took 0.35654300000169314 and created 608 modules

After:

    $ ruby test.rb
    took 0.2770050000108313 and created 466 modules

Co-authored-by: Serena Fritsch <serena@intercom.io>
2019-09-17 23:38:01 +01:00
Akira Matsuda 4257ea756b Prefer String#== over String#=== for clarity 2019-09-17 07:59:04 +09:00
Akira Matsuda 4a9ef5e120 Use Regext#match? where MatchData is not needed 2019-09-17 07:59:04 +09:00
Akira Matsuda 30a73035c7 No need to dup temporary strings 2019-09-17 07:59:04 +09:00
Akira Matsuda fc2e836aed return early 2019-09-17 07:59:04 +09:00
Akira Matsuda ec8da95447 2019-09-17 07:59:04 +09:00
Akira Matsuda 7b1fe26472 Avoid extra hash creation 2019-09-17 07:59:04 +09:00
Akira Matsuda b577bebafe Use Path::Pattern#match? that uses Regexp#match? where MatchData is not in need 2019-09-17 07:58:59 +09:00
Akira Matsuda bea24d4790 Reduce Array and Hash creations in Journey find_routes 2019-09-17 07:44:04 +09:00
Akira Matsuda bf5530df68 Revert "There are some Rack middleware take keyword arguments for initializing"
This reverts commit c6ef71ccf2
because this causes "wrong number of arguments (given 2, expected 1) (ArgumentError)" on Ruby 2.5
2019-09-15 09:26:01 +09:00
Akira Matsuda c6ef71ccf2 There are some Rack middleware take keyword arguments for initializing 2019-09-15 03:09:32 +09:00
Akira Matsuda 090aa9e535 Reduce proc call 2019-09-14 08:43:35 +09:00
Akira Matsuda ed1e719914 `get` gets keyworded options 2019-09-14 08:43:35 +09:00
Akira Matsuda fc8635f87a Other `get` signatures take keyword arguments 2019-09-14 08:43:35 +09:00
Akira Matsuda f42f2862bb IntegrationTest#head also does not accept non-keyword arguments
this follows up de9542acd5
2019-09-14 08:43:35 +09:00
Akira Matsuda 926cfdb4e3 get gets keyworded options 2019-09-13 17:36:11 +09:00
Akira Matsuda 352560308b Fix keyword arguments warnings 2019-09-09 22:49:09 +09:00
Akira Matsuda 7a563f749d Fix Class#new + keyword arguments warnings 2019-09-09 02:35:59 +09:00
Akira Matsuda 9977b63c47 I18n.translate takes keyword arguments 2019-09-09 01:13:38 +09:00
Jean Boussier 7b53016b98 Refactor `define_url_helper` to share the same instance between _path and _url
Before this patch each named routes generates two UrlHelper instances.
Both are almost identical, their only difference is the `url_strategy`
property.

This patch get rid of that property and instead pass it as an argument
to call, so effectively it's stored in the closure.
2019-09-06 14:23:38 +02:00
Akira Matsuda a43de73841 Revert "Revert "send with **options only when options is not empty""
This reverts commit 2f141ab09e.

Ruby 2.6 and 2.5 do not work without this...
2019-09-06 19:26:43 +09:00
Akira Matsuda 2f141ab09e Revert "send with **options only when options is not empty"
This reverts commit 5665fb5f6e.

This adhoc workaround is no longer needed because the root cause has been fixed upstream
2019-09-06 18:52:00 +09:00