activesupport 8.0.2 → 8.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +646 -124
  3. data/README.rdoc +1 -1
  4. data/lib/active_support/backtrace_cleaner.rb +71 -0
  5. data/lib/active_support/broadcast_logger.rb +46 -59
  6. data/lib/active_support/cache/file_store.rb +1 -0
  7. data/lib/active_support/cache/mem_cache_store.rb +29 -28
  8. data/lib/active_support/cache/memory_store.rb +3 -1
  9. data/lib/active_support/cache/redis_cache_store.rb +46 -32
  10. data/lib/active_support/cache/strategy/local_cache.rb +17 -8
  11. data/lib/active_support/cache/strategy/local_cache_middleware.rb +7 -7
  12. data/lib/active_support/cache.rb +71 -7
  13. data/lib/active_support/callbacks.rb +20 -8
  14. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +8 -62
  15. data/lib/active_support/concurrency/thread_monitor.rb +55 -0
  16. data/lib/active_support/configurable.rb +34 -0
  17. data/lib/active_support/continuous_integration.rb +145 -0
  18. data/lib/active_support/core_ext/array.rb +7 -7
  19. data/lib/active_support/core_ext/benchmark.rb +0 -12
  20. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  21. data/lib/active_support/core_ext/class/attribute.rb +8 -6
  22. data/lib/active_support/core_ext/class.rb +2 -2
  23. data/lib/active_support/core_ext/date.rb +5 -5
  24. data/lib/active_support/core_ext/date_and_time/compatibility.rb +0 -35
  25. data/lib/active_support/core_ext/date_time/calculations.rb +1 -0
  26. data/lib/active_support/core_ext/date_time/compatibility.rb +3 -5
  27. data/lib/active_support/core_ext/date_time/conversions.rb +4 -2
  28. data/lib/active_support/core_ext/date_time.rb +5 -5
  29. data/lib/active_support/core_ext/digest.rb +1 -1
  30. data/lib/active_support/core_ext/enumerable.rb +18 -6
  31. data/lib/active_support/core_ext/erb/util.rb +3 -3
  32. data/lib/active_support/core_ext/file.rb +1 -1
  33. data/lib/active_support/core_ext/hash.rb +8 -8
  34. data/lib/active_support/core_ext/integer.rb +3 -3
  35. data/lib/active_support/core_ext/kernel.rb +3 -3
  36. data/lib/active_support/core_ext/module.rb +11 -11
  37. data/lib/active_support/core_ext/numeric.rb +3 -3
  38. data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
  39. data/lib/active_support/core_ext/object/json.rb +9 -2
  40. data/lib/active_support/core_ext/object/to_query.rb +7 -1
  41. data/lib/active_support/core_ext/object/try.rb +2 -2
  42. data/lib/active_support/core_ext/object.rb +13 -13
  43. data/lib/active_support/core_ext/pathname.rb +2 -2
  44. data/lib/active_support/core_ext/range/compare_range.rb +2 -14
  45. data/lib/active_support/core_ext/range/overlap.rb +3 -3
  46. data/lib/active_support/core_ext/range/sole.rb +19 -0
  47. data/lib/active_support/core_ext/range.rb +4 -4
  48. data/lib/active_support/core_ext/string/filters.rb +5 -3
  49. data/lib/active_support/core_ext/string/inflections.rb +1 -1
  50. data/lib/active_support/core_ext/string/multibyte.rb +12 -3
  51. data/lib/active_support/core_ext/string/output_safety.rb +29 -13
  52. data/lib/active_support/core_ext/string.rb +13 -13
  53. data/lib/active_support/core_ext/symbol.rb +1 -1
  54. data/lib/active_support/core_ext/time/calculations.rb +4 -7
  55. data/lib/active_support/core_ext/time/compatibility.rb +2 -27
  56. data/lib/active_support/core_ext/time.rb +5 -5
  57. data/lib/active_support/current_attributes/test_helper.rb +2 -2
  58. data/lib/active_support/current_attributes.rb +26 -16
  59. data/lib/active_support/delegation.rb +25 -42
  60. data/lib/active_support/dependencies/interlock.rb +11 -5
  61. data/lib/active_support/dependencies.rb +6 -1
  62. data/lib/active_support/deprecation/reporting.rb +4 -2
  63. data/lib/active_support/deprecation.rb +1 -1
  64. data/lib/active_support/duration.rb +6 -6
  65. data/lib/active_support/editor.rb +70 -0
  66. data/lib/active_support/error_reporter.rb +50 -6
  67. data/lib/active_support/event_reporter/test_helper.rb +32 -0
  68. data/lib/active_support/event_reporter.rb +592 -0
  69. data/lib/active_support/evented_file_update_checker.rb +5 -1
  70. data/lib/active_support/execution_context.rb +75 -7
  71. data/lib/active_support/file_update_checker.rb +8 -6
  72. data/lib/active_support/gem_version.rb +2 -2
  73. data/lib/active_support/gzip.rb +1 -0
  74. data/lib/active_support/hash_with_indifferent_access.rb +49 -25
  75. data/lib/active_support/i18n_railtie.rb +2 -2
  76. data/lib/active_support/inflector/inflections.rb +34 -16
  77. data/lib/active_support/inflector/methods.rb +4 -4
  78. data/lib/active_support/inflector/transliterate.rb +18 -10
  79. data/lib/active_support/isolated_execution_state.rb +17 -15
  80. data/lib/active_support/json/decoding.rb +10 -4
  81. data/lib/active_support/json/encoding.rb +147 -17
  82. data/lib/active_support/lazy_load_hooks.rb +1 -1
  83. data/lib/active_support/log_subscriber.rb +2 -6
  84. data/lib/active_support/logger_thread_safe_level.rb +6 -3
  85. data/lib/active_support/message_encryptors.rb +52 -0
  86. data/lib/active_support/message_pack/extensions.rb +15 -1
  87. data/lib/active_support/message_verifiers.rb +52 -0
  88. data/lib/active_support/messages/rotation_coordinator.rb +9 -0
  89. data/lib/active_support/messages/rotator.rb +5 -0
  90. data/lib/active_support/messages/serializer_with_fallback.rb +1 -1
  91. data/lib/active_support/multibyte/chars.rb +8 -1
  92. data/lib/active_support/multibyte.rb +4 -0
  93. data/lib/active_support/notifications/fanout.rb +64 -42
  94. data/lib/active_support/notifications/instrumenter.rb +1 -1
  95. data/lib/active_support/notifications.rb +2 -2
  96. data/lib/active_support/number_helper/number_converter.rb +5 -2
  97. data/lib/active_support/number_helper/number_to_currency_converter.rb +1 -1
  98. data/lib/active_support/number_helper/number_to_delimited_converter.rb +19 -5
  99. data/lib/active_support/number_helper/number_to_phone_converter.rb +3 -7
  100. data/lib/active_support/number_helper/rounding_helper.rb +1 -1
  101. data/lib/active_support/ordered_options.rb +2 -2
  102. data/lib/active_support/railtie.rb +32 -15
  103. data/lib/active_support/security_utils.rb +4 -5
  104. data/lib/active_support/structured_event_subscriber.rb +99 -0
  105. data/lib/active_support/subscriber.rb +0 -5
  106. data/lib/active_support/syntax_error_proxy.rb +9 -1
  107. data/lib/active_support/test_case.rb +67 -6
  108. data/lib/active_support/testing/assertions.rb +42 -9
  109. data/lib/active_support/testing/autorun.rb +5 -0
  110. data/lib/active_support/testing/error_reporter_assertions.rb +17 -0
  111. data/lib/active_support/testing/event_reporter_assertions.rb +227 -0
  112. data/lib/active_support/testing/notification_assertions.rb +92 -0
  113. data/lib/active_support/testing/parallelization/server.rb +15 -2
  114. data/lib/active_support/testing/parallelization/worker.rb +9 -3
  115. data/lib/active_support/testing/parallelization.rb +29 -1
  116. data/lib/active_support/testing/tests_without_assertions.rb +1 -1
  117. data/lib/active_support/testing/time_helpers.rb +7 -3
  118. data/lib/active_support/time_with_zone.rb +27 -23
  119. data/lib/active_support/values/time_zone.rb +11 -4
  120. data/lib/active_support/xml_mini.rb +3 -2
  121. data/lib/active_support.rb +20 -15
  122. metadata +27 -19
  123. data/lib/active_support/core_ext/range/each.rb +0 -24
