File tree Expand file tree Collapse file tree 4 files changed +18
-28
lines changed
lib/active_support/deprecation Expand file tree Collapse file tree 4 files changed +18
-28
lines changed Original file line number Diff line number Diff line change
1
+ * Remove deprecated support to passing an array of strings to ` ActiveSupport::Deprecation#warn ` .
2
+
3
+ * Rafael Mendonça França*
4
+
1
5
* Remove deprecated support to setting ` attr_internal_naming_format ` with a ` @ ` prefix.
2
6
3
7
* Rafael Mendonça França*
Original file line number Diff line number Diff line change @@ -139,7 +139,6 @@ def deprecation_caller_message(callstack)
139
139
140
140
def extract_callstack ( callstack )
141
141
return [ ] if callstack . empty?
142
- return _extract_callstack ( callstack ) if callstack . first . is_a? String
143
142
144
143
offending_line = callstack . find { |frame |
145
144
# Code generated with `eval` doesn't have an `absolute_path`, e.g. templates.
@@ -150,24 +149,6 @@ def extract_callstack(callstack)
150
149
[ offending_line . path , offending_line . lineno , offending_line . label ]
151
150
end
152
151
153
- def _extract_callstack ( callstack )
154
- ActiveSupport . deprecator . warn ( <<~MESSAGE )
155
- Passing the result of `caller` to ActiveSupport::Deprecation#warn is deprecated and will be removed in Rails 8.0.
156
-
157
- Please pass the result of `caller_locations` instead.
158
- MESSAGE
159
-
160
- offending_line = callstack . find { |line | !ignored_callstack? ( line ) } || callstack . first
161
-
162
- if offending_line
163
- if md = offending_line . match ( /^(.+?):(\d +)(?::in `(.*?)')?/ )
164
- md . captures
165
- else
166
- offending_line
167
- end
168
- end
169
- end
170
-
171
152
RAILS_GEM_ROOT = File . expand_path ( "../../../.." , __dir__ ) + "/" # :nodoc:
172
153
LIB_DIR = RbConfig ::CONFIG [ "libdir" ] # :nodoc:
173
154
Original file line number Diff line number Diff line change @@ -39,14 +39,6 @@ def setup
39
39
end
40
40
end
41
41
42
- test "passing callstack as `caller` is deprecated" do
43
- assert_deprecated ( /Passing the result of `caller` to ActiveSupport::Deprecation#warn/ , ActiveSupport . deprecator ) do
44
- assert_deprecated ( @deprecator ) do
45
- @deprecator . warn ( "Yo dawg!" , caller )
46
- end
47
- end
48
- end
49
-
50
42
test "assert_deprecated requires a deprecator" do
51
43
assert_raises ( ArgumentError ) do
52
44
assert_deprecated do
@@ -196,11 +188,22 @@ def setup
196
188
assert_match "call stack!" , output
197
189
end
198
190
191
+ class CallerLocation
192
+ attr_reader :path , :lineno , :label
193
+ alias_method :absolute_path , :path
194
+
195
+ def initialize ( label , lineno )
196
+ @path = __FILE__
197
+ @lineno = lineno
198
+ @label = label
199
+ end
200
+ end
201
+
199
202
test ":stderr behavior with #warn" do
200
203
@deprecator . behavior = :stderr
201
204
202
205
output = capture ( :stderr ) do
203
- @deprecator . warn ( "Instance error!" , [ "instance call stack!" ] )
206
+ @deprecator . warn ( "Instance error!" , [ CallerLocation . new ( "instance call stack!" , __LINE__ ) ] )
204
207
end
205
208
206
209
assert_match ( /Instance error!/ , output )
Original file line number Diff line number Diff line change @@ -144,6 +144,8 @@ Please refer to the [Changelog][active-support] for detailed changes.
144
144
145
145
* Remove deprecated support to setting ` attr_internal_naming_format ` with a ` @ ` prefix.
146
146
147
+ * Remove deprecated support to passing an array of strings to ` ActiveSupport::Deprecation#warn ` .
148
+
147
149
### Deprecations
148
150
149
151
### Notable changes
You can’t perform that action at this time.
0 commit comments