File tree Expand file tree Collapse file tree 4 files changed +20
-10
lines changed Expand file tree Collapse file tree 4 files changed +20
-10
lines changed Original file line number Diff line number Diff line change
1
+ * Always clear ` CurrentAttribute ` instances.
2
+
3
+ Previously ` CurrentAttribute ` instance would be reset at the end of requests.
4
+ Meaning its attributes would be re-initialized.
5
+
6
+ This is problematic because it assume these objects don't hold any state
7
+ other than their declared attribute, which isn't always the case, and
8
+ can lead to state leak across request.
9
+
10
+ Now ` CurrentAttribute ` instances are abandonned at the end of a request,
11
+ and a new instance is created at the start of the next request.
12
+
13
+ * Jean Boussier* , * Janko Marohnić*
14
+
1
15
* Add public API for ` before_fork_hook ` in parallel testing.
2
16
3
17
Introduces a public API for calling the before fork hooks implemented by parallel testing.
Original file line number Diff line number Diff line change @@ -153,12 +153,8 @@ def resets(*methods, &block)
153
153
154
154
delegate :set , :reset , to : :instance
155
155
156
- def reset_all # :nodoc:
157
- current_instances . each_value ( &:reset )
158
- end
159
-
160
156
def clear_all # :nodoc:
161
- reset_all
157
+ current_instances . each_value ( & :reset )
162
158
current_instances . clear
163
159
end
164
160
Original file line number Diff line number Diff line change 2
2
3
3
module ActiveSupport ::CurrentAttributes ::TestHelper # :nodoc:
4
4
def before_setup
5
- ActiveSupport ::CurrentAttributes . reset_all
5
+ ActiveSupport ::CurrentAttributes . clear_all
6
6
super
7
7
end
8
8
9
9
def after_teardown
10
10
super
11
- ActiveSupport ::CurrentAttributes . reset_all
11
+ ActiveSupport ::CurrentAttributes . clear_all
12
12
end
13
13
end
Original file line number Diff line number Diff line change @@ -44,10 +44,10 @@ class Railtie < Rails::Railtie # :nodoc:
44
44
app . executor . to_complete { ActiveSupport ::ExecutionContext . clear }
45
45
end
46
46
47
- initializer "active_support.reset_all_current_attributes_instances " do |app |
47
+ initializer "active_support.clear_all_current_attributes_instances " do |app |
48
48
app . reloader . before_class_unload { ActiveSupport ::CurrentAttributes . clear_all }
49
- app . executor . to_run { ActiveSupport ::CurrentAttributes . reset_all }
50
- app . executor . to_complete { ActiveSupport ::CurrentAttributes . reset_all }
49
+ app . executor . to_run { ActiveSupport ::CurrentAttributes . clear_all }
50
+ app . executor . to_complete { ActiveSupport ::CurrentAttributes . clear_all }
51
51
52
52
ActiveSupport . on_load ( :active_support_test_case ) do
53
53
if app . config . active_support . executor_around_test_case
You can’t perform that action at this time.
0 commit comments