data/CHANGELOG.md CHANGED
@@ -1,255 +1,777 @@
1
- ## Rails 8.0.2 (March 12, 2025) ##
1
+ ## Rails 8.1.4 (September 24, 2026) ##
2
2
 
3
- * No changes.
3
+ * Fix the debug error page rendering for `SyntaxError`s with multi-line messages.
4
4
 
5
+ *Marco Roth*
5
6
 
6
- ## Rails 8.0.2 (March 12, 2025) ##
7
+ * Make `ActiveSupport::JSON.decode` compatible with the upcoming `json` 3.0 gem.
7
8
 
8
- * Fix setting `to_time_preserves_timezone` from `new_framework_defaults_8_0.rb`.
9
+ *Earlopain*
9
10
 
10
- *fatkodima*
11
+ * Fix `number_to_human_size` crashing for sizes above a terabyte by supporting
12
+ petabyte, exabyte, and zettabyte storage units.
11
13
 
12
- * Fix Active Support Cache `fetch_multi` when local store is active.
14
+ *Kenta Ishizaki*
13
15
 
14
- `fetch_multi` now properly yield to the provided block for missing entries
15
- that have been recorded as such in the local store.
16
+ * Fix `Range#sole` raising `NoMethodError` when the enumerable core extension
17
+ isn't already loaded.
16
18
 
17
- *Jean Boussier*
19
+ *Kenta Ishizaki*
18
20
 
19
- * Fix execution wrapping to report all exceptions, including `Exception`.
21
+ * Fix `ActiveSupport::Cache::FileStore` raising `NameError` for `FileUtils`
22
+ when `fileutils` isn't already loaded.
20
23
 
21
- If a more serious error like `SystemStackError` or `NoMemoryError` happens,
22
- the error reporter should be able to report these kinds of exceptions.
24
+ *Kenta Ishizaki*
23
25
 
24
- *Gannon McGibbon*
26
+ * Fix `Enumerable#in_order_of` with `filter: true` dropping `nil` elements
27
+ explicitly named in the series.
25
28
 
26
- * Fix `RedisCacheStore` and `MemCacheStore` to also handle connection pool related errors.
29
+ *Kenta Ishizaki*
27
30
 
28
- These errors are rescued and reported to `Rails.error`.
31
+ * Keep `HashWithIndifferentAccess#filter` returning a `HashWithIndifferentAccess`
32
+ instead of a plain `Hash`.
29
33
 
30
- *Jean Boussier*
34
+ *Kenta Ishizaki*
31
35
 
32
- * Fix `ActiveSupport::Cache#read_multi` to respect version expiry when using local cache.
36
+ * Fix `number_to_human` and `number_to_human_size` crashing when `:precision` is `nil`.
33
37
 
