Commit Graph

88522 Commits

Author SHA1 Message Date
Guillermo Iguaran 5a21634407
Merge pull request #48956 from skipkayhil/hm-rack-lint-show-exceptions-failsafe
Add test coverage for ShowExceptions failsafe
2023-08-18 16:08:41 -07:00
Guillermo Iguaran 4ec3a986d5
Merge pull request #48959 from skipkayhil/hm-clean-filters-requires
Remove uneeded requires of core_ext/string/filters
2023-08-18 16:03:44 -07:00
Rafael Mendonça França c82d624ea1
Fix documentation of with_routing in the class level
There is no assertions inside it.
2023-08-18 22:21:06 +00:00
Rafael Mendonça França ce36426c98
Initialize the variable in the init_internals method
This will avoid that the conditional assignment is executed every time
has_query_constraints? is called.
2023-08-18 22:13:14 +00:00
Rafael Mendonça França 08cd280866
Use class method module instead of DSL
This will make sure documentation is generated for the module.
2023-08-18 22:11:48 +00:00
eileencodes 3b5a4a56fb
Fix uninitialized ivar 2023-08-18 13:30:51 -04:00
Eileen M. Uchitelle 72f44412a6
Merge pull request #48971 from eileencodes/add-method-for-accessing-only-query-constraints
Add method for accessing only query constraints
2023-08-18 13:24:51 -04:00
eileencodes 784ca88173
Add method for accessing only query constraints
I'm working on an enhancement to query constraints that will require me
to know when we have query constraints but not a composite key.
Currently if you have a composite key it will be included in the query
constraints list. There's not a way to differentiate between the two
which means that we're forced into setting the query constraints on the
associations for the primary key.

This change adds a `has_query_constraints?` method so we can check the
class for query constraints. The options still work as well but we can
be sure we're always picking up the query constraints when they're
present.
2023-08-18 13:21:06 -04:00
Guillermo Iguaran fd9333458d
Merge pull request #48955 from skipkayhil/hm-fix-use-puma-detection
Fix served_url printed when using Puma & Rack 3
2023-08-17 17:26:03 -07:00
Rafael Mendonça França 244bdab8f0
Merge pull request #48958 from Mangara/Mangara-patch-1
Update job testing guidelines
2023-08-17 20:10:14 -04:00
Hartley McGuire 2d61a206f4
Fix served_url printed when using Puma & Rack 3
This `#use_puma?` check was [introduced][1] because Rails could
potentially display the wrong server URL in development if another host
or port is configured in `config/puma.rb`.

However, in Rack 3 the the name of the server class changed from
`Rack::Handler::Puma` to `Rackup::Handler::Puma`, which means that the
served_url is being logged again.

This commit fixes the check to accept either version of the class.
Additionally, puma was updated in Gemfile.lock because Puma 6.0.x prints
a deprecation warning about Rack::Handler that's fixed in 6.1.0.

[1]: 29648ff60e
2023-08-17 20:01:19 -04:00
Guillermo Iguaran 1e824aa8e0
Merge pull request #48961 from skipkayhil/hm-rack-lint-cable-health
Add Rack::Lint to ActionCable::Server health tests
2023-08-17 16:51:41 -07:00
Jonathan Hefner 261975dbef
Merge pull request #48970 from jonathanhefner/apidocs-main-page-fix-list-numbering
Fix list item numbering on API docs main page [ci-skip]
2023-08-17 16:26:54 -05:00
Jonathan Hefner 92dcc9a09f Fix list item numbering on API docs main page [ci-skip]
Follow-up to #47178.

RDoc's Markdown parser requires multi-line list items to use a hanging
indent of at least four spaces.  Otherwise, trailing lines will be
rendered as an independent paragraph, and the next list item will start
a new list.
2023-08-17 16:22:16 -05:00
Eileen M. Uchitelle ac5f9dec53
Merge pull request #48947 from eileencodes/use-IN-sql-over-OR-with-query-constraints
Use IN sql instead of OR sql for query constraints
2023-08-17 15:34:31 -04:00
eileencodes 0bbf4e86cb
Use IN sql intead of OR sql for query constraints
We originally implemented this project to use OR queries instead of IN
because it seemed like there was no way to do that without a row
constructor. While working on implementing this feature in our vitess
gem I noticed that we can actually get the queries we wanted, and the
new code is more performant than generating an OR.

