activesupport 6.1.4.6 → 7.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +151 -551
  3. data/MIT-LICENSE +1 -1
  4. data/lib/active_support/actionable_error.rb +1 -1
  5. data/lib/active_support/array_inquirer.rb +0 -2
  6. data/lib/active_support/benchmarkable.rb +2 -2
  7. data/lib/active_support/cache/file_store.rb +15 -9
  8. data/lib/active_support/cache/mem_cache_store.rb +119 -28
  9. data/lib/active_support/cache/memory_store.rb +21 -13
  10. data/lib/active_support/cache/null_store.rb +10 -2
  11. data/lib/active_support/cache/redis_cache_store.rb +39 -59
  12. data/lib/active_support/cache/strategy/local_cache.rb +29 -49
  13. data/lib/active_support/cache.rb +189 -45
  14. data/lib/active_support/callbacks.rb +35 -31
  15. data/lib/active_support/concern.rb +5 -5
  16. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +2 -4
  17. data/lib/active_support/concurrency/share_lock.rb +2 -2
  18. data/lib/active_support/configurable.rb +6 -3
  19. data/lib/active_support/configuration_file.rb +1 -1
  20. data/lib/active_support/core_ext/array/access.rb +1 -5
  21. data/lib/active_support/core_ext/array/conversions.rb +6 -6
  22. data/lib/active_support/core_ext/array/grouping.rb +6 -6
  23. data/lib/active_support/core_ext/big_decimal/conversions.rb +1 -1
  24. data/lib/active_support/core_ext/date/blank.rb +1 -1
  25. data/lib/active_support/core_ext/date/calculations.rb +2 -2
  26. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  27. data/lib/active_support/core_ext/digest/uuid.rb +13 -12
  28. data/lib/active_support/core_ext/enumerable.rb +64 -12
  29. data/lib/active_support/core_ext/file/atomic.rb +1 -1
  30. data/lib/active_support/core_ext/hash/keys.rb +1 -1
  31. data/lib/active_support/core_ext/kernel/reporting.rb +4 -4
  32. data/lib/active_support/core_ext/module/delegation.rb +2 -8
  33. data/lib/active_support/core_ext/name_error.rb +2 -8
  34. data/lib/active_support/core_ext/numeric/conversions.rb +2 -2
  35. data/lib/active_support/core_ext/object/blank.rb +2 -2
  36. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  37. data/lib/active_support/core_ext/object/duplicable.rb +11 -0
  38. data/lib/active_support/core_ext/object/json.rb +29 -24
  39. data/lib/active_support/core_ext/object/to_query.rb +2 -2
  40. data/lib/active_support/core_ext/object/try.rb +20 -20
  41. data/lib/active_support/core_ext/range/compare_range.rb +0 -25
  42. data/lib/active_support/core_ext/range/each.rb +1 -1
  43. data/lib/active_support/core_ext/range/include_time_with_zone.rb +1 -1
  44. data/lib/active_support/core_ext/string/filters.rb +1 -1
  45. data/lib/active_support/core_ext/string/inflections.rb +1 -1
  46. data/lib/active_support/core_ext/string/output_safety.rb +60 -36
  47. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +0 -8
  48. data/lib/active_support/core_ext/time/calculations.rb +6 -5
  49. data/lib/active_support/core_ext/time/zones.rb +2 -17
  50. data/lib/active_support/core_ext/uri.rb +1 -15
  51. data/lib/active_support/current_attributes.rb +17 -1
  52. data/lib/active_support/dependencies/interlock.rb +10 -18
  53. data/lib/active_support/dependencies/require_dependency.rb +28 -0
  54. data/lib/active_support/dependencies.rb +58 -788
  55. data/lib/active_support/deprecation/behaviors.rb +4 -1
  56. data/lib/active_support/deprecation/method_wrappers.rb +3 -3
  57. data/lib/active_support/deprecation/proxy_wrappers.rb +1 -1
  58. data/lib/active_support/deprecation.rb +1 -1
  59. data/lib/active_support/descendants_tracker.rb +12 -9
  60. data/lib/active_support/digest.rb +5 -3
  61. data/lib/active_support/duration/iso8601_parser.rb +3 -3
  62. data/lib/active_support/duration/iso8601_serializer.rb +9 -1
  63. data/lib/active_support/duration.rb +77 -48
  64. data/lib/active_support/encrypted_configuration.rb +11 -1
  65. data/lib/active_support/encrypted_file.rb +1 -1
  66. data/lib/active_support/environment_inquirer.rb +1 -1
  67. data/lib/active_support/evented_file_update_checker.rb +1 -1
  68. data/lib/active_support/execution_wrapper.rb +13 -16
  69. data/lib/active_support/fork_tracker.rb +2 -4
  70. data/lib/active_support/gem_version.rb +4 -4
  71. data/lib/active_support/hash_with_indifferent_access.rb +3 -1
  72. data/lib/active_support/i18n.rb +1 -0
  73. data/lib/active_support/inflector/inflections.rb +11 -4
  74. data/lib/active_support/inflector/methods.rb +23 -47
  75. data/lib/active_support/json/encoding.rb +3 -3
  76. data/lib/active_support/key_generator.rb +18 -1
  77. data/lib/active_support/locale/en.yml +1 -1
  78. data/lib/active_support/log_subscriber.rb +13 -3
  79. data/lib/active_support/logger_thread_safe_level.rb +5 -13
  80. data/lib/active_support/message_encryptor.rb +3 -3
  81. data/lib/active_support/message_verifier.rb +4 -4
  82. data/lib/active_support/messages/metadata.rb +2 -2
  83. data/lib/active_support/multibyte/chars.rb +10 -11
  84. data/lib/active_support/multibyte/unicode.rb +2 -2
  85. data/lib/active_support/multibyte.rb +1 -1
  86. data/lib/active_support/notifications/fanout.rb +31 -11
  87. data/lib/active_support/notifications/instrumenter.rb +17 -0
  88. data/lib/active_support/notifications.rb +10 -0
  89. data/lib/active_support/number_helper/number_converter.rb +1 -3
  90. data/lib/active_support/number_helper/number_to_currency_converter.rb +11 -6
  91. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
  92. data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
  93. data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -1
  94. data/lib/active_support/number_helper/rounding_helper.rb +1 -5
  95. data/lib/active_support/number_helper.rb +0 -2
  96. data/lib/active_support/option_merger.rb +4 -16
  97. data/lib/active_support/ordered_hash.rb +1 -1
  98. data/lib/active_support/parameter_filter.rb +5 -0
  99. data/lib/active_support/per_thread_registry.rb +1 -0
  100. data/lib/active_support/railtie.rb +34 -11
  101. data/lib/active_support/reloader.rb +1 -1
  102. data/lib/active_support/rescuable.rb +2 -2
  103. data/lib/active_support/secure_compare_rotator.rb +1 -1
  104. data/lib/active_support/string_inquirer.rb +0 -2
  105. data/lib/active_support/subscriber.rb +5 -0
  106. data/lib/active_support/tagged_logging.rb +1 -1
  107. data/lib/active_support/test_case.rb +9 -21
  108. data/lib/active_support/testing/assertions.rb +35 -5
  109. data/lib/active_support/testing/deprecation.rb +1 -1
  110. data/lib/active_support/testing/isolation.rb +1 -1
  111. data/lib/active_support/testing/method_call_assertions.rb +5 -5
  112. data/lib/active_support/testing/parallelization/server.rb +4 -0
  113. data/lib/active_support/testing/parallelization/worker.rb +3 -0
  114. data/lib/active_support/testing/parallelization.rb +4 -0
  115. data/lib/active_support/testing/parallelize_executor.rb +76 -0
  116. data/lib/active_support/testing/stream.rb +3 -5
  117. data/lib/active_support/testing/tagged_logging.rb +1 -1
  118. data/lib/active_support/testing/time_helpers.rb +13 -2
  119. data/lib/active_support/time_with_zone.rb +19 -6
  120. data/lib/active_support/values/time_zone.rb +25 -9
  121. data/lib/active_support/xml_mini/jdom.rb +1 -1
  122. data/lib/active_support/xml_mini/libxml.rb +5 -5
  123. data/lib/active_support/xml_mini/libxmlsax.rb +1 -1
  124. data/lib/active_support/xml_mini/nokogiri.rb +4 -4
  125. data/lib/active_support/xml_mini/nokogirisax.rb +1 -1
  126. data/lib/active_support/xml_mini/rexml.rb +1 -1
  127. data/lib/active_support/xml_mini.rb +2 -1
  128. data/lib/active_support.rb +14 -1
  129. metadata +14 -28
  130. data/lib/active_support/core_ext/marshal.rb +0 -26
  131. data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -117