34
- *zzak*
38
+ *Kenta Ishizaki*
39
+
40
+ * Fix `ActiveSupport::InheritableOptions#to_h` to recursively flatten nested
41
+ `InheritableOptions` parents.
42
+
43
+ *Andrew Novoselac*
44
+
45
+ * Fix `ActiveSupport::StructuredEventSubscriber.debug_only` leaking debug-only
46
+ methods across subscriber subclasses.
47
+
48
+ *Kenta Ishizaki*
49
+
50
+ * Fix `ActiveSupport::Inflector#transliterate` mutating the caller's string.
51
+
52
+ *Kenta Ishizaki*
53
+
54
+ * Fix `Hash.from_xml` raising `Date::Error` on `type="date"` values surrounded
55
+ by whitespace.
56
+
57
+ *Kenta Ishizaki*
58
+
59
+ * Fix `Time#advance` and `DateTime#advance` mutating the options hash passed
60
+ by the caller.
61
+
62
+ *Kenta Ishizaki*
63
+
64
+ * Fix `ActiveSupport::Cache::MemoryStore#cleanup` raising `NoMethodError` when
65
+ used with a non-`DupCoder` serializer.
66
+
67
+ *Kenta Ishizaki*
68
+
69
+ * Fix `String#truncate` with `:separator` misbehaving when the `:omission` is
70
+ longer than the target length.
71
+
72
+ *Kenta Ishizaki*
73
+
74
+ * Fix `ActiveSupport::Cache::Store#delete_multi` mutating the names array passed
75
+ by the caller.
76
+
77
+ *Kenta Ishizaki*
78
+
79
+ * Fix `number_to_currency` crashing on a negative number when `:precision` is `nil`.
80
+
81
+ *Kenta Ishizaki*
82
+
83
+ * Fix `TimeZone#strptime` with `%s` dropping the sub-second fraction of the timestamp.
84
+
85
+ *Kenta Ishizaki*
86
+
87
+ * Fix `HashWithIndifferentAccess.new` dropping a falsy (`false` or `0`) default
88
+ value from the source hash.
89
+
90
+ *Kenta Ishizaki*
91
+
92
+ * Fix `Range#include?` and `Range#===` raising on exclusive non-integer sub-ranges.
93
+
94
+ *Kenta Ishizaki*
95
+
96
+ * Fix `number_to_delimited` corrupting numbers that begin with a `+` or `-` sign.
97
+
98
+ *Kenta Ishizaki*
35
99
 
36
- * Fix `ActiveSupport::MessageVerifier` and `ActiveSupport::MessageEncryptor` configuration of `on_rotation` callback.
100
+ * Fix `ActiveSupport::InheritableOptions#==` raising `NoMethodError` when compared
101
+ with a non-Hash object.
102
+
103
+ *Kenta Ishizaki*
104
+
105
+ * Fix `Enumerable#in_order_of` with `filter: false` dropping elements whose keyed
106
+ value is `nil`.
107
+
108
+ *Hammad Khan*
109
+
110
+ * Stop the DRb service when shutting down parallel test workers, preventing it
111
+ from lingering after the test run.
112
+
113
+ *Shuta Mugikura*
114
+
115
+ * Preserve the encoding of `ActiveSupport::SafeBuffer` values round-tripped through
116
+ `ActiveSupport::MessagePack`.
117
+
118
+ *Rafael Mendonça França*
119
+
120
+ * Fix `number_to_phone` without an area code stripping a leading delimiter when the
121
+ number itself coincidentally starts with the delimiter string.
122
+
123
+ *Tahsin Hasan*
124
+
125
+ * Update `ActiveSupport::TimeZone` mappings to use the current IANA identifiers
126
+ `Europe/Kyiv` (was `Europe/Kiev`) and `Asia/Yangon` (was `Asia/Rangoon`).
127
+
128
+ *tsymbalenkovlad*
129
+
130
+ * Use the faster string-based delimiter logic by default in `number_to_delimited`,
131
+ instead of the regular expression fallback.
132
+
133
+ *Shinichi Maeshima*
134
+
135
+ * Preserve the requested key order in `ActiveSupport::Cache::Store#fetch_multi`
136
+ when a local cache is active.
137
+
138
+ Previously, if some keys were served from the local cache and others from the
139
+ underlying store, `fetch_multi` returned the local cache hits first instead of
140
+ following the order of the requested keys.
141
+
142
+ *Mueez Afzal*
143
+
144
+ * Fix `String#parameterize` raising `TypeError` when `separator` is `nil`.
145
+
146
+ `parameterize` already treats a `nil` separator the same as an empty one when
147
+ squeezing and trimming separators, but raised `TypeError` before reaching that
148
+ point. A `nil` separator now behaves like `""`, removing the unwanted characters.
37
149
 
38
150
  ```ruby
39
- verifier.rotate(old_secret).on_rotation { ... }
151
+ "Donald E. Knuth".parameterize(separator: nil) # => "donaldeknuth"
40
152
  ```
41
153
 
42
- Now both work as documented.
154
+ *Hammad Khan*
43
155
 
44
- *Jean Boussier*
156
+ * Add `RedisClient::Error` to `ActiveSupport::Cache::RedisCacheStore`'s failsafe rescue list.
45
157
 
46
- * Fix `ActiveSupport::MessageVerifier` to always be able to verify both URL-safe and URL-unsafe payloads.
158
+ The redis-rb gem normally translates `RedisClient::*` errors into `Redis::*` errors but in
159
+ some rare cases, such as when using sentinels, `RedisClient::*` errors may slip through.
47
160
 
48
- This is to allow transitioning seemlessly from either configuration without immediately invalidating
49
- all previously generated signed messages.
161
+ *David Arrunategui*
50
162
 
51
- *Jean Boussier*, *Florent Beaurain*, *Ali Sepehri*
163
+ * Fix `ActiveSupport::Duration#in_minutes`, `#in_hours`, `#in_days`,
164
+ `#in_weeks`, `#in_months`, and `#in_years` truncating sub-second precision.
52
165
 
53
- * Fix `cache.fetch` to honor the provided expiry when `:race_condition_ttl` is used.
166
+ These methods divided the duration's integer second count (`in_seconds`,
167
+ aliased to `to_i`) instead of its exact value, so any fractional second was
168
+ silently dropped before the conversion.
54
169
 
55
170
  ```ruby
56
- cache.fetch("key", expires_in: 1.hour, race_condition_ttl: 5.second) do
57
- "something"
58
- end
171
+ # Before
172
+ 90.5.seconds.in_minutes # => 1.5
173
+
174
+ # After
175
+ 90.5.seconds.in_minutes # => 1.5083333333333333
59
176
  ```
60
177
 
