Otherwise running the test file directly like this:
$ be ruby -w -Ilib:test test/models/variant_test.rb
Fails with:
Error:
ActiveStorage::VariantTest#test_passes_content_type_on_upload:
NoMethodError: undefined method `stub' for #<ActiveStorage::Service::DiskService:0x00007fd53ba89ef0>
test/models/variant_test.rb:207:in `block in <class:VariantTest>'
It fixes the problem in propagating return_only_media_type_on_content_type
and fixes the corresponding test being ineffective.
The mentioned test addes the following line:
...config.action_dispatch.return_only_media_type_on_content_type = true
to the config and checks if it takes effect. However, in this scenario,
the value is already true before this line.
Moreover, the users are supposed to flip this from true to false in real
situations.
This commit flips the config in the test, making it to fail as
expected. The next commit will fix the failure.
In order for return_only_media_type_on_content_type to appropriately
take effect on ActionDispatch::Response, we want to know when
ActionDispatch::Response is loaded.
As load hooks for ActionDispatch would be too broad, the appropriate
registry is for ActionDispatch::Response itself.
Looking into other examples, a hook name is a full class name in
snake case with `_base` suffix omitted, if any. Therefore, in this case,
:action_dispatch_response seems appropriate.
Rational values are move precise than float values so when comparing
rationals values may be off by a few units that are hard to assert
equality. Let's make sure we are comparing the float value with float
values.
Since 6d1c9a9b23579d13b7cbdd3217ed2cfcc300e06e the `sql.active_record`
notification includes the connection that executed the query, but only
when the result comes from the database, not the query cache.
Active Storage keys are generated in two ways: in the `before_create`
callback added by `has_secure_token`, or by calling `key` before the
blob is saved. a273da7619ac6a2b2f98532a5610238c68ad219b broke the
former code path, and the latter was previously untested.
These failed previously because decimals floats don't make perfect
decimal numbers and Rational represents them exactly (either as decimal
or the inexact float value).
This changes the asserts to match that value.
We were using picoseconds as precision but some Ruby implementations
only support up to nanoseconds. Since that much precision was not needed
to test the feature I decreased the precision.
We hook into Kernel#fork and Process#fork, when they are invoked
we can trigger all the registered callbacks.
There is also a `check!` method that can be called to very cheaply
detect if the process was forked.
I'm not sure why using a class method is the preferred way 10 years ago.
b4b2574...226a2a9
But at least in Rails 6.1, using a scope is the preferred way since
several scoping issues will be fixed only for scopes.
[ci skip]