data/CHANGELOG.md CHANGED
@@ -1,675 +1,275 @@
1
- ## Rails 6.1.4.6 (February 11, 2022) ##
1
+ ## Rails 7.0.0.alpha1 (September 15, 2021) ##
2
2
 
3
- * Fix Reloader method signature to work with the new Executor signature
4
-
5
-
6
- ## Rails 6.1.4.5 (February 11, 2022) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 6.1.4.4 (December 15, 2021) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 6.1.4.3 (December 14, 2021) ##
17
-
18
- * No changes.
19
-
20
-
21
- ## Rails 6.1.4.2 (December 14, 2021) ##
22
-
23
- * No changes.
24
-
25
-
26
- ## Rails 6.1.4.1 (August 19, 2021) ##
27
-
28
- * No changes.
29
-
30
-
31
- ## Rails 6.1.4 (June 24, 2021) ##
32
-
33
- * MemCacheStore: convert any underlying value (including `false`) to an `Entry`.
34
-
35
- See [#42559](https://github.com/rails/rails/pull/42559).
36
-
37
- *Alex Ghiculescu*
38
-
39
- * Fix bug in `number_with_precision` when using large `BigDecimal` values.
40
-
41
- Fixes #42302.
42
-
43
- *Federico Aldunate*, *Zachary Scott*
44
-
45
- * Check byte size instead of length on `secure_compare`.
46
-
47
- *Tietew*
48
-
49
- * Fix `Time.at` to not lose `:in` option.
50
-
51
- *Ryuta Kamizono*
52
-
53
- * Require a path for `config.cache_store = :file_store`.
54
-
55
- *Alex Ghiculescu*
56
-
57
- * Avoid having to store complex object in the default translation file.
58
-
59
- *Rafael Mendonça França*
60
-
61
-
62
- ## Rails 6.1.3.2 (May 05, 2021) ##
63
-
64
- * No changes.
65
-
66
-
67
- ## Rails 6.1.3.1 (March 26, 2021) ##
68
-
69
- * No changes.
70
-
71
-
72
- ## Rails 6.1.3 (February 17, 2021) ##
73
-
74
- * No changes.
75
-
76
-
77
- ## Rails 6.1.2.1 (February 10, 2021) ##
78
-
79
- * No changes.
3
+ * `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.
80
4
 
5
+ *Xavier Noria*
81
6
 
82
- ## Rails 6.1.2 (February 09, 2021) ##
7
+ * Private internal classes of `ActiveSupport::Dependencies` have been deleted, like `ActiveSupport::Dependencies::Reference`, `ActiveSupport::Dependencies::Blamable`, and others.
83
8
 
84
- * `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
85
-
86
- ```ruby
87
- config.cache_store = :mem_cache_store, nil
9
+ *Xavier Noria*
88
10
 
89
- # is now equivalent to
11
+ * The private API of `ActiveSupport::Dependencies` has been deleted. That includes methods like `hook!`, `unhook!`, `depend_on`, `require_or_load`, `mechanism`, and many others.
90
12
 
91
- config.cache_store = :mem_cache_store
13
+ *Xavier Noria*
92
14
 
93
- # and is also equivalent to
15
+ * Improves the performance of `ActiveSupport::NumberHelper` formatters by avoiding the use of exceptions as flow control.
94
16
 
95
- config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
17
+ *Mike Dalessio*
96
18
 
97
- # which is the fallback behavior of Dalli
98
- ```
19
+ * Removed rescue block from `ActiveSupport::Cache::RedisCacheStore#handle_exception`
99
20
 
100
- This helps those migrating from `:dalli_store`, where an explicit `nil` was permitted.
21
+ Previously, if you provided a `error_handler` to `redis_cache_store`, any errors thrown by
22
+ the error handler would be rescued and logged only. Removed the `rescue` clause from `handle_exception`
23
+ to allow these to be thrown.
101
24
 
102
- *Michael Overmeyer*
25
+ *Nicholas A. Stuart*
103
26
 
27
+ * Allow entirely opting out of deprecation warnings.
104
28
 
105
- ## Rails 6.1.1 (January 07, 2021) ##
29
+ Previously if you did `app.config.active_support.deprecation = :silence`, some work would
30
+ still be done on each call to `ActiveSupport::Deprecation.warn`. In very hot paths, this could
31
+ cause performance issues.
106
32
 
107
- * Change `IPAddr#to_json` to match the behavior of the json gem returning the string representation
108
- instead of the instance variables of the object.
109
-
110
- Before:
33
+ Now, you can make `ActiveSupport::Deprecation.warn` a no-op:
111
34
 
112
35
  ```ruby
113
- IPAddr.new("127.0.0.1").to_json
114
- # => "{\"addr\":2130706433,\"family\":2,\"mask_addr\":4294967295}"
36
+ config.active_support.report_deprecations = false
115
37
  ```
116
38
 
117
- After:
39
+ This is the default in production for new apps. It is the equivalent to:
118
40
 
119
41
  ```ruby
120
- IPAddr.new("127.0.0.1").to_json
121
- # => "\"127.0.0.1\""
42
+ config.active_support.deprecation = :silence
43
+ config.active_support.disallowed_deprecation = :silence
122
44
  ```
123
45
 
46
+ but will take a more optimised code path.
124
47
 
125
- ## Rails 6.1.0 (December 09, 2020) ##
126
-
127
- * Ensure `MemoryStore` disables compression by default. Reverts behavior of
128
- `MemoryStore` to its prior rails `5.1` behavior.
129
-
130
- *Max Gurewitz*
131
-
132
- * Calling `iso8601` on negative durations retains the negative sign on individual
133
- digits instead of prepending it.
134
-
135
- This change is required so we can interoperate with PostgreSQL, which prefers
136
- negative signs for each component.
137
-
138
- Compatibility with other iso8601 parsers which support leading negatives as well
139
- as negatives per component is still retained.
140
-
141
- Before:
142
-
143
- (-1.year - 1.day).iso8601
144
- # => "-P1Y1D"
145
-
146
- After:
147
-
148
- (-1.year - 1.day).iso8601
149
- # => "P-1Y-1D"
150
-
151
- *Vipul A M*
152
-
153
- * Remove deprecated `ActiveSupport::Notifications::Instrumenter#end=`.
154
-
155
- *Rafael Mendonça França*
156
-
157
- * Deprecate `ActiveSupport::Multibyte::Unicode.default_normalization_form`.
158
-
159
- *Rafael Mendonça França*
160
-
161
- * Remove deprecated `ActiveSupport::Multibyte::Unicode.pack_graphemes`,
162
- `ActiveSupport::Multibyte::Unicode.unpack_graphemes`,
163
- `ActiveSupport::Multibyte::Unicode.normalize`,
164
- `ActiveSupport::Multibyte::Unicode.downcase`,
165
- `ActiveSupport::Multibyte::Unicode.upcase` and `ActiveSupport::Multibyte::Unicode.swapcase`.
166
-
167
- *Rafael Mendonça França*
168
-
169
- * Remove deprecated `ActiveSupport::Multibyte::Chars#consumes?` and `ActiveSupport::Multibyte::Chars#normalize`.
170
-
171
- *Rafael Mendonça França*
172
-
173
- * Remove deprecated file `active_support/core_ext/range/include_range`.
174
-
175
- *Rafael Mendonça França*
176
-
177
- * Remove deprecated file `active_support/core_ext/hash/transform_values`.
178
-
179
- *Rafael Mendonça França*
180
-
181
- * Remove deprecated file `active_support/core_ext/hash/compact`.
182
-
183
- *Rafael Mendonça França*
184
-
185
- * Remove deprecated file `active_support/core_ext/array/prepend_and_append`.
186
-
187
- *Rafael Mendonça França*
188
-
189
- * Remove deprecated file `active_support/core_ext/numeric/inquiry`.
190
-
191
- *Rafael Mendonça França*
192
-
193
- * Remove deprecated file `active_support/core_ext/module/reachable`.
194
-
195
- *Rafael Mendonça França*
196
-
197
- * Remove deprecated `Module#parent_name`, `Module#parent` and `Module#parents`.
198
-
199
- *Rafael Mendonça França*
200
-
201
- * Remove deprecated `ActiveSupport::LoggerThreadSafeLevel#after_initialize`.
202
-
203
- *Rafael Mendonça França*
204
-
205
- * Remove deprecated `LoggerSilence` constant.
206
-
207
- *Rafael Mendonça França*
208
-
209
- * Remove deprecated fallback to `I18n.default_local` when `config.i18n.fallbacks` is empty.
210
-
211
- *Rafael Mendonça França*
212
-
213
- * Remove entries from local cache on `RedisCacheStore#delete_matched`
214
-
215
- Fixes #38627
216
-
217
- *ojab*
48
+ *Alex Ghiculescu*
218
49
 
219
- * Speed up `ActiveSupport::SecurityUtils.fixed_length_secure_compare` by using
220
- `OpenSSL.fixed_length_secure_compare`, if available.
50
+ * Faster tests by parallelizing only when overhead is justified by the number
51
+ of them.
221
52
 
222
- *Nate Matykiewicz*
53
+ Running tests in parallel adds overhead in terms of database
54
+ setup and fixture loading. Now, Rails will only parallelize test executions when
55
+ there are enough tests to make it worth it.
223
56
 
224
- * `ActiveSupport::Cache::MemCacheStore` now checks `ENV["MEMCACHE_SERVERS"]` before falling back to `"localhost:11211"` if configured without any addresses.
57
+ This threshold is 50 by default, and is configurable via config setting in
58
+ your test.rb:
225
59
 
226
60
  ```ruby
227
- config.cache_store = :mem_cache_store
228
-
229
- # is now equivalent to
230
-
231
- config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
232
-
233
- # instead of
234
-
235
- config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
61
+ config.active_support.test_parallelization_threshold = 100
236
62
  ```
237
63
 
238
- *Sam Bostock*
239
-
240
- * `ActiveSupport::Subscriber#attach_to` now accepts an `inherit_all:` argument. When set to true,
241
- it allows a subscriber to receive events for methods defined in the subscriber's ancestor class(es).
64
+ It's also configurable at the test case level:
242
65
 
243
66
  ```ruby
244
- class ActionControllerSubscriber < ActiveSupport::Subscriber
245
- attach_to :action_controller
246
-
247
- def start_processing(event)
248
- info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}"
249
- end
250
-
251
- def redirect_to(event)
252
- info { "Redirected to #{event.payload[:location]}" }
253
- end
254
- end
255
-
256
- # We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber
257
- # can provide its own instrumentation for certain events in the namespace
258
- ActionControllerSubscriber.detach_from(:action_controller)
259
-
260
- class CustomActionControllerSubscriber < ActionControllerSubscriber
261
- attach_to :action_controller, inherit_all: true
262
-
263
- def start_processing(event)
264
- info "A custom response to start_processing events"
265
- end
266
-
267
- # => CustomActionControllerSubscriber will process events for "start_processing.action_controller" notifications
268
- # using its own #start_processing implementation, while retaining ActionControllerSubscriber's instrumentation
269
- # for "redirect_to.action_controller" notifications
67
+ class ActiveSupport::TestCase
68
+ parallelize threshold: 100
270
69
  end
271
70
  ```
272
71
 
273
- *Adrianna Chang*
72
+ *Jorge Manrubia*
274
73
 
275
- * Allow the digest class used to generate non-sensitive digests to be configured with `config.active_support.hash_digest_class`.
276
-
277
- `config.active_support.use_sha1_digests` is deprecated in favour of `config.active_support.hash_digest_class = ::Digest::SHA1`.
74
+ * OpenSSL constants are now used for Digest computations.
278
75
 
279
76
  *Dirkjan Bussink*
280
77
 
281
- * Fix bug to make memcached write_entry expire correctly with unless_exist
282
-
283
- *Jye Lee*
284
-
285
- * Add `ActiveSupport::Duration` conversion methods
286
-
287
- `in_seconds`, `in_minutes`, `in_hours`, `in_days`, `in_weeks`, `in_months`, and `in_years` return the respective duration covered.
288
-
289
- *Jason York*
290
-
291
- * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
292
- to `read_multi` causing `fetch_multi` to not work properly
293
-
294
- *Rajesh Sharma*
78
+ * `TimeZone.iso8601` now accepts valid ordinal values similar to Ruby's `Date._iso8601` method.
79
+ A valid ordinal value will be converted to an instance of `TimeWithZone` using the `:year`
80
+ and `:yday` fragments returned from `Date._iso8601`.
295
81
 
296
- * Fixed issue in `ActiveSupport::Cache::MemCacheStore` which caused duplicate compression,
297
- and caused the provided `compression_threshold` to not be respected.
298
-
299
- *Max Gurewitz*
300
-
301
- * Prevent `RedisCacheStore` and `MemCacheStore` from performing compression
302
- when reading entries written with `raw: true`.
303
-
304
- *Max Gurewitz*
82
+ ```ruby
83
+ twz = ActiveSupport::TimeZone["Eastern Time (US & Canada)"].iso8601("21087")
84
+ twz.to_a[0, 6] == [0, 0, 0, 28, 03, 2021]
85
+ ```
305
86
 
306
- * `URI.parser` is deprecated and will be removed in Rails 6.2. Use
307
- `URI::DEFAULT_PARSER` instead.
87
+ *Steve Laing*
308
88
 
309
- *Jean Boussier*
89
+ * `Time#change` and methods that call it (e.g. `Time#advance`) will now
90
+ return a `Time` with the timezone argument provided, if the caller was
91
+ initialized with a timezone argument.
310
92
 
311
- * `require_dependency` has been documented to be _obsolete_ in `:zeitwerk`
312
- mode. The method is not deprecated as such (yet), but applications are
313
- encouraged to not use it.
93
+ Fixes [#42467](https://github.com/rails/rails/issues/42467).
314
94
 
315
- In `:zeitwerk` mode, semantics match Ruby's and you do not need to be
316
- defensive with load order. Just refer to classes and modules normally. If
317
- the constant name is dynamic, camelize if needed, and constantize.
95
+ *Alex Ghiculescu*
318
96
 
319
- *Xavier Noria*
97
+ * Allow serializing any module or class to JSON by name.
320
98
 
321
- * Add 3rd person aliases of `Symbol#start_with?` and `Symbol#end_with?`.
99
+ *Tyler Rick*, *Zachary Scott*
322
100
 
323
- ```ruby
324
- :foo.starts_with?("f") # => true
325
- :foo.ends_with?("o") # => true
326
- ```
101
+ * Raise `ActiveSupport::EncryptedFile::MissingKeyError` when the
102
+ `RAILS_MASTER_KEY` environment variable is blank (e.g. `""`).
327
103
 
328
- *Ryuta Kamizono*
104
+ *Sunny Ripert*
329
105
 
330
- * Add override of unary plus for `ActiveSupport::Duration`.
106
+ * The `from:` option is added to `ActiveSupport::TestCase#assert_no_changes`.
331
107
 
332
- `+ 1.second` is now identical to `+1.second` to prevent errors
333
- where a seemingly innocent change of formatting leads to a change in the code behavior.
334
-
335
- Before:
336
- ```ruby
337
- +1.second.class
338
- # => ActiveSupport::Duration
339
- (+ 1.second).class
340
- # => Integer
341
- ```
108
+ It permits asserting on the initial value that is expected not to change.
342
109
 
343
- After:
344
110
  ```ruby
345
- +1.second.class
346
- # => ActiveSupport::Duration
347
- (+ 1.second).class
348
- # => ActiveSupport::Duration
111
+ assert_no_changes -> { Status.all_good? }, from: true do
112
+ post :create, params: { status: { ok: true } }
113
+ end
349
114
  ```
350
115
 
351
- Fixes #39079.
352
-
353
- *Roman Kushnir*
354
-
355
- * Add subsec to `ActiveSupport::TimeWithZone#inspect`.
116
+ *George Claghorn*
356
117
 
357
- Before:
118
+ * Deprecate `ActiveSupport::SafeBuffer`'s incorrect implicit conversion of objects into string.
358
119
 
359
- Time.at(1498099140).in_time_zone.inspect
360
- # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
361
- Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
362
- # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
363
- Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
364
- # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
120
+ Except for a few methods like `String#%`, objects must implement `#to_str`
121
+ to be implicitly converted to a String in string operations. In some
122
+ circumstances `ActiveSupport::SafeBuffer` was incorrectly calling the
123
+ explicit conversion method (`#to_s`) on them. This behavior is now
124
+ deprecated.
365
125
 
366
- After:
126
+ *Jean Boussier*
367
127
 
368
- Time.at(1498099140).in_time_zone.inspect
369
- # => "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
370
- Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
371
- # => "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
372
- Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
373
- # => "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
128
+ * Allow nested access to keys on `Rails.application.credentials`.
374
129
 
375
- *akinomaeni*
130
+ Previously only top level keys in `credentials.yml.enc` could be accessed with method calls. Now any key can.
376
131
 
377
- * Calling `ActiveSupport::TaggedLogging#tagged` without a block now returns a tagged logger.
132
+ For example, given these secrets:
378
133
 
379
- ```ruby
380
- logger.tagged("BCX").info("Funky time!") # => [BCX] Funky time!
134
+ ```yml
135
+ aws:
136
+ access_key_id: 123
137
+ secret_access_key: 345
381
138
  ```
382
139
 
383
- *Eugene Kenny*
384
-
385
- * Align `Range#cover?` extension behavior with Ruby behavior for backwards ranges.
140
+ `Rails.application.credentials.aws.access_key_id` will now return the same thing as
141
+ `Rails.application.credentials.aws[:access_key_id]`.
386
142
 
387
- `(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby.
388
-
389
- Also update `#include?` and `#===` behavior to match.
390
-
391
- *Michael Groeneman*
143
+ *Alex Ghiculescu*
392
144
 
393
- * Update to TZInfo v2.0.0.
145
+ * Added a faster and more compact `ActiveSupport::Cache` serialization format.
394
146
 
395
- This changes the output of `ActiveSupport::TimeZone.utc_to_local`, but
396
- can be controlled with the
397
- `ActiveSupport.utc_to_local_returns_utc_offset_times` config.
147
+ It can be enabled with `config.active_support.cache_format_version = 7.0` or
148
+ `config.load_defaults 7.0`. Regardless of the configuration Active Support
149
+ 7.0 can read cache entries serialized by Active Support 6.1 which allows to
150
+ upgrade without invalidating the cache. However Rails 6.1 can't read the
151
+ new format, so all readers must be upgraded before the new format is enabled.
398
152
 
399
- New Rails 6.1 apps have it enabled by default, existing apps can upgrade
400
- via the config in config/initializers/new_framework_defaults_6_1.rb
153
+ *Jean Boussier*
401
154
 
402
- See the `utc_to_local_returns_utc_offset_times` documentation for details.
155
+ * Add `Enumerable#sole`, per `ActiveRecord::FinderMethods#sole`. Returns the
156
+ sole item of the enumerable, raising if no items are found, or if more than
157
+ one is.
403
158
 
404
- *Phil Ross*, *Jared Beck*
159
+ *Asherah Connor*
405
160
 
406
- * Add Date and Time `#yesterday?` and `#tomorrow?` alongside `#today?`.
161
+ * Freeze `ActiveSupport::Duration#parts` and remove writer methods.
407
162
 
408
- Aliased to `#prev_day?` and `#next_day?` to match the existing `#prev/next_day` methods.
163
+ Durations are meant to be value objects and should not be mutated.
409
164
 
410
- *Jatin Dhankhar*
165
+ *Andrew White*
411
166
 
412
- * Add `Enumerable#pick` to complement `ActiveRecord::Relation#pick`.
167
+ * Fix `ActiveSupport::TimeZone#utc_to_local` with fractional seconds.
413
168
 
414
- *Eugene Kenny*
169
+ When `utc_to_local_returns_utc_offset_times` is false and the time
170
+ instance had fractional seconds the new UTC time instance was out by
171
+ a factor of 1,000,000 as the `Time.utc` constructor takes a usec
172
+ value and not a fractional second value.
415
173
 
416
- * [Breaking change] `ActiveSupport::Callbacks#halted_callback_hook` now receive a 2nd argument:
174
+ *Andrew White*
417
175
 
418
- `ActiveSupport::Callbacks#halted_callback_hook` now receive the name of the callback
419
- being halted as second argument.
420
- This change will allow you to differentiate which callbacks halted the chain
421
- and act accordingly.
176
+ * Add `expires_at` argument to `ActiveSupport::Cache` `write` and `fetch` to set a cache entry TTL as an absolute time.
422
177
 
423
178
  ```ruby
424
- class Book < ApplicationRecord
425
- before_save { throw(:abort) }
426
- before_create { throw(:abort) }
427
-
428
- def halted_callback_hook(filter, callback_name)
429
- Rails.logger.info("Book couldn't be #{callback_name}d")
430
- end
431
-
432
- Book.create # => "Book couldn't be created"
433
- book.save # => "Book couldn't be saved"
434
- end
179
+ Rails.cache.write(key, value, expires_at: Time.now.at_end_of_hour)
435
180
  ```
436
181
 
437
- *Edouard Chin*
438
-
439
- * Support `prepend` with `ActiveSupport::Concern`.
440
-
441
- Allows a module with `extend ActiveSupport::Concern` to be prepended.
442
-
443
- module Imposter
444
- extend ActiveSupport::Concern
445
-
446
- # Same as `included`, except only run when prepended.
447
- prepended do
448
- end
449
- end
450
-
451
- class Person
452
- prepend Imposter
453
- end
454
-
455
- Class methods are prepended to the base class, concerning is also
456
- updated: `concerning :Imposter, prepend: true do`.
182
+ *Jean Boussier*
457
183
 
458
- *Jason Karns*, *Elia Schito*
184
+ * Deprecate `ActiveSupport::TimeWithZone.name` so that from Rails 7.1 it will use the default implementation.
459
185
 
460
- * Deprecate using `Range#include?` method to check the inclusion of a value
461
- in a date time range. It is recommended to use `Range#cover?` method
462
- instead of `Range#include?` to check the inclusion of a value
463
- in a date time range.
186
+ *Andrew White*
464
187
 
465
- *Vishal Telangre*
188
+ * Deprecates Rails custom `Enumerable#sum` and `Array#sum` in favor of Ruby's native implementation which
189
+ is considerably faster.
466
190
 
467
- * Support added for a `round_mode` parameter, in all number helpers. (See: `BigDecimal::mode`.)
191
+ Ruby requires an initializer for non-numeric type as per examples below:
468
192
 
469
193
  ```ruby
470
- number_to_currency(1234567890.50, precision: 0, round_mode: :half_down) # => "$1,234,567,890"
471
- number_to_percentage(302.24398923423, precision: 5, round_mode: :down) # => "302.24398%"
472
- number_to_rounded(389.32314, precision: 0, round_mode: :ceil) # => "390"
473
- number_to_human_size(483989, precision: 2, round_mode: :up) # => "480 KB"
474
- number_to_human(489939, precision: 2, round_mode: :floor) # => "480 Thousand"
194
+ %w[foo bar].sum('')
195
+ # instead of %w[foo bar].sum
475
196
 
476
- 485000.to_s(:human, precision: 2, round_mode: :half_even) # => "480 Thousand"
197
+ [[1, 2], [3, 4, 5]].sum([])
198
+ # instead of [[1, 2], [3, 4, 5]].sum
477
199
  ```
478
200
 
479
- *Tom Lord*
201
+ *Alberto Mota*
480
202
 
481
- * `Array#to_sentence` no longer returns a frozen string.
203
+ * Tests parallelization is now disabled when running individual files to prevent the setup overhead.
482
204
 
483
- Before:
205
+ It can still be enforced if the environment variable `PARALLEL_WORKERS` is present and set to a value greater than 1.
484
206
 
485
- ['one', 'two'].to_sentence.frozen?
486
- # => true
207
+ *Ricardo Díaz*
487
208
 
488
- After:
209
+ * Fix proxying keyword arguments in `ActiveSupport::CurrentAttributes`.
489
210
 
490
- ['one', 'two'].to_sentence.frozen?
491
- # => false
211
+ *Marcin Kołodziej*
492
212
 
493
- *Nicolas Dular*
494
-
495
- * When an instance of `ActiveSupport::Duration` is converted to an `iso8601` duration string, if `weeks` are mixed with `date` parts, the `week` part will be converted to days.
496
- This keeps the parser and serializer on the same page.
213
+ * Add `Enumerable#maximum` and `Enumerable#minimum` to easily calculate the maximum or minimum from extracted
214
+ elements of an enumerable.
497
215
 
498
216
  ```ruby
499
- duration = ActiveSupport::Duration.build(1000000)
500
- # 1 week, 4 days, 13 hours, 46 minutes, and 40.0 seconds
501
-
502
- duration_iso = duration.iso8601
503
- # P11DT13H46M40S
504
-
505
- ActiveSupport::Duration.parse(duration_iso)
506
- # 11 days, 13 hours, 46 minutes, and 40 seconds
507
-
508
- duration = ActiveSupport::Duration.build(604800)
509
- # 1 week
217
+ payments = [Payment.new(5), Payment.new(15), Payment.new(10)]
510
218
 
511
- duration_iso = duration.iso8601
512
- # P1W
513
-
514
- ActiveSupport::Duration.parse(duration_iso)
515
- # 1 week
219
+ payments.minimum(:price) # => 5
220
+ payments.maximum(:price) # => 15
516
221
  ```
517
222
 
518
- *Abhishek Sarkar*
519
-
520
- * Add block support to `ActiveSupport::Testing::TimeHelpers#travel_back`.
521
-
522
- *Tim Masliuchenko*
523
-
524
- * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
525
- `ActiveSupport.parse_json_times = true`.
526
-
527
- *Christian Gregg*
528
-
529
- * Support symbolic links for `content_path` in `ActiveSupport::EncryptedFile`.
530
-
531
- *Takumi Shotoku*
532
-
533
- * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
534
- and endless range targets.
535
-
536
- *Allen Hsu*, *Andrew Hodgkinson*
537
-
538
- * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
539
-
540
- *Iain Beeston*
541
-
542
- * Prevent `ActiveSupport::Duration.build(value)` from creating instances of
543
- `ActiveSupport::Duration` unless `value` is of type `Numeric`.
544
-
545
- Addresses the errant set of behaviours described in #37012 where
546
- `ActiveSupport::Duration` comparisons would fail confusingly
547
- or return unexpected results when comparing durations built from instances of `String`.
548
-
549
- Before:
550
-
551
- small_duration_from_string = ActiveSupport::Duration.build('9')
552
- large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
553
- small_duration_from_int = ActiveSupport::Duration.build(9)
554
-
555
- large_duration_from_string > small_duration_from_string
556
- # => false
557
-
558
- small_duration_from_string == small_duration_from_int
559
- # => false
560
-
561
- small_duration_from_int < large_duration_from_string
562
- # => ArgumentError (comparison of ActiveSupport::Duration::Scalar with ActiveSupport::Duration failed)
563
-
564
- large_duration_from_string > small_duration_from_int
565
- # => ArgumentError (comparison of String with ActiveSupport::Duration failed)
566
-
567
- After:
568
-
569
- small_duration_from_string = ActiveSupport::Duration.build('9')
570
- # => TypeError (can't build an ActiveSupport::Duration from a String)
571
-
572
- *Alexei Emam*
223
+ This also allows passing enumerables to `fresh_when` and `stale?` in Action Controller.
224
+ See PR [#41404](https://github.com/rails/rails/pull/41404) for an example.
573
225
 
574
- * Add `ActiveSupport::Cache::Store#delete_multi` method to delete multiple keys from the cache store.
226
+ *Ayrton De Craene*
575
227
 
576
- *Peter Zhu*
577
-
578
- * Support multiple arguments in `HashWithIndifferentAccess` for `merge` and `update` methods, to
579
- follow Ruby 2.6 addition.
580
-
581
- *Wojciech Wnętrzak*
582
-
583
- * Allow initializing `thread_mattr_*` attributes via `:default` option.
584
-
585
- class Scraper
586
- thread_mattr_reader :client, default: Api::Client.new
587
- end
588
-
589
- *Guilherme Mansur*
590
-
591
- * Add `compact_blank` for those times when you want to remove #blank? values from
592
- an Enumerable (also `compact_blank!` on Hash, Array, ActionController::Parameters).
593
-
594
- *Dana Sherson*
595
-
596
- * Make ActiveSupport::Logger Fiber-safe.
597
-
598
- Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
599
- to make log level local to Ruby Fibers in addition to Threads.
600
-
601
- Example:
602
-
603
- logger = ActiveSupport::Logger.new(STDOUT)
604
- logger.level = 1
605
- puts "Main is debug? #{logger.debug?}"
606
-
607
- Fiber.new {
608
- logger.local_level = 0
609
- puts "Thread is debug? #{logger.debug?}"
610
- }.resume
611
-
612
- puts "Main is debug? #{logger.debug?}"
228
+ * `ActiveSupport::Cache::MemCacheStore` now accepts an explicit `nil` for its `addresses` argument.
613
229
 
614
- Before:
230
+ ```ruby
231
+ config.cache_store = :mem_cache_store, nil
615
232
 
616
- Main is debug? false
617
- Thread is debug? true
618
- Main is debug? true
233
+ # is now equivalent to
619
234
 
620
- After:
235
+ config.cache_store = :mem_cache_store
621
236
 
622
- Main is debug? false
623
- Thread is debug? true
624
- Main is debug? false
237
+ # and is also equivalent to
625
238
 
626
- Fixes #36752.
239
+ config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211"
627
240
 
628
- *Alexander Varnin*
241
+ # which is the fallback behavior of Dalli
242
+ ```
629
243
 
630
- * Allow the `on_rotation` proc used when decrypting/verifying a message to be
631
- passed at the constructor level.
244
+ This helps those migrating from `:dalli_store`, where an explicit `nil` was permitted.
632
245
 
633
- Before:
246
+ *Michael Overmeyer*
634
247
 
635
- crypt = ActiveSupport::MessageEncryptor.new('long_secret')
636
- crypt.decrypt_and_verify(encrypted_message, on_rotation: proc { ... })
637
- crypt.decrypt_and_verify(another_encrypted_message, on_rotation: proc { ... })
248
+ * Add `Enumerable#in_order_of` to put an Enumerable in a certain order by a key.
638
249
 
639
- After:
250
+ *DHH*
640
251
 
641
- crypt = ActiveSupport::MessageEncryptor.new('long_secret', on_rotation: proc { ... })
642
- crypt.decrypt_and_verify(encrypted_message)
643
- crypt.decrypt_and_verify(another_encrypted_message)
252
+ * `ActiveSupport::Inflector.camelize` behaves expected when provided a symbol `:upper` or `:lower` argument. Matches
253
+ `String#camelize` behavior.
644
254
 
645
- *Edouard Chin*
255
+ *Alex Ghiculescu*
646
256
 
647
- * `delegate_missing_to` would raise a `DelegationError` if the object
648
- delegated to was `nil`. Now the `allow_nil` option has been added to enable
649
- the user to specify they want `nil` returned in this case.
257
+ * Raises an `ArgumentError` when the first argument of `ActiveSupport::Notification.subscribe` is
258
+ invalid.
650
259
 
651
- *Matthew Tanous*
260
+ *Vipul A M*
652
261
 
653
- * `truncate` would return the original string if it was too short to be truncated
654
- and a frozen string if it were long enough to be truncated. Now truncate will
655
- consistently return an unfrozen string regardless. This behavior is consistent
656
- with `gsub` and `strip`.
262
+ * `HashWithIndifferentAccess#deep_transform_keys` now returns a `HashWithIndifferentAccess` instead of a `Hash`.
657
263
 
658
- Before:
264
+ *Nathaniel Woodthorpe*
659
265
 
660
- 'foobar'.truncate(5).frozen?
661
- # => true
662
- 'foobar'.truncate(6).frozen?
663
- # => false
266
+ * Consume dalli’s `cache_nils` configuration as `ActiveSupport::Cache`'s `skip_nil` when using `MemCacheStore`.
664
267
 
665
- After:
268
+ *Ritikesh G*
666
269
 
667
- 'foobar'.truncate(5).frozen?
668
- # => false
669
- 'foobar'.truncate(6).frozen?
670
- # => false
270
+ * Add `RedisCacheStore#stats` method similar to `MemCacheStore#stats`. Calls `redis#info` internally.
671
271
 
672
- *Jordan Thomas*
272
+ *Ritikesh G*
673
273
 
674
274
 
675
- Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activesupport/CHANGELOG.md) for previous changes.
275
+ Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activesupport/CHANGELOG.md) for previous changes.