61
- In the above example, the final cache entry would have a 10 seconds TTL instead
62
- of the requested 1 hour.
178
+ *Kenta Ishizaki*
63
179
 
64
- *Dhia*
180
+ * Fix JSON encoding of non-String Hash keys.
65
181
 
66
- * Better handle procs with splat arguments in `set_callback`.
182
+ The old encoder would simply call `to_s` on them, the newer encoder
183
+ would incorrectly call `as_json` instead.
67
184
 
68
- *Radamés Roriz*
185
+ In the case of `Time`, `DateTime` and `TimeWithZone` this would result
186
+ in different serialization of time keys: `"2009-01-01T12:30:00.000Z"` (arguably better)
187
+ instead of `"2009-01-01 12:30:00 UTC"` (how it used to be).
69
188
 
70
- * Fix `String#mb_chars` to not mutate the receiver.
189
+ *Kenta Ishizaki*
71
190
 
72
- Previously it would call `force_encoding` on the receiver,
73
- now it dups the receiver first.
191
+ * Fix `number_to_phone` dropping only the first character of a
192
+ multi-character `:delimiter` when no area code is present.
74
193
 
75
- *Jean Boussier*
194
+ The leading delimiter produced by an empty first capture group was
195
+ stripped with `slice!(0, 1)`, which assumed a single-character
196
+ delimiter. Multi-character (and multibyte) delimiters now work:
76
197
 
77
- * Improve `ErrorSubscriber` to also mark error causes as reported.
198
+ number_to_phone(5551234, delimiter: " - ") # => "555 - 1234"
199
+ # was "- 555 - 1234"
78
200
 
79
- This avoid some cases of errors being reported twice, notably in views because of how
80
- errors are wrapped in `ActionView::Template::Error`.
201
+ *Kenta Ishizaki*
81
202
 
82
- *Jean Boussier*
203
+ * Fix `titleize` inflector to consider Unicode characters
204
+
205
+ ```ruby
206
+ "ćasim đipa".titleize # => "Ćasim Đipa"
207
+ ```
208
+
209
+ *Eldin Guzin*
210
+
211
+
212
+ ## Rails 8.1.3.1 (July 29, 2026) ##
213
+
214
+ * No changes.
215
+
216
+
217
+ ## Rails 8.1.3 (March 24, 2026) ##
218
+
219
+ * Fix `JSONGemCoderEncoder` to correctly serialize custom object hash keys.
83
220
 
84
- * Fix `Module#module_parent_name` to return the correct name after the module has been named.
221
+ When hash keys are custom objects whose `as_json` returns a Hash,
222
+ the encoder now calls `to_s` on the original key object instead of
223
+ on the `as_json` result.
85
224
 
86
- When called on an anonymous module, the return value wouldn't change after the module was given a name
87
- later by being assigned to a constant.
225
+ Before:
226
+ hash = {CustomKey.new(123) => "value"}
227
+ hash.to_json # => {"{:id=>123}":"value"}
228
+
229
+ After:
230
+ hash.to_json # => {"custom_123":"value"}
231
+
232
+ *Dan Sharp*
233
+
234
+ * Fix inflections to better handle overlapping acronyms.
88
235
 
89
236
  ```ruby
90
- mod = Module.new
91
- mod.module_parent_name # => "Object"
92
- MyModule::Something = mod
93
- mod.module_parent_name # => "MyModule"
237
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
238
+ inflect.acronym "USD"
239
+ inflect.acronym "USDC"
240
+ end
241
+
242
+ "USDC".underscore # => "usdc"
94
243
  ```
95
244
 
245
+ *Said Kaldybaev*
246
+
247
+ * Silence Dalli 4.0+ warning when using `ActiveSupport::Cache::MemCacheStore`.
248
+
249
+ *zzak*
250
+
251
+
252
+ ## Rails 8.1.2.1 (March 23, 2026) ##
253
+
254
+ * Reject scientific notation in NumberConverter
255
+
256
+ [CVE-2026-33176]
257
+
96
258
  *Jean Boussier*
97
259
 
260
+ * Fix `SafeBuffer#%` to preserve unsafe status
98
261
 
99
- ## Rails 8.0.1 (December 13, 2024) ##
262
+ [CVE-2026-33170]
100
263
 
101
- * Fix a bug in `ERB::Util.tokenize` that causes incorrect tokenization when ERB tags are preceeded by multibyte characters.
264
+ *Jean Boussier*
102
265
 
103
- *Martin Emde*
266
+ * Improve performance of NumberToDelimitedConverter
267
+
268
+ [CVE-2026-33169]
269
+
270
+ *Jean Boussier*
104
271
 
105
- * Restore the ability to decorate methods generated by `class_attribute`.
106
272
 
107
- It always has been complicated to use Module#prepend or an alias method chain
108
- to decorate methods defined by `class_attribute`, but became even harder in 8.0.
273
+ ## Rails 8.1.2 (January 08, 2026) ##
109
274
 
110
- This capability is now supported for both reader and writer methods.
275
+ * Make `delegate` and `delegate_missing_to` work in BasicObject subclasses.
276
+
277
+ *Rafael Mendonça França*
278
+
279
+ * Fix Inflectors when using a locale that fallbacks to `:en`.
280
+
281
+ *Said Kaldybaev*
282
+
283
+ * Fix `ActiveSupport::TimeWithZone#as_json` to consistently return UTF-8 strings.
284
+
285
+ Previously the returned string would sometime be encoded in US-ASCII, which in
286
+ some cases may be problematic.
287
+
288
+ Now the method consistently always return UTF-8 strings.
111
289
 
112
290
  *Jean Boussier*
113
291
 
292
+ * Fix `TimeWithZone#xmlschema` when wrapping a `DateTime` instance in local time.
114
293
 
115
- ## Rails 8.0.0.1 (December 10, 2024) ##
294
+ Previously it would return an invalid time.
116
295
 
117
- * No changes.
296
+ *Dmytro Rymar*
118
297
 
