Commit Graph

16010 Commits

Author SHA1 Message Date
Gannon McGibbon
099776069c
Merge pull request #52303 from Shopify/routing_source_locations_in_command
Only enable routing source locations when using routes command
2024-07-15 11:39:39 -05:00
Gannon McGibbon
e3cc8fe707 Only enable routing source locations when using routes command
The overhead isn't necessary for development when not using the routes
command. We can omit it entirely by checking for existence of the routes
command constant.
2024-07-11 18:53:20 -05:00
Hartley McGuire
eb60e20193
Add documentation for delegated methods on Metal
Some of these were specifically mentioned earlier in the Metal docs
(response_body=, content_type=, status=) but were not linked because the
methods were not documented (due to being part of a delegation).

This commit separates all of the delegated methods so that they can be
documented, adds links for the mentioned methods, and additionally
documents two methods on Response that are mentioned in the new Metal
documentation, but were not previously documented.
2024-07-10 21:41:34 -04:00
Jenny Shen
bdd9f4e89e Check If-None-Match before If-Modified-Since with strict freshness 2024-07-08 11:23:00 -04:00
Nate Matykiewicz
78ad54569b
Make http_cache_forever use immutable: true 2024-07-06 01:59:39 -05:00
Jean Boussier
0d30e84878 Fix a typo 2024-07-05 11:52:59 +02:00
heka1024
fc7637103a Prefer ETag over Last-Modified for fresh_when and stale? according to the HTTP specification 2024-07-05 10:18:43 +02:00
Aaron Patterson
35a4946d1c
Merge pull request #52094 from ioquatix/rack-3-streaming
Utilize Rack 3 streaming.
2024-07-01 17:39:11 -07:00
heka1024
a1a0931e13 Document immutable option in expires_in 2024-07-02 03:33:21 +09:00
Rafael Mendonça França
999df686de
Merge pull request #52197 from heka1024/cache-controler-immutable
Support `immutable` directive in Cache-Control
2024-06-26 16:23:19 -04:00
Earlopain
979e308312
Don't make rdoc generation take an unreasonable amount of time
On CI, this takes about 8 hours. On my PC I canceled after 3.

I suspect this comment in rdoc to be relevant (since this method is where it is stuck): 4b84660690/lib/rdoc/mixin.rb (L68-L71)
Removing a few includes eventually makes it complete. It doesn't seem to matter which ones you remove.

https://github.com/rails/rails/pull/52185 was the trigger for this.
2024-06-26 17:53:43 +02:00
heka1024
d98cfde86a Support immutable directive in Cache-Control 2024-06-23 08:49:34 +09:00
Rafael Mendonça França
5cfa13687d
Merge pull request #52185 from Shopify/vs/turn_action_controller_inclusions_explicit
Turn ActionController::Base inclusions explicit
2024-06-21 17:45:32 -04:00
Vinicius Stock
0966b1983b
Turn ActionController::Base inclusions explicit
Currently, we are using dynamic inclusions to
guarantee that the list of MODULES is always up to
date with what gets included into Base. However,
that prevents static analysis tools from
understanding the ancestors of controllers, which
prevents completion and other editor features from
working correctly. We can instead use a unit test
to verify that both lists are synchronized, which
retains the original behavior while allowing for
more accurate static analysis.
2024-06-21 21:07:12 +00:00
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
Yasuo Honda
1b905edd2e Support selenium-webdriver 4.22.0 that enables CDP in Firefox by default
This pull request supports selenium-webdriver 4.22.0 that enables CDP in Firefox by default.
because Firefox 129 deprecates Chrome DevTools Protocol (CDP).
selenium-webdriver 4.22.0 enables CDP explicitly by adding "remote.active-protocols"=>3 .

