Follow-up to #45344.
When using `config.load_default "7.1"`, the value is `false`, so the
value in `new_framework_defaults_7_1.rb` should be `false` as well.
This commit also adds configuration tests.
In minitest/minitest@6e06ac9 minitest changed such that it now accepts
`kwargs` instead of requiring kwargs to be shoved into the args array.
This is a good change but required some updates to our test code to get
the new version of minitest passing.
Changes are as follows:
1) Lock minitest to 5.15 for Ruby 2.7. We don't love this change but
it's pretty difficult to get 2.7 and 3.0 to play nicely together with
the new kwargs changes. Dropping 2.7 support isn't an option right
now for Rails. This is safe because all of the code changes here are
internal methods to Rails like assert_called_with. Applications
shouldn't be consuming them as they are no-doc'd.
2) Update the `assert_called_with` method to take any kwargs but also
the returns kwarg.
3) Update callers of `assert_called_with` to move the kwargs outside the
args array.
4) Update the message from marshaled exceptions. In 5.16 the exception
message is "result not reported" instead of "Wrapped undumpable
exception".
Co-authored-by: Matthew Draper <matthew@trebex.net>
activerecord-session_store was removed in 0ffe190, and has been
displaying a special error message when missing since Rails 4.0.
Replace the specific error message so that third party stores get nicer
error handling as well
This seems to be a pattern that was common around Rails 3 (for example,
it was last changed in 7ee5843). However, most of the usages were
removed in 36dd185 and this one looks like it was missed.
Some of the other files changed in 7ee5843 were later consolidated into
a root `load_paths.rb` file in 9f01dff which was later removed in
2abcdfd.
This removes the singularize from `where` which runs on all `expand_from_hash` keys which might be reflections or column names. This saves a lot of time by avoiding singularizing column names.
Previously in https://github.com/rails/rails/pull/45163 the singularize was removed entirely. after some reflection, I think it is better to at least give a warning for one release since `where` is a very popular API and the problems you can run into with incorrect relation could be hard to debug.
Configurable with `ActiveRecord::Base.allow_deprecated_singular_assocaitions_name = false` / `config.active_record.allow_deprecated_singular_assocaitions_name = false`
The `assert_called_with` helper allows passing a multi-dimensional array to
mock multiple calls to the same method for a given block. This works
fine now, but when adding support for real kwargs arguments to line up with
recent upgrades in Minitest, this approach is no longer workable because
we can't pass multiple sets of differing kwargs.
Rather than complicated this method further, this commit removes the
multi-call form of `assert_called_with` and modifies the tests that
currently make use of that functionality to just use the underlying
`Minitest::Mock` calls.
Co-authored-by: Eileen M. Uchitelle <eileencodes@gmail.com>
In #45162 it was discovered that the multi_db generator that was created
for 7.0 doesn't work correctly because that file is loaded _after_ the
initializer in active record is run. I tried moving everything to an
after_initialize but the middleware stack is frozen at that point. I
also attempted to fix this in #45353 but it just didn't feel right to
have to deprecate this behavior that _should_ work.
I then realized that most of the middleware in Rails is installed in the
middleware stack file in railties. If I move the middleware installation
to this file, everything works as necessary.
The only caveat is we need to check if `config` responds to
`active_record` but I think that should be fine - we already do that in
the framework defaults configuration.
Fixes#45162
If you use either of these frameworks, Active Job is used. That means
that only skipping Active Job will not really skip it, and whenever
app:update runs, Active Job will be added back.
In
f075be3dcb
did_you_mean and error_highlight now use `detailed_message` over
`message` to display errors.
For cases where we are testing `message`, in 3.2 and above we need to
test against `detailed_message` instead.
As far as I can tell in a Rails console when these errors are raised the
`detailed_message` is used so we shouldn't need to make other changes to
Rails. The only case where this isn't true is in the Railties changes -
we are explicitly formatting the did you mean message so we need to be
sure to call `detailed_message` here.
This fixes most of the failing tests for ruby-trunk.
Rails allows you to use a `shared` entry in the database yaml which gets
merged into other entries. This was broken when using a 3-tier config.
The change here ensures we're looping through all the configs. We know
we have a 3-tier config if the config is a hash and all the values
inside that config are a hash. If so we need to keep looping, otherwise
we have a standard 2-tier config.
Fixes #
Rails::Rack::Logger is one of the few (the only?) places where we aren't
able to use the preferred AS::N.instrument API with a block. This is
because we want to finish the event when the Rack body is closed, rather
than when the status and headers are first returned.
This switches to using the low-level `build_handle` API, which allows
safe interleaving of events and doesn't make use of thread or fiber
locals.
Since Puma 5.0 (puma/puma@05936689c8),
Puma will automatically set `workers` to `ENV["WEB_CONCURRENCY"] || 0`.
Additionally, if `ENV["WEB_CONCURRENCY"]` > 1, Puma will automatically
set `preload_app`.
This can lead to confusing scenarios for users who are unaware of this
behavior and have customized `config/puma.rb`. For example, if a user
uncomments the `workers` and `preload_app!` directives, it is clear that
Puma will preload the app, and the number of workers can be configured
by setting `ENV["WEB_CONCURRENCY"]`. If the user sets
`ENV["WEB_CONCURRENCY"]` > 1, but then changes their mind and removes
the `workers` or `preload_app!` directives *without* clearing
`ENV["WEB_CONCURRENCY"]`, Puma will still preload the app and launch
`ENV["WEB_CONCURRENCY"]` number of workers. Similarly, if a user
uncomments *only* the `workers` directive and sets
`ENV["WEB_CONCURRENCY"]` > 1, Puma will preload the app even though the
`preload_app!` directive is still commented out.
To avoid such scenarios, this commit removes the commented-out `workers`
and `preload_app!` directives from the default `config/puma.rb`.
Also, to improve discoverability of available configuration options,
this commit adds a link to the Puma DSL documentation at the top of the
file.
I was auditing which routes in my app do not actually a
have corresponding controller action. ActionMailbox's
inbound_mails has these 4 routes defined, which do not
actually work.
GET /rails/conductor/action_mailbox/inbound_emails/:id/edit
PATCH /rails/conductor/action_mailbox/inbound_emails/:id
PUT /rails/conductor/action_mailbox/inbound_emails/:id
DELETE /rails/conductor/action_mailbox/inbound_emails/:id
This avoids loading the Rakefile, which results in the app booting
twice, once in the development environment to load the Rake tasks, and
then another time in a fork to run the test runner in the test
environment.
Using Thor tasks with no parameters means passing arguments to the task
raises, whereas Rake accepts additional arguments that are not used:
$ bin/rake test:system SOMETHING=anything
Similarly, with Rake you can use --trace which won't work here.
If more than one test is using `use_postgresql` for it's tests and both
need to run `db:create` those tests will fail often due to them
running in parallel. I tried turning off parallelization for these tests
and they still ran in separate processes. Ultimately though, turning off
parallelization means we don't aren't testing parallelization. Instead I've
added `Process.pid` to the database name so it creates a database
specifically for that test. For cases where we need to set an explict
name a name can be passed in.
I also added an ensure to one of the tests so that the databases get
cleaned up and not left behind.
Fixes#45114Fixes#45158
Users, especially those who are creating an app for the first time,
might not be aware of the `rails credentials:diff --enroll` command.
This commit enrolls new apps in decrypted diffs by default so that users
benefit automatically. This behavior can be opted out of with the app
generator's `--skip-decrypted-diffs` flag.
This makes it possible to run a declarative-style test such as:
```ruby
class MyTest < ActiveSupport::TestCase
test "does something" do
# ...
end
end
```
Using its declared name:
```bash
$ bin/rails test test/my_test.rb -n "does something"
```
Instead of having to specify its expanded method name:
```bash
$ bin/rails test test/my_test.rb -n test_does_something
```
Co-authored-by: Eugene Kenny <elkenny@gmail.com>