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