This patch just changes the inspect method on test case instances.
Seeing test instance internals probably isn't helpful when an exception
is raised (for example a `NoMethodError`).
This isn't as good as #45122, but should fix#45121
This change incorporates to Rails a feature called error_highlight that
has been available since Ruby 3.1. This allow Rails' error report screen
to display the fine-grained location where an error occurred (not only a
line number but also beginning and end column numbers of the code
fragment).
For ErrorHighlight, see https://bugs.ruby-lang.org/issues/17930 in
detail.
To use error_highlight, ExceptionWrapper now prefers
`Exception#backtrace_locations` (since Ruby 2.1), which returns an array
of `Thread::Backtrace::Location`s, instead of `Exception#backtrace`.
This is because error_highlight requires `Thread::Backtrace::Location`
to locate the column where an error was raised.
Co-Authored-By: John Hawthorn <john@hawthorn.email>
Co-Authored-By: Jean Boussier <jean.boussier@gmail.com>
This updates The Rails runner command to give a more helpful error
message when given a path as input but the file does not exist.
Instead of the cryptic "undefined local variable or method" the user is
told that the file could not be found.
I've gone for the simplest approach I could think of to identify when
the input is likely a file path: it ends with `".rb"`. This isn't a
perfect approach – there's nothing stopping someone passing a script
without an extension, and it's also possible to have valid Ruby syntax
that ends in `".rb" – but it does feel "good enough" and will make the
Rails runner slightly more user-friendly for those working with file
paths without negatively impacting those that are passing in Ruby
code.
In this https://github.com/rails/rails/blob/main/guides/source/action_cable_overview.md#connect-consumer part of the documentation it mentions a url that has https in it, when it should be a web socket url as mentioned here https://guides.rubyonrails.org/action_cable_overview.html#client-server-interaction
This MR is to create the confusion and to have consistency across the docs for the web socket url
Update guides/source/action_cable_overview.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Update guides/source/action_cable_overview.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
remove cable.js in action_cable overview
Update guides/source/action_cable_overview.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Update guides/source/action_cable_overview.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
remove cable.js in action_cable overview
Update guides/source/action_cable_overview.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Update guides/source/action_cable_overview.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
remove cable.js in action_cable overview
While working on another PR I noticed that we have 6 different tasks for
loading the schema; 3 for all dbs, 3 for namespaced dbs. They are:
* `db:schema:load`
* `db:schema:load:namespace`
* `db:test:load_schema`
* `db:test:load_schema:namespace`
* `db:test:load` (calls `db:test:load_schema` only)
* `db:test:load:namespace` (calls `db:test:load_schema:namespace` only)
I've removed the last two because they didn't call anything except for
another task and they were already private. I believe the original
`db:test:load` and `db:test:load:namescace` were added to handle whether
to load sql or ruby schema fules, but we no longer need that (it's
handled by the `load_schema` method directly now).
In addition I removed `:load_config, :check_protected_environments` from
the `db:schema:load:namespace` task because `purge` already calls these
so we don't need to do it twice.
I tried to remove `db:test:load_schema:namespace` and call
`db:schema:load:namespace` instead but we can't do that because
`db:test:load_schema:namespace` needs to set the environment to "test",
not use the current environment. `db:schema:load` also can't be used
instead of `db:test:load_schema` because it tries to load both dev and
test schemas, but it's callers want just the test schema.
The driver being used is an implementation detail of `redis-rb`.
If somehow something break on one driver but not the other, it should
be reported to redis-rb and fixed there.
Also `redis-rb` `5.0` has a totally new client and hiredis binding
so all this code no longer works with redis-rb 5.0.
This PR is similar to #36439 which moved schema migrations to the
connection and migration context. This PR does the same thing for the
internal metadata class.
Previously the metadata class was only accessible on Base which makes it
a little weird when switching connections. This didn't really cause any
issues but I noticed it when working on a PR to change how connections
work in the database rake tasks.
In a multiple database environment it makes sense to access the
`ar_internal_metadata` on the existing connection rather than on
`Base.connection`. I previously didn't implement this because I felt we
wanted only one place to ask for the metadata information but recently
realized that we were still recording metadata on all the databases, so
we might as well record it correctly.
Applications should notice no change in behavior because this is only
accessed through the rake tasks. Additionally behavior between schema
migrations and internal metadata are now more similar. Eventually I'd
like neither of these to inherit from or rely on Base, but we have a
lot more work to do before that's possible.
This adds support for reading binary column default values before the column data is read from the database.
This makes binary columns behave more like other column types with default values
Ref: https://github.com/rails/rails/pull/43550
If `executor_around_test_case` is enabled, all hooks must be
reentrant. However `allow_concurrency = false` register a
`MutexHook` that isn't reentrant.
So this commit replace it by a `Monitor` which does allow
reentrancy.
This will either be nil or a non-blank string. The case that it is the
empty string is handled (and replaced) at compile. I'd also argue that
it's possible that the empty string could be a valid value that's
considered to be a strict local, we just happen not to use that value
(preferring the "nokey" syntax).
This commit allows template lookups and render calls which find a
"strict local" template to reuse that template even when provided with
different locals.
This also makes Template#locals return nil for strict local templates,
to avoid leaking the details of the first lookup. Almost nothing calls
this method, so this should not be a significant change.
As the codespell dictionary changes between versions, we should declare
explicitly the version we are ready for so that this CI doesn't break
every time there is a new version.
Ideally this would be upgraded periodically to catch new errors, but I
don't think the need is urgent enough for us to fail CI on PRs.
Previously ripper tracker would misidentify the method name when called with a constant and assoc_hash.
This correctly finds the method name in those cases
In Ruby trunk date changed to use the gregorian calendar in
https://github.com/ruby/date/pull/73.
This had the result that dates not in the gregorian calendar can't be
compared to times not in the gregorian calendar. Since this test isn't
testing datetime comparison but rather that bc timestamps can be stored
in the database, we can compare with `Time.new(0) - 1.week` rather than
`Date.new(0) - 1.week`. I think this might be a bug in Ruby but I'm not
sure there's a great fix. For now however, let's get this test passing.
* Reference consistency check correction
By default all belongs_to relations are set to required, and required means Rails checks the reference consistency. That sentence is correct only if the optional is set to true, then in this case Rails not only allows this field to be null but also it does not check the reference consistency. But this is not the default behavior.
Co-authored-by: Eileen M. Uchitelle <eileencodes@users.noreply.github.com>