Skip to content

Merge remote mater#1

Merged
00dav00 merged 1382 commits into00dav00:masterfrom
rails:master
Dec 20, 2020
Merged

Merge remote mater#1
00dav00 merged 1382 commits into00dav00:masterfrom
rails:master

Conversation

@00dav00
Copy link
Owner

@00dav00 00dav00 commented Dec 20, 2020

No description provided.

David Heinemeier Hansson and others added 30 commits November 24, 2020 17:57
)

* Add `with_all_rich_text` method to eager load all RichText models at once

* Update actiontext/test/test_helper.rb

Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>

* Update actiontext/lib/action_text/attribute.rb

Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>

Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>
Move Spring machinery back to bin files
Wrap evaluation of db/seeds.rb with the executor
This links the first mention of each method to its API documentation,
similar to a Wikipedia article.

This also modifies the text in a few places to ensure that methods are
explicitly mentioned and linked.
Those tasks are deprecated though, just to maintain backwards compartibility
and ask people to update their scripts.

Fixes #40658.
Closes #40482

Prior to this commit it was possible to subscribe with
`ActionCable::Channel::Base` as the subscription class. While it doesn't
seem possible to exploit this in away way, it also doesn't seem like
something we need to allow.

This commit swaps [Module#>=][gte] with [Module#>][gt] to prevent
subscribing to a channel when `ActionCable::Channel::Base` is the
subscription class.

[gte]: https://ruby-doc.org/core-2.5.3/Module.html#method-i-3E-3D
[gt]: https://ruby-doc.org/core-2.5.3/Module.html#method-i-3E
…s run by ruby 3.0.0dev

This pull request addresses the `ArgumentError: missing keywords: :sql, :name`,
which has been reported at https://buildkite.com/rails/rails/builds/72990#c78d1e4c-5775-4758-9010-9ba71fdb6138

Follow up #39397

```ruby
$ ruby -v
ruby 3.0.0dev (2020-11-24T22:48:19Z master 63ad55cd88) [x86_64-linux]
$ cd actiontext
$ bin/test test/unit/model_test.rb -n test_eager_loading
Run options: -n test_eager_loading --seed 16493

E

Error:
ActionText::ModelTest#test_eager_loading:
ArgumentError: missing keywords: :sql, :name
    /home/yahonda/src/github.com/rails/rails/actiontext/test/test_helper.rb:29:in `block in assert_queries'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:186:in `finish'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:63:in `block in finish'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:63:in `each'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:63:in `finish'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:45:in `finish_with_state'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:30:in `instrument'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:688:in `log'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb:46:in `exec_query'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:536:in `select_prepared'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:67:in `select_all'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:103:in `select_all'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/querying.rb:47:in `find_by_sql'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation.rb:850:in `block in exec_queries'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation.rb:868:in `skip_query_cache_if_necessary'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation.rb:835:in `exec_queries'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation.rb:638:in `load'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation.rb:249:in `records'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation.rb:244:in `to_ary'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation/finder_methods.rb:553:in `find_nth_with_limit'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation/finder_methods.rb:538:in `find_nth'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation/finder_methods.rb:122:in `first'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/relation/finder_methods.rb:153:in `last'
    /home/yahonda/src/github.com/rails/rails/actiontext/test/unit/model_test.rb:93:in `block (2 levels) in <class:ModelTest>'
    /home/yahonda/src/github.com/rails/rails/actiontext/test/test_helper.rb:33:in `assert_queries'
    /home/yahonda/src/github.com/rails/rails/actiontext/test/unit/model_test.rb:93:in `block in <class:ModelTest>'

Error:
ActionText::ModelTest#test_eager_loading:
ArgumentError: missing keywords: :sql, :name
    /home/yahonda/src/github.com/rails/rails/actiontext/test/test_helper.rb:29:in `block in assert_queries'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:186:in `finish'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:63:in `block in finish'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:63:in `each'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/fanout.rb:63:in `finish'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:45:in `finish_with_state'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:30:in `instrument'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:688:in `log'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb:98:in `exec_rollback_db_transaction'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:378:in `rollback_db_transaction'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:22:in `rollback_db_transaction'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:205:in `rollback'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:302:in `block in rollback_transaction'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:300:in `rollback_transaction'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:328:in `rollback_transaction'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/test_fixtures.rb:168:in `block in teardown_fixtures'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/test_fixtures.rb:167:in `each'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/test_fixtures.rb:167:in `teardown_fixtures'
    /home/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/test_fixtures.rb:16:in `after_teardown'
    /home/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:51:in `after_teardown'

bin/test test/unit/model_test.rb:90

Finished in 0.117256s, 8.5284 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
$
```

Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
Address "ArgumentError: missing keywords: :sql, :name" with ruby 3.0.0dev
It might be non-obvious to a user that's new to ActiveStorage, how access control
to files is handled.
I suspect the `VALID_AUTOMATIC_INVERSE_MACROS` checking is to avoid
`has_and_belongs_to_many` association, but `has_and_belongs_to_many` is
defined as `has_many` with implicit through association, so all possible
macro variants are `:has_many`, `:has_one`, and `:belongs_to`, therefore
`VALID_AUTOMATIC_INVERSE_MACROS.include?(macro)` is always true, and in
that through association case it is already covered by `options[:through]`
checking.

https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations.rb#L1955-L1963
Guides: Add note on ActiveStorage URL security [ci skip]
…bscription

Do not allow subscribing to Base channel
[skip ci]  Fix examples for has_{one,many} :through :source and :source_type
When building the default middleware stack, the ActionDispatch::ActionableExceptions
middleware should only be used if the configuration has :consider_all_requests_local
set to true.

There is an existing check #actionable_request? in ActionableExceptions
that will prevent actionable exceptions from being dispatched, which
relies on the "action_dispatch.show_detailed_exceptions" header being
set to false. This check should remain in place as a second line of defense
in case the ActionableExceptions middleware is added back to the application.

However, we can go ahead and remove the middleware from the default stack
when the environment is not local.
Just scope this to just the two conceptually similar methods,
we're concerned with. (Don't submit rename PRs please.)
georgeclaghorn and others added 29 commits December 17, 2020 19:27
This change broke config.active_job.queue_name_prefix with eager-loading enabled (i.e. in production, by default).

