Commit Graph

79737 Commits

Author SHA1 Message Date
Ryuta Kamizono
d7f5f4f97f Fix test_from_trusted_xml_allows_symbol_and_yaml_types failure
Caused by #41712.

https://buildkite.com/rails/rails/builds/75962#984c08aa-f57f-4f1c-ab31-7674fac12bbe/975-1397
2021-03-23 08:29:09 +09:00
Ryuta Kamizono
ee0420ffcc
Merge pull request #41731 from henrik/typo-rel
Fix typo in 6.1 release notes

[ci skip]
2021-03-23 08:24:29 +09:00
Rafael França
3262492bed
Merge pull request #41733 from henrik/consistent-quotes
More consistent quotes in template files
2021-03-22 18:22:21 -04:00
Rafael Mendonça França
741099e995
Really make OrderedHash private to the framework
Related to 0dd76540327be58999b0cb7584277724e60486d3.
2021-03-22 22:13:23 +00:00
Henrik Nyh
c13fee85ba More consistent quotes in template files 2021-03-22 22:07:27 +00:00
Rafael França
d86475af51
Merge pull request #41734 from rails/rm-fix-preload-extending
Batch queries that are the same but are using different extension
2021-03-22 18:03:20 -04:00
Rafael Mendonça França
57514ecf6c
Remove non-project specific entry from gitignore 2021-03-22 22:02:00 +00:00
Rafael França
84c9941642
Merge pull request #41080 from ankurp/standardrb-fixes
Update template files to follow the standard gem code formatter recommendations
2021-03-22 18:01:35 -04:00
Rafael Mendonça França
21e0c20667
Batch queries that are the same but are using different extension
If an association scope would generate the same query but have different
values for `extending`, `skip_query_cache` or `strict_loading` we should
consider them the same for the purpose of generating the preload
batches.
2021-03-22 21:51:18 +00:00
Henrik Nyh
959266998f Fix typo in 6.1 release notes 2021-03-22 21:15:17 +00:00
Ryuta Kamizono
e8fb1ac705
Merge pull request #41729 from kamipo/fix_test_polymorphic_assignment_foreign_key_type_string
Fix the test case for #14855 to catch a future regression correctly
2021-03-23 05:11:04 +09:00
Ryuta Kamizono
eb6a43a798 Fix the test case for #14855 to catch a future regression correctly
I've found the test doesn't catch a future regression since it doesn't
assert the result of the preload.

Also, add extra assertions to assert the difference of the value type.
2021-03-23 04:55:33 +09:00
Rafael Mendonça França
6388e300e5
Revert "Fix schema for members"
This reverts commit 8da6ba9cae21beae1ee3c379db7b7113d2731c9b.

The type is not standard to make sure preload work when the types don't
match.

See #14855.
2021-03-22 19:45:09 +00:00
OKURA Masafumi
d2bbb218cb Add table for shallow routing to routing doc
Shallow routes is one of the most difficult-to-use features for
generating routes in Rails.
To make it easier to understand how it works, a routing table
shows us the final result and really helps.
However, there's only one table for shallow routes and it's with
shallow_path option, which is even more complicated.
Adding a table for simpler shallow routes will help people
understand shallow routing's idea and usage better.

There's a drawback of this addition. Adding a large table occupies
the screen and might make it slightly difficult to walk through
the documentation.
2021-03-22 22:25:54 +09:00
Ryuta Kamizono
1ef30c19b5
Merge pull request #41712 from okuramasafumi/remove-ordered-hash
Remove requires and references to OrderedHash
2021-03-22 22:01:26 +09:00
OKURA Masafumi
0dd7654032 Remove some references to OrderedHash
OrderedHash is deprecated but there are some requires and references
to OrderedHash, which might be confusing.
As described in
https://github.com/rails/rails/issues/22681#issuecomment-166059717
OrderedHash is internal only so references in the docs should be
removed.
2021-03-22 21:14:32 +09:00
Ryuta Kamizono
7c67b94986 Make infinity handling symmetrical in cast and deserialize
Related: #41716, 30391e9ddba745d6bdc0b23f526ecf432dfe6adf.
2021-03-22 15:47:20 +09:00
Ryuta Kamizono
bbac68d428
Merge pull request #41716 from shunichi/fix-postgresql-infinity-datetime
Fix Float::INFINITY assignment to datetime attributes
2021-03-22 15:16:07 +09:00
Shunichi Ikegami
800d6bd1df Fix Float::INFINITY assignment to datetime attributes
After assigning string "infinity" to datetime attribute with postgresql adapter, reading it back gets Float::INFINITY.
But assigning Float::INFINITY to datetime attribute results in getting nil value when ActiveRecord::Base.time_zone_aware_attributes is true.
This is due to TimeZoneConverter not handling Float::INFINITY appropriately.
2021-03-22 13:56:06 +09:00
Ryuta Kamizono
ef99e7d509
Merge pull request #41602 from intrip/40550-fix-throw-abort-on-belongs-to-third-level-rollback
Fix rollback of parent destruction with nested dependent:destroy
2021-03-22 13:39:52 +09:00
Ryuta Kamizono
c7a036c2b6 Revert "Passing in a Hash instance as non-kwargs parameters has to be curly braced now"
This reverts commit d2f4541f126001e029078cc48a3a481e23ae3ed9.

