Commit Graph

316 Commits

Author SHA1 Message Date
Jeremy Daer
eea3d5adcf Revert lazy routesets (#52012) due to polymorphic routing regression
References https://github.com/rails/rails/pull/52012#issuecomment-2183415161

Revert "Merge pull request #52033 from Shopify/amend_lazy_routes_changelog"

This reverts commit 743128b2307b6e1bd59acb9dc8358592d264c573, reversing
changes made to 6622075802bdcca22ab3e32ef6e3f6d2b9a881f8.

Revert "Merge pull request #52012 from Shopify/defer_route_drawing"

This reverts commit 6622075802bdcca22ab3e32ef6e3f6d2b9a881f8, reversing
changes made to 5dabff4b7bf4cc5e2e552efb78c6a3f3e44bed37.
2024-06-21 13:59:43 -07:00
Gannon McGibbon
7ac333858c Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-06-04 11:12:12 -05:00
Gannon McGibbon
d46d5ce610 Make with_routing test helper work for integration tests
Adds support for with_routing test helpers in ActionDispatch::IntegrationTest.
Previously, this helper didn't work in an integration context because
the rack app and integration session under test were not mutated.
Because controller tests are integration tests by default, we should
support test routes for these kinds of test cases as well.
2023-11-23 22:10:45 -06:00
Jean Boussier
02e679ba75 Get rid of the jruby_skip test helper
The last test calling it actually passes on latest
JRuby.
2023-10-02 13:01:44 +02:00
Rafael Mendonça França
818bfc269a
Remove deprecation messages from actionpack test suite
The 6.1 cache format that is the default is deprecated.
2023-08-23 18:43:35 +00:00
Samuel Williams
8fbf70c889
Improve cookie attribute assertions. 2023-07-19 15:36:57 +12:00
Samuel Williams
08510b5437
Improve matching of headers assertions.
The current implementation makes assumptions about the case and format of
headers. Introduce methods to handle headers in a case insensitive manner
and reduce churn when comparing with multi-value headers.
2023-01-21 05:26:22 +13:00
Samuel Williams
f63a5e7d16
Improve matching of cookie assertions.
The current implementation makes assumptions about the order and case
sensitivity of cookie attributes. Introduce methods to parse those fields
and compare them semantically. Update the existing tests to take advantage
of these new assertions.
2023-01-20 14:53:18 +13:00
Jonathan Hefner
48d4e6e02b Add ActionDispatch.deprecator
This commit adds `ActionDispatch.deprecator` and replaces all usages of
`ActiveSupport::Deprecation.warn` in `actionpack/lib/action_dispatch`
with `ActionDispatch.deprecator`.

Additionally, this commit adds `ActionDispatch.deprecator` to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
2022-10-27 17:11:02 -05:00
Jonathan Hefner
b287779499 Add {Abstract,Action}Controller.deprecator
This commit adds `AbstractController.deprecator` and
`ActionController.deprecator`, and replaces all usages of
`ActiveSupport::Deprecation.warn` in `actionpack/lib/action_controller`
with the latter.

Additionally, this commit adds `ActionController.deprecator` to
`Rails.application.deprecators`.  Because `AbstractController` does not
have its own railtie to do the same, `AbstractController` and
`ActionController` use the same deprecator instance.  Thus, both can be
configured via `Rails.application.deprecators[:action_controller]` or
via config settings such as `config.active_support.report_deprecations`.
2022-10-27 16:20:53 -05:00
Jean Boussier
d917896f45 Enable verbose mode in test and report warnings as errors
We recently let a few very easy to avoid warnings get merged.
The root cause is that locally the test suite doesn't run in
verbose mode unless you explictly pass `-w`.

On CI warnings are enabled, but there is no reason to look at the
build output unless something is failing. And even if one wanted
to do that, that would be particularly work intensive since warnings
may be specific to a Ruby version etc.

Because of this I believe we should:

  - Always run the test suite with warnings enabled.
  - Raise an error if a warning is unexpected.

We've been using this pattern for a long time at Shopify both in private
and public repositories.
2022-10-11 09:25:18 +02:00
Yasuo Honda
349a66ebed Drop Rubinius code
Rubinius has not been maintained since May 2020 and based on the
discussion at https://github.com/rails/rails/pull/44984 ,
I think we can remove Rubinius specific code from Rails.
2022-09-15 23:43:51 +09:00
Xavier Noria
e933dc0b84 Let the Action Pack autoload with Zeitwerk 2021-08-21 20:20:23 +02:00
Xavier Noria
2a22b4c53b Delete AS::Dependencies.hook! 2021-08-17 05:18:22 +02:00
eileencodes
6f04ec1ee1
Stop using a singleton for routes
This change ensures we're no longer using a singleton for routes because
we want to change the routing table based on the controller we're
testing. We don't want the routing table to be global for the Action
Pack tests.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2020-07-14 13:46:54 -04:00
fatkodima
e24d6ecbfd Update rubocop-performance gem and enable Performance/DeletePrefix and Performance/DeleteSuffix cops 2020-05-24 12:51:35 +03:00
Ryuta Kamizono
9ccfc0e179 Fix typo 2020-05-03 05:43:01 +09:00
Xavier Noria
5b28a0e972 Remove require_dependency usage in helper [Closes #37632]
Motivation is twofold:

  * We are gradually removing `require_dependency` from the framework.

  * Let `helper` work if `config.add_autoload_paths_to_load_path` is
    disabled.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2020-05-02 17:57:55 +02:00
Yasuo Honda
c667a725f1 Remove ENV['TRAVIS']
Rather than replace `ENV['TRAVIS']` with `ENV['CI']`, I think we can
remove this condition because `ENV['TRAVIS']` is not valid at Buildkite
then Rails CI has been running with `PROCESS_COUNT` about 9 month
since this e485c14a3e
2020-01-02 09:23:06 +09:00
Yasuo Honda
1a41a741cf Address DEPRECATED: use MT_CPU instead of N for parallel test runs
* Steps to reproduce

```ruby
% cd actionpack
% N=0 bundle exec ruby -w -Itest test/controller/mime/accept_format_test.rb
DEPRECATED: use MT_CPU instead of N for parallel test runs
... snip ...
%
```

* minitest 5.12.0 deprecates ENV["N"] to specify number of parallel test
runners:

https://github.com/seattlerb/minitest/blob/master/History.rdoc#5120--2019-09-22
4103a10eb4

* No other code uses `ENV["N"]`
```
% git grep 'ENV\["N"\]'
actionpack/test/abstract_unit.rb:  PROCESS_COUNT = (ENV["N"] || 4).to_i
%
```

* Rails guide suggests using `PARALLEL_WORKERS` to specify the number of workers, not `N`
https://guides.rubyonrails.org/testing.html#parallel-testing
https://guides.rubyonrails.org/testing.html#parallel-testing

```ruby
PARALLEL_WORKERS=15 rails test
```
2019-12-28 13:01:09 +09: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
Akira Matsuda
fc8635f87a Other get signatures take keyword arguments 2019-09-14 08:43:35 +09:00
Rafael Mendonça França
967beb7229
Revert "MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now"
This reverts commit 98d0f7ebd34b858f12a12dcf37ae54fdbb5cab64.
2019-08-02 00:24:21 -04:00
Rafael Mendonça França
6384933994
Revert "You give jruby_skip & rubinius_skip a good name"
This reverts commit 8d2866bb80fbe81acb04f5b0c44f152f571fb29f.
2019-08-02 00:24:11 -04:00
Akira Matsuda
8d2866bb80 You give jruby_skip & rubinius_skip a good name
This hack prevails everywhere in the codebase by being copy & pasted, and it's actually not a negative thing but a necessary thing for framework implementors,
so it should better have a name and be a thing.

And with this commit, activesupport/test/abstract_unit.rb now doesn't silently autoload AS::TestCase,
so we're ready to establish clearner environment for running AS tests (probably in later commits)
2019-08-02 05:36:38 +09:00
Akira Matsuda
98d0f7ebd3 MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now
It's used everywhere, clean and mature enough
2019-08-02 05:36:15 +09:00
Ryuta Kamizono
c81af6ae72 Enable Layout/EmptyLinesAroundAccessModifier cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
Genadi Samokovarov
54df392bc5 Manage ActionDispatch::ActionableExceptions from the default middleware stack 2019-04-19 14:15:22 +09:00
Fumiaki MATSUSHIMA
61c4be4777 Output junit format test report 2019-04-04 14:34:46 +09:00
yuuji.yaginuma
4b5c4ca377 Use Testing::Parallelization in Action Packs's test
Parallel execution of `ForkingExecutor` is the same approach as
`Testing::Parallelization`. So do not need to have own code inside
Action Pack. Let's use an already existing feature.
2018-11-28 16:10:14 +09:00
schneems
235e734e1e Revert "Merge pull request #33970 from rails/eager-url-helpers"
Until #34050 can be resolved

This reverts commit 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, reversing
changes made to 6556898884d636c59baae008e42783b8d3e16440.
2018-10-03 16:15:47 -05:00
Aaron Patterson
8dc784292b
Eagerly build the routing helper module after routes are committed
This commit eagerly builds the route helper module after the routes have
been drawn and finalized.  This allows us to cache the helper module but
not have to worry about people accessing the module while route
definition is "in-flight", and automatically deals with cache
invalidation as the module is regenerated anytime someone redraws the
routes.

The restriction this commit introduces is that the url helper module can
only be accessed *after* the routes are done being drawn.

Refs #24554 and #32892
2018-09-25 09:43:25 -07:00
Aaron Patterson
6d698fdb07
Merge pull request #33973 from rails/remove-catch-all
Remove deprecated catch-all route in the AV tests
2018-09-25 09:27:37 -07:00
Aaron Patterson
4f96e739c2
Remove deprecated catch-all route in the AV tests
This commit removes a deprecated catch-all route in the AV tests.  It
defines and includes the necessary routes for each test such that we
don't need the catch-all anymore.

This also helps push us toward #33970
2018-09-24 15:39:15 -07:00
Sakshi Jain
0fe2bb816f Remove private def 2018-09-23 21:27:44 +05:30
Nobuyoshi Nakada
09820655f8
let drb make temprary server 2017-12-29 23:58:43 +09:00
yuuji.yaginuma
cc0d272c8c Generate tmpname on its own
`make_tmpname` was removed by 25d56ea7b7.
In this case, we want a file name, not a `File`. So cannot use `Tempfile`.

Fixes #31458
2017-12-15 11:57:43 +09:00
bogdanvlviv
82b974813b
Add headless firefox driver to System Tests 2017-12-07 20:20:54 +02:00
Shuhei Kitagawa
03dd47ff21 removed unnecessary semicolons 2017-10-28 17:39:58 +09:00
yuuji.yaginuma
ada05850f8 Add headless chrome driver to System Tests 2017-10-17 07:35:48 +09:00
Koichi ITO
d2901bd517 [Action Pack] rubocop -a --only Layout/EmptyLineAfterMagicComment 2017-07-11 13:12:32 +09:00
Kir Shatrov
b3f3d49fd6 Prepare AP and AR to be frozen string friendly 2017-07-06 21:30:43 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
bogdanvlviv
40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
2017-05-23 00:53:51 +03:00
eileencodes
7c9af60e5c Call system test driver per-instance rather than globally
Previously the system test subclasses would call `driven_by` when the
app booted and not again when the test was initialized which resulted in
the driver from whichever class was called last to be used in tests.

In rails/rails#28144 the `driven_by` method was changed to run `use` on
setup and `reset` on teardown. While this was a viable fix this really
pointed to the problem that system test `driven_by` was a global
setting, rather than a per-class setting.

To alieviate this problem calling the driver should be done on an
instance level, rather than on the global level. I added an `initialize`
method to `SystemTestCase` which will call `use` on the superclass
driver. Running the server has been moved to `start_application` so that
it only needs to be called once on boot and no options from `driven_by`
were being passed to it.

This required a largish rewrite of the tests. Each test needs to utilize
the subclass so that it can properly test the drivers.
`ActionDispatch::SystemTestCase` shouldn't be called directly anymore.
2017-03-09 10:52:05 -05:00
Akira Matsuda
146e928800 Don't pollute Object with rubinius_skip and jruby_skip
we call them only in the tests
2017-01-17 18:51:50 +09:00
Akira Matsuda
c82fa18514 Use Encoding::UTF_8 constant for default_{internal,external} in the tests 2017-01-11 17:48:00 +09:00
Rafael Mendonça França
209bfc0a5c
Fix style guide violations 2017-01-05 00:40:24 -05:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00