SQL Before:

```sql
SELECT "sharded_comments".*
FROM "sharded_comments"
WHERE ("sharded_comments"."blog_id" = 969142904
AND ("sharded_comments"."blog_post_id" = 357271355
OR "sharded_comments"."blog_post_id" = 756811794)
OR "sharded_comments"."blog_id" = 308674288
AND "sharded_comments"."blog_post_id" = 1055755181)
```

SQL After:

```sql
SELECT "sharded_comments".*
FROM "sharded_comments"
WHERE "sharded_comments"."blog_id"
IN (969142904, 308674288)
AND "sharded_comments"."blog_post_id"
IN (357271355, 756811794, 1055755181)
```

Using one of the tests that utilizes this code path, I benchmarked the
queries. The new implementation is faster:

Before:

```
Warming up --------------------------------------
             queries   147.000  i/100ms
Calculating -------------------------------------
             queries      1.486k (± 3.2%) i/s -      7.497k in   5.050742s
```

After:

```
Warming up --------------------------------------
             queries   179.000  i/100ms
Calculating -------------------------------------
             queries      1.747k (± 4.5%) i/s -      8.771k in   5.031424s
```

We can probably improve this more but I think this query is more in line
with what we want and expect while also being more performant (without
having to build a new row constructor in arel).
2023-08-17 15:04:32 -04:00
Eileen M. Uchitelle b56f938b5f
Merge pull request #48964 from sinsoku/fix-method-name
Fix method name to `check_all_pending!`
2023-08-17 10:04:41 -04:00
Eileen M. Uchitelle 8abfcd752a
Merge pull request #48913 from ipc103/fix-parent-deprecation-warning
Allow parent to define alias method override
2023-08-17 09:46:26 -04:00
Jean Boussier 8eb051a6e6
Merge pull request #48967 from jdelStrother/distributed-redis-tests
Add test coverage for RedisCacheStore with Redis::Distributed / ConnectionPool
2023-08-17 14:05:12 +02:00
Jonathan del Strother 1b3d884bb3
Add test coverage for RedisCacheStore with Redis::Distributed / ConnectionPool
This 'forward-ports' some tests added against 7-0-stable here: #48952

Also fixes a bug in supports_expire_nx? when using distributed-redis.
2023-08-17 12:34:28 +01:00
Jean Boussier 7f8cdb1dc3
Merge pull request #48966 from byroot/fix-codespell-yarn
Do not codespell yarn.lock
2023-08-17 12:49:53 +02:00
Jean Boussier ca781c84cd Do not codespell yarn.lock 2023-08-17 12:48:20 +02:00
Takumi Shotoku 0e41e2cd8e
Fix method name to `check_all_pending!`
The method added in 03379d1f59 is `check_all_pending!`, not
`check_pending_migrations!`.
2023-08-17 16:51:39 +09:00
Yasuo Honda 2fa54931cf
Merge pull request #48949 from skipkayhil/hm-fix-suggesting-missing-gems
Do not suggest adding non-existent gems to Gemfile
2023-08-17 12:13:52 +09:00
Hartley McGuire c3c844ef3a
Add Rack::Lint to ActionCable::Server health tests
This adds additional coverage to ActionCable::Server to validate that
its output follow the Rack SPEC.

In addition to using Rack::CONTENT_TYPE for the Content-Type header,
there was another change required: the Content-Type header cannot be
specified when the Response status is 204, so the default health check
status was updated to 200
2023-08-16 22:49:32 -04:00
Hartley McGuire 92b716204e
Do not suggest adding non-existent gems to Gemfile
While these are valid Rack Handler names, their handler name is not the
same as their gem name.