298
+ * Implement LocalCache strategy on `ActiveSupport::Cache::MemoryStore`. The memory store
299
+ needs to respond to the same interface as other cache stores (e.g. `ActiveSupport::NullStore`).
119
300
 
120
- ## Rails 8.0.0 (November 07, 2024) ##
301
+ *Mikey Gough*
121
302
 
122
- * No changes.
303
+ * Fix `ActiveSupport::Inflector.humanize` with international characters.
304
+
305
+ ```ruby
306
+ ActiveSupport::Inflector.humanize("áÉÍÓÚ") # => "Áéíóú"
307
+ ActiveSupport::Inflector.humanize("аБВГДЕ") # => "Абвгде"
308
+ ```
309
+
310
+ *Jose Luis Duran*
123
311
 
124
312
 
125
- ## Rails 8.0.0.rc2 (October 30, 2024) ##
313
+ ## Rails 8.1.1 (October 28, 2025) ##
126
314
 
127
315
  * No changes.
128
316
 
129
317
 
130
- ## Rails 8.0.0.rc1 (October 19, 2024) ##
318
+ ## Rails 8.1.0 (October 22, 2025) ##
131
319
 
132
- * Remove deprecated support to passing an array of strings to `ActiveSupport::Deprecation#warn`.
320
+ * Remove deprecated passing a Time object to `Time#since`.
133
321
 
134
322
  *Rafael Mendonça França*
135
323
 
136
- * Remove deprecated support to setting `attr_internal_naming_format` with a `@` prefix.
324
+ * Remove deprecated `Benchmark.ms` method. It is now defined in the `benchmark` gem.
137
325
 
138
326
  *Rafael Mendonça França*
139
327
 
140
- * Remove deprecated `ActiveSupport::ProxyObject`.
328
+ * Remove deprecated addition for `Time` instances with `ActiveSupport::TimeWithZone`.
141
329
 
142
330
  *Rafael Mendonça França*
143
331
 
144
- * Don't execute i18n watcher on boot. It shouldn't catch any file changes initially,
145
- and unnecessarily slows down boot of applications with lots of translations.
332
+ * Remove deprecated support for `to_time` to preserve the system local time. It will now always preserve the receiver
333
+ timezone.
146
334
 
147
- *Gannon McGibbon*, *David Stosik*
335
+ *Rafael Mendonça França*
148
336
 
149
- * Fix `ActiveSupport::HashWithIndifferentAccess#stringify_keys` to stringify all keys not just symbols.
337
+ * Deprecate `config.active_support.to_time_preserves_timezone`.
150
338
 
151
- Previously:
339
+ *Rafael Mendonça França*
340
+
341
+ * Standardize event name formatting in `assert_event_reported` error messages.
342
+
343
+ The event name in failure messages now uses `.inspect` (e.g., `name: "user.created"`)
344
+ to match `assert_events_reported` and provide type clarity between strings and symbols.
345
+ This only affects tests that assert on the failure message format itself.
346
+
347
+ *George Ma*
348
+
349
+ * Fix `Enumerable#sole` to return the full tuple instead of just the first element of the tuple.
350
+
351
+ *Olivier Bellone*
352
+
353
+ * Fix parallel tests hanging when worker processes die abruptly.
354
+
355
+ Previously, if a worker process was killed (e.g., OOM killed, `kill -9`) during parallel
356
+ test execution, the test suite would hang forever waiting for the dead worker.
357
+
358
+ *Joshua Young*
359
+
360
+ * Add `config.active_support.escape_js_separators_in_json`.
361
+
362
+ Introduce a new framework default to skip escaping LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) in JSON.
363
+
364
+ Historically these characters were not valid inside JavaScript literal strings but that changed in ECMAScript 2019.
365
+ As such it's no longer a concern in modern browsers: https://caniuse.com/mdn-javascript_builtins_json_json_superset.
366
+
367
+ *Étienne Barrié*, *Jean Boussier*
368
+
369
+ * Fix `NameError` when `class_attribute` is defined on instance singleton classes.
370
+
371
+ Previously, calling `class_attribute` on an instance's singleton class would raise
372
+ a `NameError` when accessing the attribute through the instance.
152
373
 
153
374
  ```ruby
154
- { 1 => 2 }.with_indifferent_access.stringify_keys[1] # => 2
375
+ object = MyClass.new
376
+ object.singleton_class.class_attribute :foo, default: "bar"
377
+ object.foo # previously raised NameError, now returns "bar"
155
378
  ```
156
379
 
157
- After this change:
380
+ *Joshua Young*
381
+
382
+ * Introduce `ActiveSupport::Testing::EventReporterAssertions#with_debug_event_reporting`
383
+ to enable event reporter debug mode in tests.
384
+
385
+ The previous way to enable debug mode is by using `#with_debug` on the
386
+ event reporter itself, which is too verbose. This new helper will help
387
+ clear up any confusion on how to test debug events.
388
+
389
+ *Gannon McGibbon*
390
+
391
+ * Add `ActiveSupport::StructuredEventSubscriber` for consuming notifications and
392
+ emitting structured event logs. Events may be emitted with the `#emit_event`
393
+ or `#emit_debug_event` methods.
158
394
 
159
395
  ```ruby
160
- { 1 => 2 }.with_indifferent_access.stringify_keys["1"] # => 2
396
+ class MyStructuredEventSubscriber < ActiveSupport::StructuredEventSubscriber
397
+ def notification(event)
398
+ emit_event("my.notification", data: 1)
399
+ end
400
+ end
161
401
  ```
162
402
 
163
- This change can be seen as a bug fix, but since it behaved like this for a very long time, we're deciding
164
- to not backport the fix and to make the change in a major release.
403
+ *Adrianna Chang*
165
404
 
166
- *Jean Boussier*
405
+ * `ActiveSupport::FileUpdateChecker` does not depend on `Time.now` to prevent unecessary reloads with time travel test helpers
167
406
 
168
- ## Rails 8.0.0.beta1 (September 26, 2024) ##
407
+ *Jan Grodowski*
169
408
 
