File tree Expand file tree Collapse file tree 8 files changed +40
-31
lines changed Expand file tree Collapse file tree 8 files changed +40
-31
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord ::QueryLogs ::TestHelper # :nodoc:
4
+ def before_setup
5
+ ActiveRecord ::QueryLogs . clear_context
6
+ super
7
+ end
8
+
9
+ def after_teardown
10
+ super
11
+ ActiveRecord ::QueryLogs . clear_context
12
+ end
13
+ end
Original file line number Diff line number Diff line change @@ -380,6 +380,11 @@ class Railtie < Rails::Railtie # :nodoc:
380
380
app . reloader . before_class_unload { ActiveRecord ::QueryLogs . clear_context }
381
381
app . executor . to_run { ActiveRecord ::QueryLogs . clear_context }
382
382
app . executor . to_complete { ActiveRecord ::QueryLogs . clear_context }
383
+
384
+ ActiveSupport . on_load ( :active_support_test_case ) do
385
+ require "active_record/query_logs/test_helper"
386
+ include ActiveRecord ::QueryLogs ::TestHelper
387
+ end
383
388
end
384
389
end
385
390
end
Original file line number Diff line number Diff line change 2
2
3
3
require "cases/helper"
4
4
require "models/dashboard"
5
+ require "active_record/query_logs/test_helper"
5
6
6
7
class QueryLogsTest < ActiveRecord ::TestCase
8
+ # Automatically included in Rails apps via railtie but that don't run here.
9
+ include ActiveRecord ::QueryLogs ::TestHelper
10
+
7
11
fixtures :dashboards
8
12
9
13
ActiveRecord ::QueryLogs . taggings [ :application ] = -> {
10
14
"active_record"
11
15
}
12
16
13
17
def setup
14
- # QueryLogs context is automatically reset in Rails app via an executor hooks set in railtie
15
- # But not in Active Record's own test suite.
16
- ActiveRecord ::QueryLogs . clear_context
17
-
18
18
# Enable the query tags logging
19
19
@original_transformers = ActiveRecord . query_transformers
20
20
@original_prepend = ActiveRecord ::QueryLogs . prepend_comment
@@ -28,9 +28,6 @@ def teardown
28
28
ActiveRecord . query_transformers = @original_transformers
29
29
ActiveRecord ::QueryLogs . prepend_comment = @original_prepend
30
30
ActiveRecord ::QueryLogs . tags = [ ]
31
- # QueryLogs context is automatically reset in Rails app via an executor hooks set in railtie
32
- # But not in Active Record's own test suite.
33
- ActiveRecord ::QueryLogs . clear_context
34
31
end
35
32
36
33
def test_escaping_good_comment
Original file line number Diff line number Diff line change 1
- * ` Rails.application.executor ` hooks are now called around every tests.
2
-
3
- This helps to better simulate request or job local state being reset.
4
-
5
- * Jean Boussier*
6
-
7
1
* Fix the ` Digest::UUID.uuid_from_hash ` behavior for namespace IDs that are different from the ones defined on ` Digest::UUID ` .
8
2
9
3
The new behavior will be enabled by setting the
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport ::CurrentAttributes ::TestHelper # :nodoc:
4
+ def before_setup
5
+ ActiveSupport ::CurrentAttributes . reset_all
6
+ super
7
+ end
8
+
9
+ def after_teardown
10
+ super
11
+ ActiveSupport ::CurrentAttributes . reset_all
12
+ end
13
+ end
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ class Railtie < Rails::Railtie # :nodoc:
33
33
app . executor . to_complete { ActiveSupport ::CurrentAttributes . reset_all }
34
34
35
35
ActiveSupport . on_load ( :active_support_test_case ) do
36
- require "active_support/executor /test_helper"
37
- include ActiveSupport ::Executor ::TestHelper
36
+ require "active_support/current_attributes /test_helper"
37
+ include ActiveSupport ::CurrentAttributes ::TestHelper
38
38
end
39
39
end
40
40
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require_relative "abstract_unit"
4
+ require "active_support/current_attributes/test_helper"
4
5
5
6
class CurrentAttributesTest < ActiveSupport ::TestCase
6
- # CurrentAttributes is automatically reset in Rails app via executor hooks set in railtie
7
- # But not in Active Support's own test suite.
8
- setup do
9
- ActiveSupport ::CurrentAttributes . reset_all
10
- end
11
-
12
- teardown do
13
- ActiveSupport ::CurrentAttributes . reset_all
14
- end
7
+ # Automatically included in Rails apps via railtie but that don't run here.
8
+ include ActiveSupport ::CurrentAttributes ::TestHelper
15
9
16
10
Person = Struct . new ( :id , :name , :time_zone )
17
11
You can’t perform that action at this time.
0 commit comments