| handler | gem        |
| ------- | ---------- |
| fastcgi | fcgi       |
| lsws    | ruby-lsapi |
2023-08-16 22:05:13 -04:00
Ian Candy a88f47d012 Only define attribute methods for class
Because we're using a class_attribute to track all of the attribute_aliases,
each subclass was regenerating the parent class methods, causing some unexpected
deprecation messages.

Instead, we can use a class instance variable to track the attributes aliased locally
in that particular subclass. We then walk up the chain and re-define the attribute methods
if they haven't been defined yet.
2023-08-16 18:23:02 -04:00
Hartley McGuire ff6e885d59
Remove uneeded requires of core_ext/string/filters
`actionpack/lib/action_dispatch/routing.rb`
- added: 013745151b
- removed: 93034ad7fe

`activejob/lib/active_job/log_subscriber.rb`
- added: b314ab555e
- removed: 5ab2034730

`activemodel/lib/active_model/errors.rb`
- added: cf7fac7e29
- removed: 9de6457ab0

`activerecord/lib/active_record/core.rb`
- added: b3bfa361c5
- removed: e1066f450d

`activesupport/lib/active_support/core_ext/module/introspection.rb`
- added: 358ac36edf
- removed: 167b4153ca

`activesupport/lib/active_support/duration.rb`
- added: 75924c4517
- removed: a91ea1d510

`railties/lib/rails/commands/server/server_command.rb`
- added: f217364893
- removed: 553b86fc75

`railties/lib/rails/command/base.rb`
- added: 6813edc7d9
- removed: b617a561d8
2023-08-16 17:39:25 -04:00
Sander Verdonschot 315db730cc
Update job testing guidelines
The current example test for jobs using `perform_now` to run the job inline. This is problematic for jobs that have retries configured, as any exception that is retried will be silently rescued. Ideally, the test will still fail because the job did not perform the work it was supposed to, but it makes finding the root cause a lot harder.

Testing with `perform_enqueued_jobs` and `perform_later` gets around this problem, as the retries are also performed immediately and, assuming that the exception happens consistently, it will bubble up after exhausting its retries.

Therefore, this PR updates the basic test guidance to suggest `perform_enqueued_jobs` and `perform_later` over `perform_now`.

Both described behaviours make it harder to test that a job raises a specific exception, so this requires special handling, which I added a paragraph on. I can pull that out to a separate PR if desired.
2023-08-16 16:49:46 -04:00
Hartley McGuire 6bf2ee09f7
Add test coverage for ShowExceptions failsafe
This adds additional test coverage to ShowExceptions, since one of the
possible responses it creates was not previously tested. Because of the
previous [addition][1] of Rack::Lint, this also demonstrates that the
Content-Type header needed to be fixed.

[1]: 339dda4a82
2023-08-16 16:00:25 -04:00
Akira Matsuda 5cf742ef51
ERB is no longer in use here since c2e756a944 2023-08-17 04:46:35 +09:00
Yasuo Honda 6db58ed7b6
Merge pull request #48898 from akhilgkrishnan/line-range-testing-guide
[skip ci] Testing by line range documentation added in guide
2023-08-16 08:33:50 +09:00
Akhil G Krishnan 8ae0b4ac7a [skip ci] Testing by line range documentation added in guide
Review changes updated

Update railties/lib/rails/commands/test/USAGE

Co-authored-by: Yasuo Honda <yasuo.honda@gmail.com>

Update guides/source/testing.md

Co-authored-by: Yasuo Honda <yasuo.honda@gmail.com>
2023-08-15 07:40:17 +05:30
Rafael Mendonça França 3779b5069d
Merge pull request #44262 from jdelStrother/duration-deserialization
Fix invalid durations with ActiveJob deserialization
2023-08-14 14:06:05 -04:00
Jean Boussier c0980d3036
Merge pull request #48936 from Shopify/jbuilder-collection-caching
Handle non-string partial body in ActionView::CollectionCaching
2023-08-14 11:52:48 +02:00
Jean Boussier 770060d93a Handle non-string partial body in ActionView::CollectionCaching
Followup: https://github.com/rails/rails/pull/48645