- Steps to reproduce and this commit addresses these failures.
```ruby
$ bundle update selenium-webdriver --conservative
$ git diff main ../Gemfile.lock
diff --git a/Gemfile.lock b/Gemfile.lock
index 4e1c049ac0..e05f4b3b3c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -512,8 +512,9 @@ GEM
       google-protobuf (~> 3.25)
     sass-embedded (1.69.6-x86_64-linux-gnu)
       google-protobuf (~> 3.25)
-    selenium-webdriver (4.20.1)
+    selenium-webdriver (4.22.0)
       base64 (~> 0.2)
+      logger (~> 1.4)
       rexml (~> 3.2, >= 3.2.5)
       rubyzip (>= 1.2.2, < 3.0)
       websocket (~> 1.0)
$ cd actionpack
$ bin/test test/dispatch/system_testing/driver_test.rb test/dispatch/system_testing/driver_test.rb
Running 18 tests in a single process (parallelization threshold is 50)
Run options: --seed 58668

.....F

Failure:
DriverTest#test_define_extra_capabilities_using_firefox [test/dispatch/system_testing/driver_test.rb:127]:
--- expected
+++ actual
@@ -1 +1 @@
-{"moz:firefoxOptions"=>{"args"=>["--host=127.0.0.1"], "prefs"=>{"browser.startup.homepage"=>"http://www.seleniumhq.com/"}}, "browserName"=>"firefox"}
+{"moz:firefoxOptions"=>{"args"=>["--host=127.0.0.1"], "prefs"=>{"remote.active-protocols"=>3, "browser.startup.homepage"=>"http://www.seleniumhq.com/"}}, "browserName"=>"firefox"}

bin/test test/dispatch/system_testing/driver_test.rb:113

.F

Failure:
DriverTest#test_define_extra_capabilities_using_headless_firefox [test/dispatch/system_testing/driver_test.rb:144]:
--- expected
+++ actual
@@ -1 +1 @@
-{"moz:firefoxOptions"=>{"args"=>["-headless", "--host=127.0.0.1"], "prefs"=>{"browser.startup.homepage"=>"http://www.seleniumhq.com/"}}, "browserName"=>"firefox"}
+{"moz:firefoxOptions"=>{"args"=>["-headless", "--host=127.0.0.1"], "prefs"=>{"remote.active-protocols"=>3, "browser.startup.homepage"=>"http://www.seleniumhq.com/"}}, "browserName"=>"firefox"}

bin/test test/dispatch/system_testing/driver_test.rb:130

..........

Finished in 0.007717s, 2332.3654 runs/s, 4794.3066 assertions/s.
18 runs, 37 assertions, 2 failures, 0 errors, 0 skips
```

- Planned Deprecation of CDP in Firefox
https://groups.google.com/a/mozilla.org/g/dev-platform/c/Z6Qu3ZT1MJ0?pli=1

- Add preference to enable CDP in Firefox by default
https://github.com/SeleniumHQ/selenium/pull/14091

- [rb] Add logger gem as a runtime dependency #14082
https://github.com/SeleniumHQ/selenium/pull/14082
2024-06-21 09:57:50 +09:00
Maxime Lapointe
3e816bfe72 Fixes tests with nested exception backtraces on Ruby master
Ruby master did the following changes (and probably more)
https://bugs.ruby-lang.org/issues/16495
https://bugs.ruby-lang.org/issues/20275
2024-06-17 09:43:28 -04:00
Rafael Mendonça França
3342f13d12
Move the rewind code closer to the reason why we need to rewind
We only need to rewind because we call `read_body_stream`. Since
that method is only called in one place, move the rewing to inside it.
2024-06-14 18:56:36 +00:00
Samuel Williams
ed68af0f62
Utilize Rack 3 streaming. 2024-06-13 10:27:09 +09:00
Maxime Lapointe
f47ef36c4d
Log trace of causes for unhandled exceptions 2024-06-12 22:51:15 +00:00
Samuel Williams
f7f79480d6
Don't try to set invalid cookies.
In Rack 3.1, using invalid cookie keys was deprecated and in Rack 3.2,
using an invalid cookie key will raise an exception.