It should work without curly braces.

See also: #41198, #41206, 81d90d81d0ee1fc1a649ab705119a71f2d04c8a2.
2021-03-22 11:21:33 +09:00
Ryuta Kamizono
81d90d81d0 Allow both current_page?(url_hash) and current_page?(**url_hash) on Ruby 2.7
Keyword argument warnings are caused by #41206 to allow both
`current_page?(url_hash)` and `current_page?(**url_hash)` on Ruby 3.0.

Unfortunately it is super hard to support that for both Ruby 2.7 and 3.0
with the same method signature.

Closes #41710.
2021-03-22 10:57:45 +09:00
Ryuta Kamizono
8c7883d3fc ✂️ [ci skip] 2021-03-22 04:46:11 +09:00
Henrik Nyh
515108ee03 'lookup' -> 'look up' in dummy webpacker.ymls
Corresponding to this fix: https://github.com/rails/webpacker/pull/2961
2021-03-21 12:36:56 +00:00
Ryuta Kamizono
043184d903 Fix end alignment 2021-03-21 15:46:36 +09:00
Ryuta Kamizono
1dcad65f80
Merge pull request #41707 from okuramasafumi/add-missing-require-to-hash_with_indifferent_access
Add missing require to hash_with_indifferent_access
2021-03-21 15:19:44 +09:00
Jean Boussier
39341de433 Remove useless include_private parameter in define_proxy_call
Since Ruby 2.7 `self.some_private_method` works fine.
So now that Ruby 2.7 is the minimal supported version,
`define_proxy_call` can always prepend `self.`
2021-03-20 14:27:53 -04:00
OKURA Masafumi
8a56380c53
Add documentation to HashWithIndifferentAccess#except
https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html#method-i-except
Currently HashWithIndifferentAccess#except has no documentation.
Since it's behavior is different from Hash#except, so it deserves
its own documentation.
2021-03-20 10:37:13 -04:00
OKURA Masafumi
e4de1ca9b5 Add missing require to hash_with_indifferent_access
When requiring only "active_support/hash_with_indifferent_access",
calling `slice!` method on `HashWithIndifferentAccess` object
causes `NoMethodError`.
This is caused by `slice!` method calls `super` which is defined
in "active_support/core_ext/hash/slice" that' not required by this file.
Adding `require "active_support/core_ext/hash/slice"` to hwia
resolves this issue.

Note: since all tests `require_relative "abstract_unit"` that requires
"active_support/core_ext/hash/slice" eventually, it's pretty hard to
test method behavior without require.
2021-03-20 22:10:38 +09:00
Ryuta Kamizono
a8a1afd455
Merge pull request #41703 from Shopify/tripple-dot
Use `...` argument forwarding instead of ruby2_keywords when possible
2021-03-20 02:38:59 +09:00
James Brooks
b1b0b22f50
Always render attachment partials as HTML with :html format inside trix editor 2021-03-19 13:35:09 -04:00
Máximo Mussini
1598ad5c4b
Ensure modules are preloaded correctly using rel=modulepreload.
Prior to this change, javascript_include_tag was sending a hint using
rel="preload" for all scripts, including those of type="module".

This causes the browser to make a request to preload the script, but
because the rel is incorrect, it won't be able to reuse it.

When passing type="module", it should use rel=modulepreload instead.

[0] developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content
[1] developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
[2] developer.mozilla.org/en-US/docs/Web/HTML/Link_types/modulepreload
2021-03-19 13:22:22 -04:00
Ryuta Kamizono
b5c4af7d52
Merge pull request #41068 from ricardotk002/fix-where-in-stmt-logging
Fix binds logging for "WHERE ... IN ..." statements
2021-03-20 01:41:29 +09:00
Jean Boussier
8a3fcad2d2 Use ... argument forwarding instead of ruby2_keywords when possible 2021-03-19 16:53:06 +01:00
Xavier Noria
6d38553b09 Removes the monkey-patch for Marshal.load
Marshal.load autoloads out of the box with Zeitwerk. See

    https://github.com/fxn/zeitwerk/blob/master/test/lib/zeitwerk/test_marshal.rb