This reverts commit a173a65, reversing
changes made to 89414f5.
Every existing file needs to be individually updated to have a
publicly-readable ACL (at least, this is true of S3 and DigitalOcean
Spaces), otherwise the files will fail to load.

This bit me when I was trying to introduce `public: true` in my
production Rails app.

I realize the docs already mention consulting the cloud service docs to
ensure that your bucket is "properly configured for public access", but
that's rather vague and I didn't really understand the potential issues
with individual files' public read permissions from the S3 docs.
before this, passing false would raise the following error
because a condition in AR would disregard the option entirely
if false was passed.

ArgumentError: Unknown key: :polymorphic. Valid keys are:
:class_name, :anonymous_class, :primary_key, :foreign_key,
:dependent, :validate, :inverse_of, :strict_loading, :autosave,
:required, :touch, :counter_cache, :optional, :default
allow passing false to :polymorphic option of belongs_to
Since delegated_type assumes that the foreign_key ends with `_id`,
`singular_id` defined by it does not work when the foreign_key does
not end with `id`. This commit fixes it by taking into account
`primary_key` and `foreign_key` in the options.
Returning `OID::Money` column type is accidentally skipped in a query
result due to the type is a subclass of `Type::Decimal`.

Fixes #40860.
Don't skip money's type cast for pluck and calculations
Because Bundler is a default gem, `require "bundler"` by itself will
load the default version of the gem, instead of the most recent version.
This can cause Rails commands to produce warnings like the following:

> Warning: the running version of Bundler (2.1.4) is older than the
> version that created the lockfile (2.2.2). We suggest you to upgrade
> to the version that created the lockfile by running
> `gem install bundler:2.2.2`.

Adding `gem "bundler"` allows the most recent version of the gem to be
loaded.
Load most recent version of Bundler in bin/spring
Save some allocations in ActionView digest
…n_update

Adds warning on usage of destroy_async. [ci skip]
…40870)

* Fix `SELECT COUNT` queries when rendering ActiveRecord collections

Fixes #40837

When rendering collections, calling `size` when the collection is an
ActiveRecord relation causes unwanted `SELECT COUNT(*)` queries. This
change ensures the collection is an array before getting the size, and
also loads the relation for any further array inspections.

* Test queries when rendering relation collections

* Add `length` support to partial collection iterator

Allows getting the size of a relation without duplicating records, but
still loads the relation. The length method existence needs to be
checked because you can pass in an `Enumerator`, which does not respond
to `length`.

* Ensure unsubscribed from notifications after tests

[Rafael Mendonça França + aar0nr]
```ruby
class User
  scope :active, -> { where(accepted: true, locked: false) }
end

User.active

User.active.invert_where
```
postgres: Make the initial type map query less expensive
Expose an `invert_where` method that will invert all scope conditions.
Active support cache - memcached store - consume dalli’s cache_nils option as skip_nil
…-docs

Add a note to the docs about existing apps for ActiveStorage public access
Use "default" as default queue for mailers test helpers
* Fixes #40218

Clarify the difference between Railtie initializers and config initializers in
the initialization guide.

* Update guides/source/initialization.md

Co-authored-by: Alan Savage <asavageiv@gmail.com>
Co-authored-by: Rafael França <rafael@franca.dev>
…rt_enqueued_email_with_as_default

Sets default mailer queue to default
Include ActiveSupport::Testing::Assertions in ActiveJob::TestHelpers
Fixes an indention issue which results in ill-formatted RDoc code rendering.
Fix RDoc code formatting for Railtie [ci skip]
The ever common extra = symbols are not needed in the loop, as it means the array is also rendered.
[ci skip] Fix full_messages_for example in getting started
Fix extra = in code example for _form.html.erb in Getting Started 6.4.1 [ci skip]
@00dav00 00dav00 merged commit 4dd2c72 into 00dav00:master Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.