Some template engines such as `jbuilder` use these Action View primitives
with types other than strings, which breaks a bunch of assumptions.

I wish I could add a test for this, but this is deep in private methods
I don't see a way to cover this.
2023-08-14 11:20:43 +02:00
Jonathan del Strother 074d431493
Fix invalid durations in ActiveJob serialization
Durations that were round-tripped through ActiveJob::Arguments.serialize
would appear fine at a first glance, but trying to perform
duration-math on them would fail:

```
irb(main):001:0> d = ActiveJob::Arguments.deserialize(ActiveJob::Arguments.serialize([1.year]))[0]
=> 1 year
irb(main):002:0> d + 1.day
activesupport-6.1.4.4/lib/active_support/duration.rb:242:in `+': undefined method `merge' for [[:years, 1]]:Array (NoMethodError)
```
2023-08-13 11:27:16 +01:00
Rafael Mendonça França b6669e5605
Merge pull request #48927 from paulreece/remove_table_alias_writer
This removes the writer method for table_alias from Arel::Table.
2023-08-11 15:34:18 -04:00
Eileen M. Uchitelle 48243d42aa
Merge pull request #48928 from jozr/main-1
Reference correct method from 'deliver_now' example code
2023-08-11 11:53:15 -04:00
Josephine 03f5f45615
Reference correct method from 'deliver_now' example code 2023-08-11 07:11:16 -07:00
paulreece 6b56de4183 This removes the writer method for table_alias from Arel::Table. Since arel_table is a private API of the framework, no one should be modifying it. 2023-08-10 20:20:13 -04:00
zzak 81fa9136f8
Merge pull request #48924 from skipkayhil/hm-docs-fix-plusses
Fix code blocks using + instead of <tt> [ci skip]
2023-08-11 08:04:19 +09:00
Hartley McGuire bac6d8c079
Fix code blocks using + instead of <tt>
Pluses cannot be used to create code blocks when the content includes a
space.

Found using a regular expression:

```bash
$ rg '#\s[^+]*\+[^+]*\s[^+]*\S\+'
```
2023-08-10 13:05:05 -04:00
Eileen M. Uchitelle 22fa76c125
Merge pull request #48911 from jhbabon/fix/schema-cache-settings
Ensure schema_cache_dump settings are propagated to SchemaReflection class
2023-08-10 10:57:57 -04:00
Eileen M. Uchitelle 030652eeb9
Merge pull request #48916 from vinistock/vs/fix_engine_rake_task_on_windows
Use Pathnames for comparisons in the engine rake tasks
2023-08-10 10:54:07 -04:00
Vinicius Stock 3db3bd10af
Use Pathnames for comparisons in the engine rake tasks
We cannot compare paths directly to strings or that might fail on
different operating system. In this case, comparing to `/` fails on
Windows and we end up in endless recursion. We need to use
`Pathname#root?` to check if we reached the root of the folder structure
2023-08-10 09:37:41 -04:00
Eileen M. Uchitelle 6dd4579bcb
Merge pull request #48917 from Shopify/use-AR-deprecator-instead-of-AM
Use `ActiveRecord.deprecator` for the alias attribute deprecation
2023-08-09 17:32:12 -04:00
Nikita Vasilevsky 594f539324
Use `ActiveRecord.deprecator` for the alias attribute deprecation 2023-08-09 20:51:23 +00:00
Rafael Mendonça França 008db52a06
Merge pull request #46617 from r7kamura/feature/isolation-level-default
Remove unnecessary isolation_level setting from load_defaults 7.0
2023-08-09 15:37:25 -04:00
Rafael Mendonça França 809bce06a5
Merge pull request #48904 from p8/doc/use-sdoc-main-on-edge
Use sdoc main branch for edge API docs
2023-08-09 15:35:07 -04:00