for similar coverage.
2021-03-18 22:08:25 +01:00
eileencodes
8da6ba9cae
Fix schema for members
While working on another branch I noticed that this `resource_id` was
set to a string. I ran all the tests for sqlite, mysql, and postgres and
none failed so I think this is an oversight. As far as I can tell this
was supposed to be an integer.
2021-03-18 10:00:08 -04:00
Ricardo Díaz
2327ebfdc6 Disable parallel testing when running individual files
Setting up the parallel workers could be an overhead when running
individual files.

This patch disables that process in case the number of files to run
is less than one.

Results running a sample file:

Before:

```
actionpack $ bin/test test/controller/parameters/accessors_test.rb
Run options: --seed 48261

........................................................................

Finished in 0.211923s, 339.7460 runs/s, 552.0873 assertions/s.
72 runs, 117 assertions, 0 failures, 0 errors, 0 skips
```

After

```
actionpack $ bin/test test/controller/parameters/accessors_test.rb

Run options: --seed 5461

........................................................................

Finished in 0.008411s, 8560.2189 runs/s, 13910.3557 assertions/s.
72 runs, 117 assertions, 0 failures, 0 errors, 0 skips
```
2021-03-18 02:06:42 -05:00
eileencodes
5e300f1121
Fix test name
I copied the previous test and forgot to remain it. This commit fixes
the test name.
2021-03-17 09:19:55 -04:00
Ryuta Kamizono
6ab3191ed6
Merge pull request #41675 from kamipo/dont_use_cast_in_unboundable
Don't use `type.cast(value)` to emulate unchecked serialized value in `unboundable?`
2021-03-17 20:21:34 +09:00
Ryuta Kamizono
e8a358237e
Merge pull request #41690 from mollerhoj/patch-2
fix typo
2021-03-17 08:25:20 +09:00
Jens Dahl Møllerhøj
7d10ce1c92
fix typo 2021-03-16 23:57:22 +01:00
Eileen M. Uchitelle
6655c78349
Merge pull request #41688 from eileencodes/handle-false-for-strict-loading
Handle false in relation strict loading checks
2021-03-16 17:07:28 -04:00
eileencodes
226007daa1
Handle false in relation strict loading checks
Fixes: #41453
Closes: #41461

Previously when a model had strict loading set to true and then had a
relation set strict_loading to false the false wasn't considered when
deciding whether to raise/warn about strict loading.

Code example:

```ruby
class Dog < ActiveRecord::Base
  self.strict_loading_by_default = true

  has_many :treats, strict_loading: false
end
```

In the example, `dog.treats` would still raise even though
`strict_loading` was set to false. This is a bug effecting more than
Active Storage which is why I made this PR superceeding #41461. We need
to fix this for all applications since the behavior is a little
surprising. I took the test from ##41461 and the code suggestion from #41453
with some additions.

Co-authored-by: Radamés Roriz <radamesroriz@gmail.com>
2021-03-16 16:26:59 -04:00
John Hawthorn
35652100d2
Merge pull request #41597 from jhawthorn/preloader_batch_loader_query
Add Preloader::Association::LoaderQuery
2021-03-16 10:09:28 -07:00
Ankur Patel
3cc4207aa8
Update template files to follow the standard gem code formatter recommendations 2021-03-16 09:37:42 -04:00
John Hawthorn
eeef0bb26a Add Preloader::Association::LoaderQuery
This class represents the query a Preloader::Association uses to load
its records. This replaces the previous concept of a grouping_key and
serves both to group Preloader::Associations by their query and to run
the query to load the records (which nicely avoids using .first).

This should not change any functionality but should be slightly faster
due to being able to avoid calling `scope.to_sql` unless necessary.
2021-03-15 17:59:29 -07:00
John Hawthorn
3bac3a4e8b Implement hash equality for WhereClause
Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
2021-03-15 17:54:03 -07:00
John Hawthorn
1baa0684a0
Merge pull request #41596 from jhawthorn/preloader_branch
Allow Preloader to group through association queries
2021-03-15 17:50:35 -07:00
Rafael Mendonça França
d5ee11933f
Make sure the version of rake used in Rails apps work
Since 68a3f679d93a22160cca9a8bd9a869b8c766f860, we are requiring rake
0.13, so we need to specify that is the version we want.
2021-03-15 20:48:38 +00:00
Jean Boussier
c9a9dcd383 Reproduce the preloader regression in #41596
It's very peculiar, what seem to happen is that if some associations
are already loaded, the batching is done properly.
2021-03-15 12:36:21 -07:00