2021-09-15 18:22:51 -04:00
## Rails 7.0.0.alpha2 (September 15, 2021) ##
* No changes.
2021-09-15 17:55:08 -04:00
## Rails 7.0.0.alpha1 (September 15, 2021) ##
2021-09-04 03:30:08 -04:00
* `ActiveSupport::Dependencies` no longer installs a `const_missing` hook. Before this, you could push to the autoload paths and have constants autoloaded. This feature, known as the `classic` autoloader, has been removed.
*Xavier Noria*
* Private internal classes of `ActiveSupport::Dependencies` have been deleted, like `ActiveSupport::Dependencies::Reference` , `ActiveSupport::Dependencies::Blamable` , and others.
*Xavier Noria*
* The private API of `ActiveSupport::Dependencies` has been deleted. That includes methods like `hook!` , `unhook!` , `depend_on` , `require_or_load` , `mechanism` , and many others.
*Xavier Noria*
2021-09-04 03:32:04 -04:00
* Improves the performance of `ActiveSupport::NumberHelper` formatters by avoiding the use of exceptions as flow control.
2021-08-25 20:28:19 -04:00
*Mike Dalessio*
2021-08-24 12:33:08 -04:00
* Removed rescue block from `ActiveSupport::Cache::RedisCacheStore#handle_exception`
2021-08-23 23:29:18 -04:00
2021-08-24 12:33:08 -04:00
Previously, if you provided a `error_handler` to `redis_cache_store` , any errors thrown by
the error handler would be rescued and logged only. Removed the `rescue` clause from `handle_exception`
2021-09-04 03:30:08 -04:00
to allow these to be thrown.
2021-08-24 13:09:07 -04:00
*Nicholas A. Stuart*
2021-08-23 23:29:18 -04:00
2021-08-07 12:53:10 -04:00
* Allow entirely opting out of deprecation warnings.
2021-07-29 16:02:51 -04:00
Previously if you did `app.config.active_support.deprecation = :silence` , some work would
still be done on each call to `ActiveSupport::Deprecation.warn` . In very hot paths, this could
cause performance issues.
Now, you can make `ActiveSupport::Deprecation.warn` a no-op:
```ruby
config.active_support.report_deprecations = false
```
This is the default in production for new apps. It is the equivalent to:
```ruby
config.active_support.deprecation = :silence
config.active_support.disallowed_deprecation = :silence
```
but will take a more optimised code path.
*Alex Ghiculescu*
2021-07-16 14:32:23 -04:00
* Faster tests by parallelizing only when overhead is justified by the number
of them.
2021-07-12 11:37:52 -04:00
Running tests in parallel adds overhead in terms of database
setup and fixture loading. Now, Rails will only parallelize test executions when
there are enough tests to make it worth it.
2021-07-16 14:32:23 -04:00
This threshold is 50 by default, and is configurable via config setting in
your test.rb:
2021-07-12 11:37:52 -04:00
```ruby
2021-07-16 14:32:23 -04:00
config.active_support.test_parallelization_threshold = 100
```
It's also configurable at the test case level:
```ruby
class ActiveSupport::TestCase
2021-07-20 21:08:08 -04:00
parallelize threshold: 100
2021-07-16 14:32:23 -04:00
end
2021-07-12 11:37:52 -04:00
```
*Jorge Manrubia*
2021-03-22 05:25:49 -04:00
* OpenSSL constants are now used for Digest computations.
*Dirkjan Bussink*
2021-03-28 16:06:26 -04:00
* `TimeZone.iso8601` now accepts valid ordinal values similar to Ruby's `Date._iso8601` method.
A valid ordinal value will be converted to an instance of `TimeWithZone` using the `:year`
and `:yday` fragments returned from `Date._iso8601` .
```ruby
twz = ActiveSupport::TimeZone["Eastern Time (US & Canada)"].iso8601("21087")
twz.to_a[0, 6] == [0, 0, 0, 28, 03, 2021]
```
*Steve Laing*
2021-07-20 20:15:10 -04:00
* `Time#change` and methods that call it (e.g. `Time#advance` ) will now
2021-06-23 18:44:35 -04:00
return a `Time` with the timezone argument provided, if the caller was
initialized with a timezone argument.
Fixes [#42467 ](https://github.com/rails/rails/issues/42467 ).
*Alex Ghiculescu*
2021-07-20 21:08:08 -04:00
* Allow serializing any module or class to JSON by name.
2021-06-18 07:54:43 -04:00
*Tyler Rick* , *Zachary Scott*
2021-06-03 09:16:14 -04:00
* Raise `ActiveSupport::EncryptedFile::MissingKeyError` when the
`RAILS_MASTER_KEY` environment variable is blank (e.g. `""` ).
*Sunny Ripert*
2021-05-23 16:22:43 -04:00
* The `from:` option is added to `ActiveSupport::TestCase#assert_no_changes` .
It permits asserting on the initial value that is expected not to change.
```ruby
assert_no_changes -> { Status.all_good? }, from: true do
post :create, params: { status: { ok: true } }
end
```
2021-06-03 09:16:14 -04:00
2021-05-23 16:22:43 -04:00
*George Claghorn*
2021-05-02 05:58:54 -04:00
* Deprecate `ActiveSupport::SafeBuffer` 's incorrect implicit conversion of objects into string.
Except for a few methods like `String#%` , objects must implement `#to_str`
2021-05-03 10:09:25 -04:00
to be implicitly converted to a String in string operations. In some
2021-05-02 05:58:54 -04:00
circumstances `ActiveSupport::SafeBuffer` was incorrectly calling the
explicit conversion method (`#to_s`) on them. This behavior is now
deprecated.
*Jean Boussier*
2021-07-20 21:08:08 -04:00
* Allow nested access to keys on `Rails.application.credentials` .
2021-04-29 15:25:52 -04:00
Previously only top level keys in `credentials.yml.enc` could be accessed with method calls. Now any key can.
For example, given these secrets:
```yml
aws:
2021-07-20 21:08:08 -04:00
access_key_id: 123
secret_access_key: 345
2021-04-29 15:25:52 -04:00
```
2021-07-20 21:08:08 -04:00
`Rails.application.credentials.aws.access_key_id` will now return the same thing as
`Rails.application.credentials.aws[:access_key_id]` .
2021-04-29 15:25:52 -04:00
*Alex Ghiculescu*
2021-04-26 05:20:59 -04:00
* Added a faster and more compact `ActiveSupport::Cache` serialization format.
It can be enabled with `config.active_support.cache_format_version = 7.0` or
2021-05-26 16:16:26 -04:00
`config.load_defaults 7.0` . Regardless of the configuration Active Support
2021-04-26 05:20:59 -04:00
7.0 can read cache entries serialized by Active Support 6.1 which allows to
upgrade without invalidating the cache. However Rails 6.1 can't read the
new format, so all readers must be upgraded before the new format is enabled.
*Jean Boussier*
2021-04-19 05:26:34 -04:00
* Add `Enumerable#sole` , per `ActiveRecord::FinderMethods#sole` . Returns the
sole item of the enumerable, raising if no items are found, or if more than
one is.
*Asherah Connor*
2021-04-11 05:32:34 -04:00
* Freeze `ActiveSupport::Duration#parts` and remove writer methods.
Durations are meant to be value objects and should not be mutated.
*Andrew White*
2021-04-12 05:23:27 -04:00
* Fix `ActiveSupport::TimeZone#utc_to_local` with fractional seconds.
When `utc_to_local_returns_utc_offset_times` is false and the time
instance had fractional seconds the new UTC time instance was out by
a factor of 1,000,000 as the `Time.utc` constructor takes a usec
value and not a fractional second value.
*Andrew White*
2021-04-03 12:30:32 -04:00
* Add `expires_at` argument to `ActiveSupport::Cache` `write` and `fetch` to set a cache entry TTL as an absolute time.
```ruby
Rails.cache.write(key, value, expires_at: Time.now.at_end_of_hour)
```
*Jean Boussier*
2021-04-04 11:57:51 -04:00
* Deprecate `ActiveSupport::TimeWithZone.name` so that from Rails 7.1 it will use the default implementation.
*Andrew White*
Deprecates `Enumerable#sum` and `Array#sum`
Ruby (2.4+) includes a native implementation of `sum` with significant
performance gains. Rails 7.1 will be removing `Enumerable#sum` and
`Array#sum` in favor of Ruby's native implementation.
This commit adds a deprecation warning to calls with non-numeric
arguments without a suitable initial argument as those will be required
once Rails removes this functionality.
Some examples that will now trigger a deprecation warning:
>> %w[foo bar].sum
>> [[1, 2], [3, 4, 5]].sum
To avoid the deprecation warning they should now invoked as follows:
>> %w[foo bar].sum('')
>> [[1, 2], [3, 4, 5]].sum([])
In order to prepare for the deprecation on Rails 7.1, it also
deprecates `[nil].sum == 0`, which in Ruby's native implementation
throws a `TypeError`.
2021-04-26 14:18:27 -04:00
* Deprecates Rails custom `Enumerable#sum` and `Array#sum` in favor of Ruby's native implementation which
is considerably faster.
Ruby requires an initializer for non-numeric type as per examples below:
```ruby
2021-05-23 16:22:43 -04:00
%w[foo bar].sum('')
Deprecates `Enumerable#sum` and `Array#sum`
Ruby (2.4+) includes a native implementation of `sum` with significant
performance gains. Rails 7.1 will be removing `Enumerable#sum` and
`Array#sum` in favor of Ruby's native implementation.
This commit adds a deprecation warning to calls with non-numeric
arguments without a suitable initial argument as those will be required
once Rails removes this functionality.
Some examples that will now trigger a deprecation warning:
>> %w[foo bar].sum
>> [[1, 2], [3, 4, 5]].sum
To avoid the deprecation warning they should now invoked as follows:
>> %w[foo bar].sum('')
>> [[1, 2], [3, 4, 5]].sum([])
In order to prepare for the deprecation on Rails 7.1, it also
deprecates `[nil].sum == 0`, which in Ruby's native implementation
throws a `TypeError`.
2021-04-26 14:18:27 -04:00
# instead of %w[foo bar].sum
2021-05-23 16:22:43 -04:00
Deprecates `Enumerable#sum` and `Array#sum`
Ruby (2.4+) includes a native implementation of `sum` with significant
performance gains. Rails 7.1 will be removing `Enumerable#sum` and
`Array#sum` in favor of Ruby's native implementation.
This commit adds a deprecation warning to calls with non-numeric
arguments without a suitable initial argument as those will be required
once Rails removes this functionality.
Some examples that will now trigger a deprecation warning:
>> %w[foo bar].sum
>> [[1, 2], [3, 4, 5]].sum
To avoid the deprecation warning they should now invoked as follows:
>> %w[foo bar].sum('')
>> [[1, 2], [3, 4, 5]].sum([])
In order to prepare for the deprecation on Rails 7.1, it also
deprecates `[nil].sum == 0`, which in Ruby's native implementation
throws a `TypeError`.
2021-04-26 14:18:27 -04:00
[[1, 2], [3, 4, 5]].sum([])
2021-07-20 21:08:08 -04:00
# instead of [[1, 2], [3, 4, 5]].sum
Deprecates `Enumerable#sum` and `Array#sum`
Ruby (2.4+) includes a native implementation of `sum` with significant
performance gains. Rails 7.1 will be removing `Enumerable#sum` and
`Array#sum` in favor of Ruby's native implementation.
This commit adds a deprecation warning to calls with non-numeric
arguments without a suitable initial argument as those will be required
once Rails removes this functionality.
Some examples that will now trigger a deprecation warning:
>> %w[foo bar].sum
>> [[1, 2], [3, 4, 5]].sum
To avoid the deprecation warning they should now invoked as follows:
>> %w[foo bar].sum('')
>> [[1, 2], [3, 4, 5]].sum([])
In order to prepare for the deprecation on Rails 7.1, it also
deprecates `[nil].sum == 0`, which in Ruby's native implementation
throws a `TypeError`.
2021-04-26 14:18:27 -04:00
```
*Alberto Mota*
Disable parallel testing when running individual files
Setting up the parallel workers could be an overhead when running
individual files.
This patch disables that process in case the number of files to run
is less than one.
Results running a sample file:
Before:
```
actionpack $ bin/test test/controller/parameters/accessors_test.rb
Run options: --seed 48261
........................................................................
Finished in 0.211923s, 339.7460 runs/s, 552.0873 assertions/s.
72 runs, 117 assertions, 0 failures, 0 errors, 0 skips
```
After
```
actionpack $ bin/test test/controller/parameters/accessors_test.rb
Run options: --seed 5461
........................................................................
Finished in 0.008411s, 8560.2189 runs/s, 13910.3557 assertions/s.
72 runs, 117 assertions, 0 failures, 0 errors, 0 skips
```
2021-02-24 17:42:34 -05:00
* Tests parallelization is now disabled when running individual files to prevent the setup overhead.
It can still be enforced if the environment variable `PARALLEL_WORKERS` is present and set to a value greater than 1.
*Ricardo Díaz*
2021-02-22 11:42:48 -05:00
* Fix proxying keyword arguments in `ActiveSupport::CurrentAttributes` .
*Marcin Kołodziej*
2021-02-11 05:15:10 -05:00
* Add `Enumerable#maximum` and `Enumerable#minimum` to easily calculate the maximum or minimum from extracted
elements of an enumerable.
```ruby
payments = [Payment.new(5), Payment.new(15), Payment.new(10)]
payments.minimum(:price) # => 5
2021-03-10 00:27:53 -05:00
payments.maximum(:price) # => 15
2021-02-11 05:15:10 -05:00
```
This also allows passing enumerables to `fresh_when` and `stale?` in Action Controller.
See PR [#41404 ](https://github.com/rails/rails/pull/41404 ) for an example.
*Ayrton De Craene*
2021-02-09 09:16:38 -05:00
* `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
```ruby
config.cache_store = :mem_cache_store, nil
# is now equivalent to
config.cache_store = :mem_cache_store
# and is also equivalent to
config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
# which is the fallback behavior of Dalli
```
This helps those migrating from `:dalli_store` , where an explicit `nil` was permitted.
*Michael Overmeyer*
2021-02-05 11:28:50 -05:00
* Add `Enumerable#in_order_of` to put an Enumerable in a certain order by a key.
*DHH*
2021-02-02 13:20:39 -05:00
* `ActiveSupport::Inflector.camelize` behaves expected when provided a symbol `:upper` or `:lower` argument. Matches
`String#camelize` behavior.
*Alex Ghiculescu*
2020-12-28 19:30:40 -05:00
* Raises an `ArgumentError` when the first argument of `ActiveSupport::Notification.subscribe` is
invalid.
*Vipul A M*
2020-11-27 16:46:58 -05:00
* `HashWithIndifferentAccess#deep_transform_keys` now returns a `HashWithIndifferentAccess` instead of a `Hash` .
*Nathaniel Woodthorpe*
2021-07-20 21:08:08 -04:00
* Consume dalli’ s `cache_nils` configuration as `ActiveSupport::Cache` 's `skip_nil` when using `MemCacheStore` .
2020-12-18 02:40:33 -05:00
*Ritikesh G*
2021-07-20 21:08:08 -04:00
* Add `RedisCacheStore#stats` method similar to `MemCacheStore#stats` . Calls `redis#info` internally.
2020-12-29 02:52:24 -05:00
*Ritikesh G*
2020-07-25 22:19:34 -04:00
2020-12-02 18:37:26 -05:00
Please check [6-1-stable ](https://github.com/rails/rails/blob/6-1-stable/activesupport/CHANGELOG.md ) for previous changes.