The usage of `dispatch` in all logging methods causes common usages such
as `logger.info` to return an array of loggers, making it unsafe for an
application to upgrade to Rails 7.1.
Returning `nil` is more efficient, and is the default behavior when
using `Logger`.
The usage of `dispatch` in all logging methods causes common usages such
as `logger.info` to return an array of loggers, making it unsafe for an
application to upgrade to Rails 7.1.
Returning `nil` is more efficient, and is the default behavior when
using `Logger`.
This is too much complexity for something low value. Let's just always
warn when a test doesn't have any assertions.
If people want to raise an error or ignore them, they can do so by
overriding `Warning.warn`.
Ref: https://bugs.ruby-lang.org/issues/15554
This new Ruby 3.4 warning is still being fined tuned to reduce false positives,
so we shouldn't fail builds on it just yet.
It however caught one mistake in the test suite which is valuable.
Fix: https://github.com/rails/rails/pull/51426#issuecomment-2042611790
`perform_later` is supposed to return the Job instance on success,
and `false` on error.
When the `enqueue` is automatically delayed, it's of course impossible
to predict if the actual queueing will succeed, but for backward compatibility
reasons, it's best to assume it will.
If necessary, you can hold onto the job instance and check for
`#successfully_enqueued?` after the transaction has completed.
String.new with no arguments returns the empty string with ASCII-8BIT
encoding. Then, depending on each grapheme cluster of the string and
on the omission string, the resulting string might keep the ASCII-8BIT
encoding. With this change, we preserve the encoding of the original
string instead.
Note that String.new accepts an `encoding` keyword argument, like
```
String.new(encoding: Encoding::UTF_8)
```
However, instead of using that, we rely on `force_encoding` to set the
original encoding. This is so that String subclasses don't need to
preserve this keyword argument. For example, SafeBuffer doesn't.
Thanks to @jeremy for catching this!
* Switch ActiveSupport::TestCase teardown and setup callbacks to run in setup and teardown minitest lifecycle hooks.
Minitest provides `setup` and `teardown` lifecycle hooks to run code in. In general it is best practice to when defining your own test case class, to use `Minitest::TestCase.setup` and `Minitest::TestCase.teardown` instead of `before_setup` and `after_teardown`.
Per Minitest's Documentation on Lifecycle Hooks: https://docs.ruby-lang.org/en/2.1.0/MiniTest/Unit/LifecycleHooks.html
> before_setup()
> Runs before every test, before setup. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.
> after_teardown()
> Runs after every test, after teardown. This hook is meant for libraries to extend minitest. It is not meant to be used by test developers.
Since the `setup` and `teardown` ActiveSupport::TestCase callbacks are in essence user code, it makes sense to run during their corresponding Minitest Lifecycle hooks.
* Ensure test fixutres are torndown on errors in superclass after_teardown code.
By not adding wrapping the `teardown_fixtures` code, its possible that super raises an error and prevents the existing database transaction from rolling back.
`super` in general should only be calling `Minitest::Testcase.after_teardown` however, if another library were to override `Minitest::Testcase.after_teardown`, like the popular gem [rspec-mocks](https://github.com/rspec/rspec-mocks/blob/main/lib/rspec/mocks/minitest_integration.rb#L23) does, it causes all subsequent tests to retain any changes that were made to the database in the original test that errors.
* Remove unnecessary setup and teardown methods in tests
* update activesupport Changelog
* Fix linter issues in CHANGELOG
* fix tests with improper setup and teardown method definitions
* Fix final CHANGELOG lint
* Revert "Fix final CHANGELOG lint"
This reverts commit f30682eb629780862ccc63e1d3210dfe035e997e.
* Revert "fix tests with improper setup and teardown method definitions"
This reverts commit 1d5b88c8739695a4eed5c46924c9ffc6010353f5.
* Revert "Fix linter issues in CHANGELOG"
This reverts commit 60e89bd189cbcdf50d7e923a90ec5ebe1578a6e9.
* Revert "update activesupport Changelog"
This reverts commit 0f19bc324fec7a793cc34dcfede27017b5a24e46.
* Revert "Remove unnecessary setup and teardown methods in tests"
This reverts commit e5673f179ac01c814ab44017b97e7638aad6e775.
* Revert "Switch ActiveSupport::TestCase teardown and setup callbacks to run in setup and teardown minitest lifecycle hooks."
This reverts commit d08d92d86131d8643a275397d9b0c15995730a14.
* Rescue Minitest::Assertion errors in ActiveSupport::TestCase.teardown callback code to ensure all other after_teardown methods are called.
* Fix name of test class
* remove unused MyError class
* Fix module to not be in global namespace
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
This commit addresses CI failure
at https://buildkite.com/rails/rails-nightly/builds/108#018d57ac-4f2a-45f1-86b9-9015a7b0a463/1165-2002
* Error addressed by this commit
```
$ ruby -v
ruby 3.4.0dev (2024-01-30T10:19:23Z master 86547fd69d) [x86_64-linux]
$ rm Gemfile.lock
$ bundle install
$ cd activesupport
$ bin/test test/core_ext/object/to_query_test.rb -n test_hash_not_sorted_lexicographically_for_nested_structure
... snip ...
E
Error:
ToQueryTest#test_hash_not_sorted_lexicographically_for_nested_structure:
NameError: uninitialized constant ToQueryTest::URI
test/core_ext/object/to_query_test.rb:90:in `test_hash_not_sorted_lexicographically_for_nested_structure'
bin/test test/core_ext/object/to_query_test.rb:79
Finished in 0.000385s, 2597.3082 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
$
```
This behavior has been introduced since Ruby 3.4.0dev vendors URI from top level to `Gem::URI`
via d64d0b5423 .
Here is the RubyGems one.
https://github.com/rubygems/rubygems/pull/7386
* Save cache size by omit the prefix if unnecessary
* rename to straightforward naming.
* check the prefix directly instead of inspect
* Remove unused helper method
* add to changelog
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Follow-up to #50677.
Prior to this commit, all `ActiveSupport::CurrentAttributes` subclasses
stored their default values in the same `Hash`, causing default values
to leak between classes. This commit ensures each subclass maintains a
separate `Hash`.
This commit also simplifies the resolution of default values, replacing
the `merge_defaults!` method with `resolve_defaults`.
Extend the `.attribute` class method to accept a `:default` option for
its list of attributes:
```ruby
class Current < ActiveSupport::CurrentAttributes
attribute :counter, default: 0
end
```
Internally, `ActiveSupport::CurrentAttributes` will maintain a
`.defaults` class attribute to determine default values during instance
initialization.
Now that we require Ruby 3.1, we can assume `Process._fork` is
defined on MRI, hence we can trust that our decorator will
reliably detect forks so we no longer need to check the if
the pid changed in critical spots.
The introduction of the block argument means that `Object#with` can now
accept a `Symbol#to_proc` as the block argument:
```ruby
client.with(timeout: 5_000) do |c|
c.get("/commits")
end
```
Now that we dropped support for Ruby 2.7, we no longer
need to check if variables are defined before accessing them
to avoid the undefined variable warning.