mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #43553 from rails/revert-43546-as-test-case-executor-wrap
Revert "Call Executor#wrap around each test"
This commit is contained in:
commit
63ff0d7a71
8 changed files with 40 additions and 31 deletions
13
activerecord/lib/active_record/query_logs/test_helper.rb
Normal file
13
activerecord/lib/active_record/query_logs/test_helper.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActiveRecord::QueryLogs::TestHelper # :nodoc:
|
||||
def before_setup
|
||||
ActiveRecord::QueryLogs.clear_context
|
||||
super
|
||||
end
|
||||
|
||||
def after_teardown
|
||||
super
|
||||
ActiveRecord::QueryLogs.clear_context
|
||||
end
|
||||
end
|
|
@ -380,6 +380,11 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|||
app.reloader.before_class_unload { ActiveRecord::QueryLogs.clear_context }
|
||||
app.executor.to_run { ActiveRecord::QueryLogs.clear_context }
|
||||
app.executor.to_complete { ActiveRecord::QueryLogs.clear_context }
|
||||
|
||||
ActiveSupport.on_load(:active_support_test_case) do
|
||||
require "active_record/query_logs/test_helper"
|
||||
include ActiveRecord::QueryLogs::TestHelper
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
require "cases/helper"
|
||||
require "models/dashboard"
|
||||
require "active_record/query_logs/test_helper"
|
||||
|
||||
class QueryLogsTest < ActiveRecord::TestCase
|
||||
# Automatically included in Rails apps via railtie but that don't run here.
|
||||
include ActiveRecord::QueryLogs::TestHelper
|
||||
|
||||
fixtures :dashboards
|
||||
|
||||
ActiveRecord::QueryLogs.taggings[:application] = -> {
|
||||
|
@ -11,10 +15,6 @@ class QueryLogsTest < ActiveRecord::TestCase
|
|||
}
|
||||
|
||||
def setup
|
||||
# QueryLogs context is automatically reset in Rails app via an executor hooks set in railtie
|
||||
# But not in Active Record's own test suite.
|
||||
ActiveRecord::QueryLogs.clear_context
|
||||
|
||||
# Enable the query tags logging
|
||||
@original_transformers = ActiveRecord.query_transformers
|
||||
@original_prepend = ActiveRecord::QueryLogs.prepend_comment
|
||||
|
@ -28,9 +28,6 @@ class QueryLogsTest < ActiveRecord::TestCase
|
|||
ActiveRecord.query_transformers = @original_transformers
|
||||
ActiveRecord::QueryLogs.prepend_comment = @original_prepend
|
||||
ActiveRecord::QueryLogs.tags = []
|
||||
# QueryLogs context is automatically reset in Rails app via an executor hooks set in railtie
|
||||
# But not in Active Record's own test suite.
|
||||
ActiveRecord::QueryLogs.clear_context
|
||||
end
|
||||
|
||||
def test_escaping_good_comment
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
* `Rails.application.executor` hooks are now called around every tests.
|
||||
|
||||
This helps to better simulate request or job local state being reset.
|
||||
|
||||
*Jean Boussier*
|
||||
|
||||
* Fix the `Digest::UUID.uuid_from_hash` behavior for namespace IDs that are different from the ones defined on `Digest::UUID`.
|
||||
|
||||
The new behavior will be enabled by setting the
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActiveSupport::CurrentAttributes::TestHelper # :nodoc:
|
||||
def before_setup
|
||||
ActiveSupport::CurrentAttributes.reset_all
|
||||
super
|
||||
end
|
||||
|
||||
def after_teardown
|
||||
super
|
||||
ActiveSupport::CurrentAttributes.reset_all
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActiveSupport::Executor::TestHelper # :nodoc:
|
||||
def run(...)
|
||||
Rails.application.executor.wrap { super }
|
||||
end
|
||||
end
|
|
@ -33,8 +33,8 @@ module ActiveSupport
|
|||
app.executor.to_complete { ActiveSupport::CurrentAttributes.reset_all }
|
||||
|
||||
ActiveSupport.on_load(:active_support_test_case) do
|
||||
require "active_support/executor/test_helper"
|
||||
include ActiveSupport::Executor::TestHelper
|
||||
require "active_support/current_attributes/test_helper"
|
||||
include ActiveSupport::CurrentAttributes::TestHelper
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative "abstract_unit"
|
||||
require "active_support/current_attributes/test_helper"
|
||||
|
||||
class CurrentAttributesTest < ActiveSupport::TestCase
|
||||
# CurrentAttributes is automatically reset in Rails app via executor hooks set in railtie
|
||||
# But not in Active Support's own test suite.
|
||||
setup do
|
||||
ActiveSupport::CurrentAttributes.reset_all
|
||||
end
|
||||
|
||||
teardown do
|
||||
ActiveSupport::CurrentAttributes.reset_all
|
||||
end
|
||||
# Automatically included in Rails apps via railtie but that don't run here.
|
||||
include ActiveSupport::CurrentAttributes::TestHelper
|
||||
|
||||
Person = Struct.new(:id, :name, :time_zone)
|
||||
|
||||
|
|
Loading…
Reference in a new issue