170
- * Include options when instrumenting `ActiveSupport::Cache::Store#delete` and `ActiveSupport::Cache::Store#delete_multi`.
409
+ * Add `ActiveSupport::Cache::Store#namespace=` and `#namespace`.
171
410
 
172
- *Adam Renberg Tamm*
411
+ Can be used as an alternative to `Store#clear` in some situations such as parallel
412
+ testing.
173
413
 
174
- * Print test names when running `rails test -v` for parallel tests.
414
+ *Nick Schwaderer*
175
415
 
176
- *John Hawthorn*, *Abeid Ahmed*
416
+ * Create `parallel_worker_id` helper for running parallel tests. This allows users to
417
+ know which worker they are currently running in.
177
418
 
178
- * Deprecate `Benchmark.ms` core extension.
419
+ *Nick Schwaderer*
179
420
 
180
- The `benchmark` gem will become bundled in Ruby 3.5
421
+ * Make the cache of `ActiveSupport::Cache::Strategy::LocalCache::Middleware` updatable.
181
422
 
182
- *Earlopain*
423
+ If the cache client at `Rails.cache` of a booted application changes, the corresponding
424
+ mounted middleware needs to update in order for request-local caches to be setup properly.
425
+ Otherwise, redundant cache operations will erroneously hit the datastore.
183
426
 
184
- * `ActiveSupport::TimeWithZone#inspect` now uses ISO 8601 style time like `Time#inspect`
427
+ *Gannon McGibbon*
185
428
 
186
- *John Hawthorn*
429
+ * Add `assert_events_reported` test helper for `ActiveSupport::EventReporter`.
187
430
 
188
- * `ActiveSupport::ErrorReporter#report` now assigns a backtrace to unraised exceptions.
431
+ This new assertion allows testing multiple events in a single block, regardless of order:
189
432
 
190
- Previously reporting an un-raised exception would result in an error report without
191
- a backtrace. Now it automatically generates one.
433
+ ```ruby
434
+ assert_events_reported([
435
+ { name: "user.created", payload: { id: 123 } },
436
+ { name: "email.sent", payload: { to: "user@example.com" } }
437
+ ]) do
438
+ create_user_and_send_welcome_email
439
+ end
440
+ ```
192
441
 
193
- *Jean Boussier*
442
+ *George Ma*
443
+
444
+ * Add `ActiveSupport::TimeZone#standard_name` method.
445
+
446
+ ``` ruby
447
+ zone = ActiveSupport::TimeZone['Hawaii']
448
+ # Old way
449
+ ActiveSupport::TimeZone::MAPPING[zone.name]
450
+ # New way
451
+ zone.standard_name # => 'Pacific/Honolulu'
452
+ ```
453
+
454
+ *Bogdan Gusiev*
194
455
 
195
- * Add `escape_html_entities` option to `ActiveSupport::JSON.encode`.
456
+ * Add Structured Event Reporter, accessible via `Rails.event`.
196
457
 
197
- This allows for overriding the global configuration found at
198
- `ActiveSupport.escape_html_entities_in_json` for specific calls to `to_json`.
458
+ The Event Reporter provides a unified interface for producing structured events in Rails
459
+ applications:
199
460
 
200
- This should be usable from controllers in the following manner:
201
461
  ```ruby
202
- class MyController < ApplicationController
203
- def index
204
- render json: { hello: "world" }, escape_html_entities: false
462
+ Rails.event.notify("user.signup", user_id: 123, email: "user@example.com")
463
+ ```
464
+
465
+ It supports adding tags to events:
466
+
467
+ ```ruby
468
+ Rails.event.tagged("graphql") do
469
+ # Event includes tags: { graphql: true }
470
+ Rails.event.notify("user.signup", user_id: 123, email: "user@example.com")
471
+ end
472
+ ```
473
+
474
+ As well as context:
475
+ ```ruby
476
+ # All events will contain context: {request_id: "abc123", shop_id: 456}
477
+ Rails.event.set_context(request_id: "abc123", shop_id: 456)
478
+ ```
479
+
480
+ Events are emitted to subscribers. Applications register subscribers to
481
+ control how events are serialized and emitted. Subscribers must implement
482
+ an `#emit` method, which receives the event hash:
483
+
484
+ ```ruby
485
+ class LogSubscriber
486
+ def emit(event)
487
+ payload = event[:payload].map { |key, value| "#{key}=#{value}" }.join(" ")
488
+ source_location = event[:source_location]
489
+ log = "[#{event[:name]}] #{payload} at #{source_location[:filepath]}:#{source_location[:lineno]}"
490
+ Rails.logger.info(log)
205
491
  end
206
492
  end
207
493
  ```
208
494
 
209
- *Nigel Baillie*
495
+ *Adrianna Chang*
210
496
 
211
- * Raise when using key which can't respond to `#to_sym` in `EncryptedConfiguration`.
497
+ * Make `ActiveSupport::Logger` `#freeze`-friendly.
212
498
 
213
- As is the case when trying to use an Integer or Float as a key, which is unsupported.
499
+ *Joshua Young*
214
500
 
215
- *zzak*
501
+ * Make `ActiveSupport::Gzip.compress` deterministic based on input.
216
502
 
217
- * Deprecate addition and since between two `Time` and `ActiveSupport::TimeWithZone`.
503
+ `ActiveSupport::Gzip.compress` used to include a timestamp in the output,
504
+ causing consecutive calls with the same input data to have different output
505
+ if called during different seconds. It now always sets the timestamp to `0`
506
+ so that the output is identical for any given input.
218
507
 
219
- Previously adding time instances together such as `10.days.ago + 10.days.ago` or `10.days.ago.since(10.days.ago)` produced a nonsensical future date. This behavior is deprecated and will be removed in Rails 8.1.
508
+ *Rob Brackett*
220
509
 
221
- *Nick Schwaderer*
510
+ * Given an array of `Thread::Backtrace::Location` objects, the new method
511
+ `ActiveSupport::BacktraceCleaner#clean_locations` returns an array with the
512
+ clean ones:
222
513
 