Escaping cookie keys is non-standard behaviour and is not understood by
clients, e.g. `document.cookies` will contain escaped keys. It also
doesn't round-trip correctly, as in, setting a header with a given name
won't have the same name in subsequent requests. In addition, the
escaping / unescaping behaviour in previous versions of Rack
[caused a security issue](https://github.com/advisories/GHSA-j6w9-fv6q-3q52).
2024-06-12 18:28:41 +00:00
Gannon McGibbon
6622075802
Merge pull request #52012 from Shopify/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called.
2024-06-06 11:23:47 -05:00
Zack Deveau
35858f1d9d
include the HTTP Permissions-Policy on non-HTML Content-Types
[CVE-2024-28103]

The application configurable Permissions-Policy is only
served on responses with an HTML related Content-Type.

This change allows all Content-Types to serve the
configured Permissions-Policy as there are many non-HTML
Content-Types that would benefit from this header.
(examples include image/svg+xml and application/xml)
2024-06-04 10:07:37 -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
Rafael Mendonça França
3922460df7
Link should be separated by comma.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link.
2024-05-31 22:04:38 +00:00
Rafael Mendonça França
8dc7a7fb15
Merge pull request #51975 from artfuldodger/patch-1
Clarify and make double rendering documentation consistent [ci skip]
2024-05-31 17:42:39 -04:00
Rafael Mendonça França
fe57bd2462
Lower case the link header
Since 1fbcf54289
the early hints will be checked against Rack::Link that requires all
headers to be lower cased.

Fixes #51961.
2024-05-31 21:00:22 +00:00
Jon Evans
625ec8301a Clarify and make double rendering documentation consistent
An action can _contain_ multiple renders/redirects, but only one can be _performed_.

"Attempting to try to" is redundant.

Also removes the `and return` recommendation in order to be consistent with the documentation updates from https://github.com/rails/rails/pull/45927
2024-05-31 12:42:44 -06:00
Jean Boussier
bc56661a3d
Merge pull request #51933 from zzak/51910
Handle case where script_name is a blank string
2024-05-31 11:12:29 +02:00
Cyril Blaecke
6cb41bae10
Keep previous CHANGELOG entry 2024-05-29 22:55:27 +02:00
Cyril Blaecke
cba374995c
Update actionpack CHANGELOG 2024-05-29 22:49:59 +02:00
Cyril Blaecke
931d2a890c
Update permissions policy list 2024-05-29 22:40:05 +02:00
zzak
234191c03b
Handle case where script_name is a blank string
TBD: where is it being set as ""

wip: add regression test
2024-05-29 21:24:07 +09:00
Joe Haig
10dc425e8e
Add CSP mapping for 'wasm-unsafe-eval'
The `'wasm-unsafe-eval'` keyword for the Content Security Policy allows the
loading and execution of WebAssembly modules without the need to allow unsafe
JavaScript execution via `'unsafe-eval'`. A mapping is added so that the symbol
`:wasm_unsafe_evel` can be used for this keyword in the policy configuration in
`config/initializers/content_security_policy.rb`.
2024-05-28 18:39:48 +00:00
Jamie McCarthy
dc34e293e0
ActionPack: fix BrowserBlocker versions
css-nesting is not fully supported until Chrome 120, Opera 106:
https://caniuse.com/css-nesting
https://developer.mozilla.org/en-US/docs/Web/CSS/Nesting_selector#browser_compatibility
2024-05-24 19:50:05 +00:00
Rafael Mendonça França
cff6b2cd8d
Merge pull request #51874 from stiig/fix-colspan-for-rails-routes
Fix colspan for representing search results in the rails routes
2024-05-24 15:47:05 -04:00
eileencodes
d189cbcb56
Revert "Merge pull request #51614 from gmcgibbon/defer_route_drawing"
This reverts commit e97db3b3957781c781a61fb01265feb2b57688bb, reversing
changes made to a27a1751cfd499f69499e943f12e3400b55a323e.

This is breaking application routes when running without eager load enabled.
2024-05-24 09:59:41 -04:00
Vasiliy Matyushin
48d7feaebd fix colspan for HtmlTableFormatter and dynamic search for routes 2024-05-24 11:49:36 +05:00
zzak
a0621e5946
Private methods do not need :nodoc: to be private API
Follow up to #51279

Co-authored-by: Gabriel Amaral <1706819+gabriel-amaral@users.noreply.github.com>
2024-05-24 06:56:19 +09:00
Andy Waite
a8fdfffe18
Look up route from requirements (#51850)
* Lookup route from requirements

* Add docs

* Strings instead of symbols

S

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

---------

Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-05-23 11:37:45 -07:00
Rafael Mendonça França
7ee34d9efb
Enable Rails minitest plugin in our rake tasks 2024-05-23 16:16:37 +00:00
Hartley McGuire
8cbf969e09
Temporarily fix multi-paragraph definition lists
The rdoc markdown parser does not currently parse multi-paragraph
definition lists correctly. Instead of putting both paragraphs inside
a single definition, only the first paragraph ends up in the definition
and the second paragraph is rendered after the definition list as a code
block.

Since 7.2 appears to be coming soon, this commit fixes the second
paragraph rendering as a code block by turning it into a second
definition. This doesn't strictly seem like the "correct" fix (compared
to fixing the rdoc markdown parser) but it gives us the visual result
that we want until rdoc is fixed.
2024-05-21 11:48:01 -04:00
Rafael Mendonça França
bf59d363fb
Clean CHANGELOG for 8.0 2024-05-13 16:55:52 +00:00
Rafael Mendonça França
37fd0e7fe4
Development of Rails 8.0 starts now
🎉
2024-05-13 16:45:20 +00:00
zzak
833c1c9a4d
Enable Lint/Debugger
This will prevent issues like be0cb4e8f9, which would have resulted in:

```
guides/rails_guides/generator.rb:16:1: W: Lint/Debugger: Remove debugger entry point require "debug".
require "debug"
^^^^^^^^^^^^^^^
```

Disabled the cop in actionpack tests for screenshot_helper and page_dump_helper:

```
actionpack/test/controller/integration_test.rb:1369:9: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
        save_and_open_page
        ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1381:11: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
          save_and_open_page
          ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1391:39: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
      assert_raise(InvalidResponse) { save_and_open_page }
                                      ^^^^^^^^^^^^^^^^^^
```

```
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:111:13: W: Lint/Debugger: Remove debugger entry point page.save_page(absolute_html_path).
            page.save_page(absolute_html_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:115:13: W: Lint/Debugger: Remove debugger entry point page.save_screenshot(absolute_image
_path).
            page.save_screenshot(absolute_image_path)
```

The DebuggerRequires option was first available in rubocop v1.63.0, in rubocop/rubocop#12766.
2024-05-13 13:41:18 +09:00
Gannon McGibbon
e97db3b395
Merge pull request #51614 from gmcgibbon/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called
2024-05-12 10:17:57 -04:00
Gert Goet
111b6ab1fb
Example requires delimiter 2024-05-10 12:40:35 +02:00
Gannon McGibbon
e54f869e43 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-05-08 23:43:06 -04:00
Jean Boussier
06d3b358df Replace allocations count by GC time in request logs
Allocations count is often an interesting proxy for performance,
but not necessarily the most relevant thing to include in request
logs, given they aren't a per thread metric, so the reporting
is widely innacurate in multi-threaded environments.

Since Ruby 3.1 there is now `GC.total_time` which is a monotonically
increasing counter of time spent in GC. It still isn't really a per
thread metric, but is is more interesting because it uses the same
unit as the response time, allowing to better see when you have a GC
pause performance issue.
2024-05-08 23:02:35 +02:00
fatkodima
702638291c
Fix tests without assertions in the framework 2024-04-30 23:29:30 +00:00