223
- * Support rfc2822 format for Time#to_fs & Date#to_fs.
514
+ ```ruby
515
+ clean_locations = backtrace_cleaner.clean_locations(caller_locations)
516
+ ```
224
517
 
225
- *Akshay Birajdar*
518
+ Filters and silencers receive strings as usual. However, the `path`
519
+ attributes of the locations in the returned array are the original,
520
+ unfiltered ones, since locations are immutable.
226
521
 
227
- * Optimize load time for `Railtie#initialize_i18n`. Filter `I18n.load_path`s passed to the file watcher to only those
228
- under `Rails.root`. Previously the watcher would grab all available locales, including those in gems
229
- which do not require a watcher because they won't change.
522
+ *Xavier Noria*
230
523
 
231
- *Nick Schwaderer*
524
+ * Improve `CurrentAttributes` and `ExecutionContext` state managment in test cases.
525
+
526
+ Previously these two global state would be entirely cleared out whenever calling
527
+ into code that is wrapped by the Rails executor, typically Action Controller or
528
+ Active Job helpers:
529
+
530
+ ```ruby
531
+ test "#index works" do
532
+ CurrentUser.id = 42
533
+ get :index
534
+ CurrentUser.id == nil
535
+ end
536
+ ```
537
+
538
+ Now re-entering the executor properly save and restore that state.
539
+
540
+ *Jean Boussier*
541
+
542
+ * The new method `ActiveSupport::BacktraceCleaner#first_clean_location`
543
+ returns the first clean location of the caller's call stack, or `nil`.
544
+ Locations are `Thread::Backtrace::Location` objects. Useful when you want to
545
+ report the application-level location where something happened as an object.
546
+
547
+ *Xavier Noria*
548
+
549
+ * FileUpdateChecker and EventedFileUpdateChecker ignore changes in Gem.path now.
550
+
551
+ *Ermolaev Andrey*, *zzak*
552
+
553
+ * The new method `ActiveSupport::BacktraceCleaner#first_clean_frame` returns
554
+ the first clean frame of the caller's backtrace, or `nil`. Useful when you
555
+ want to report the application-level frame where something happened as a
556
+ string.
557
+
558
+ *Xavier Noria*
559
+
560
+ * Always clear `CurrentAttributes` instances.
561
+
562
+ Previously `CurrentAttributes` instance would be reset at the end of requests.
563
+ Meaning its attributes would be re-initialized.
564
+
565
+ This is problematic because it assume these objects don't hold any state
566
+ other than their declared attribute, which isn't always the case, and
567
+ can lead to state leak across request.
568
+
569
+ Now `CurrentAttributes` instances are abandoned at the end of a request,
570
+ and a new instance is created at the start of the next request.
571
+
572
+ *Jean Boussier*, *Janko Marohnić*
573
+
574
+ * Add public API for `before_fork_hook` in parallel testing.
575
+
576
+ Introduces a public API for calling the before fork hooks implemented by parallel testing.
577
+
578
+ ```ruby
579
+ parallelize_before_fork do
580
+ # perform an action before test processes are forked
581
+ end
582
+ ```
583
+
584
+ *Eileen M. Uchitelle*
585
+
586
+ * Implement ability to skip creating parallel testing databases.
587
+
588
+ With parallel testing, Rails will create a database per process. If this isn't
589
+ desirable or you would like to implement databases handling on your own, you can
590
+ now turn off this default behavior.
591
+
592
+ To skip creating a database per process, you can change it via the
593
+ `parallelize` method:
594
+
595
+ ```ruby
596
+ parallelize(workers: 10, parallelize_databases: false)
597
+ ```
598
+
599
+ or via the application configuration:
600
+
601
+ ```ruby
602
+ config.active_support.parallelize_databases = false
603
+ ```
604
+
605
+ *Eileen M. Uchitelle*
606
+
607
+ * Allow to configure maximum cache key sizes
608
+
609
+ When the key exceeds the configured limit (250 bytes by default), it will be truncated and
610
+ the digest of the rest of the key appended to it.
611
+
612
+ Note that previously `ActiveSupport::Cache::RedisCacheStore` allowed up to 1kb cache keys before
613
+ truncation, which is now reduced to 250 bytes.
614
+
615
+ ```ruby
616
+ config.cache_store = :redis_cache_store, { max_key_size: 64 }
617
+ ```
618
+
619
+ *fatkodima*
620
+
621
+ * Use `UNLINK` command instead of `DEL` in `ActiveSupport::Cache::RedisCacheStore` for non-blocking deletion.
622
+
623
+ *Aron Roh*
624
+
625
+ * Add `Cache#read_counter` and `Cache#write_counter`
626
+
627
+ ```ruby
628
+ Rails.cache.write_counter("foo", 1)
629
+ Rails.cache.read_counter("foo") # => 1
630
+ Rails.cache.increment("foo")
631
+ Rails.cache.read_counter("foo") # => 2
632
+ ```
633
+
634
+ *Alex Ghiculescu*
232
635
 
233
- * Add a `filter` option to `in_order_of` to prioritize certain values in the sorting without filtering the results
234
- by these values.
636
+ * Introduce ActiveSupport::Testing::ErrorReporterAssertions#capture_error_reports
235
637
 
236
- *Igor Depolli*
638
+ Captures all reported errors from within the block that match the given
639
+ error class.
237
640
 
238
- * Improve error message when using `assert_difference` or `assert_changes` with a
239
- proc by printing the proc's source code (MRI only).
641
+ ```ruby
642
+ reports = capture_error_reports(IOError) do
643
+ Rails.error.report(IOError.new("Oops"))
644
+ Rails.error.report(IOError.new("Oh no"))
645
+ Rails.error.report(StandardError.new)
646
+ end
647
+
648
+ assert_equal 2, reports.size
649
+ assert_equal "Oops", reports.first.error.message
650
+ assert_equal "Oh no", reports.last.error.message
651
+ ```
652
+
653
+ *Andrew Novoselac*
654
+
655
+ * Introduce ActiveSupport::ErrorReporter#add_middleware
656
+
657
+ When reporting an error, the error context middleware will be called with the reported error
658
+ and base execution context. The stack may mutate the context hash. The mutated context will
659
+ then be passed to error subscribers. Middleware receives the same parameters as `ErrorReporter#report`.
660
+
661
+ *Andrew Novoselac*, *Sam Schmidt*
662
+
663
+ * Change execution wrapping to report all exceptions, including `Exception`.
240
664
 
241
- *Richard Böhme*, *Jean Boussier*
665
+ If a more serious error like `SystemStackError` or `NoMemoryError` happens,
666
+ the error reporter should be able to report these kinds of exceptions.
667
+
668
+ *Gannon McGibbon*
669
+
670
+ * `ActiveSupport::Testing::Parallelization.before_fork_hook` allows declaration of callbacks that
671
+ are invoked immediately before forking test workers.
242
672
 
243
- * Add a new configuration value `:zone` for `ActiveSupport.to_time_preserves_timezone` and rename the previous `true` value to `:offset`. The new default value is `:zone`.
673
+ *Mike Dalessio*
674
+
675
+ * Allow the `#freeze_time` testing helper to accept a date or time argument.
676
+
677
+ ```ruby
678
+ Time.current # => Sun, 09 Jul 2024 15:34:49 EST -05:00
679
+ freeze_time Time.current + 1.day
680
+ sleep 1
681
+ Time.current # => Mon, 10 Jul 2024 15:34:49 EST -05:00
682
+ ```
244
683
 
245
- *Jason Kim*, *John Hawthorn*
684
+ *Joshua Young*
685
+
686
+ * `ActiveSupport::JSON` now accepts options
687
+
688
+ It is now possible to pass options to `ActiveSupport::JSON`:
689
+ ```ruby
690
+ ActiveSupport::JSON.decode('{"key": "value"}', symbolize_names: true) # => { key: "value" }
691
+ ```
692
+
693
+ *matthaigh27*
694
+
695
+ * `ActiveSupport::Testing::NotificationAssertions`'s `assert_notification` now matches against payload subsets by default.
696
+
697
+ Previously the following assertion would fail due to excess key vals in the notification payload. Now with payload subset matching, it will pass.
698
+
699
+ ```ruby
700
+ assert_notification("post.submitted", title: "Cool Post") do
701
+ ActiveSupport::Notifications.instrument("post.submitted", title: "Cool Post", body: "Cool Body")
702
+ end
703
+ ```
704
+
705
+ Additionally, you can now persist a matched notification for more customized assertions.
706
+
707
+ ```ruby
708
+ notification = assert_notification("post.submitted", title: "Cool Post") do
709
+ ActiveSupport::Notifications.instrument("post.submitted", title: "Cool Post", body: Body.new("Cool Body"))
710
+ end
711
+
712
+ assert_instance_of(Body, notification.payload[:body])
713
+ ```
246
714
 
247
- * Align instrumentation `payload[:key]` in ActiveSupport::Cache to follow the same pattern, with namespaced and normalized keys.
715
+ *Nicholas La Roux*
716
+
717
+ * Deprecate `String#mb_chars` and `ActiveSupport::Multibyte::Chars`.
718
+
719
+ These APIs are a relic of the Ruby 1.8 days when Ruby strings weren't encoding
720
+ aware. There is no legitimate reasons to need these APIs today.
721
+
722
+ *Jean Boussier*
723
+
724
+ * Deprecate `ActiveSupport::Configurable`
725
+
726
+ *Sean Doyle*
727
+
728
+ * `nil.to_query("key")` now returns `key`.
729
+
730
+ Previously it would return `key=`, preventing round tripping with `Rack::Utils.parse_nested_query`.
731
+
732
+ *Erol Fornoles*
733
+
734
+ * Avoid wrapping redis in a `ConnectionPool` when using `ActiveSupport::Cache::RedisCacheStore` if the `:redis`
735
+ option is already a `ConnectionPool`.
736
+
737
+ *Joshua Young*
738
+
739
+ * Alter `ERB::Util.tokenize` to return :PLAIN token with full input string when string doesn't contain ERB tags.
740
+
741
+ *Martin Emde*
742
+
743
+ * Fix a bug in `ERB::Util.tokenize` that causes incorrect tokenization when ERB tags are preceded by multibyte characters.
744
+
745
+ *Martin Emde*
746
+
747
+ * Add `ActiveSupport::Testing::NotificationAssertions` module to help with testing `ActiveSupport::Notifications`.
748
+
749
+ *Nicholas La Roux*, *Yishu See*, *Sean Doyle*
750
+
751
+ * `ActiveSupport::CurrentAttributes#attributes` now will return a new hash object on each call.
752
+
753
+ Previously, the same hash object was returned each time that method was called.
754
+
755
+ *fatkodima*
756
+
757
+ * `ActiveSupport::JSON.encode` supports CIDR notation.
758
+
759
+ Previously:
760
+
761
+ ```ruby
762
+ ActiveSupport::JSON.encode(IPAddr.new("172.16.0.0/24")) # => "\"172.16.0.0\""
763
+ ```
764
+
765
+ After this change:
766
+
767
+ ```ruby
768
+ ActiveSupport::JSON.encode(IPAddr.new("172.16.0.0/24")) # => "\"172.16.0.0/24\""
769
+ ```
248
770
 
249
- *Frederik Erbs Spang Thomsen*
771
+ *Taketo Takashima*
250
772
 
251
- * Fix `travel_to` to set usec 0 when `with_usec` is `false` and the given argument String or DateTime.
773
+ * Make `ActiveSupport::FileUpdateChecker` faster when checking many file-extensions.
252
774
 
253
- *mopp*
775
+ *Jonathan del Strother*
254
776
 
255
- Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/activesupport/CHANGELOG.md) for previous changes.
777
+ Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/activesupport/CHANGELOG.md) for previous changes.