mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Call Executor#wrap around each test"
This commit is contained in:
parent
18922cccd4
commit
d2734111dd
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.reloader.before_class_unload { ActiveRecord::QueryLogs.clear_context }
|
||||||
app.executor.to_run { ActiveRecord::QueryLogs.clear_context }
|
app.executor.to_run { ActiveRecord::QueryLogs.clear_context }
|
||||||
app.executor.to_complete { 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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
require "cases/helper"
|
require "cases/helper"
|
||||||
require "models/dashboard"
|
require "models/dashboard"
|
||||||
|
require "active_record/query_logs/test_helper"
|
||||||
|
|
||||||
class QueryLogsTest < ActiveRecord::TestCase
|
class QueryLogsTest < ActiveRecord::TestCase
|
||||||
|
# Automatically included in Rails apps via railtie but that don't run here.
|
||||||
|
include ActiveRecord::QueryLogs::TestHelper
|
||||||
|
|
||||||
fixtures :dashboards
|
fixtures :dashboards
|
||||||
|
|
||||||
ActiveRecord::QueryLogs.taggings[:application] = -> {
|
ActiveRecord::QueryLogs.taggings[:application] = -> {
|
||||||
|
@ -11,10 +15,6 @@ class QueryLogsTest < ActiveRecord::TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
def setup
|
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
|
# Enable the query tags logging
|
||||||
@original_transformers = ActiveRecord.query_transformers
|
@original_transformers = ActiveRecord.query_transformers
|
||||||
@original_prepend = ActiveRecord::QueryLogs.prepend_comment
|
@original_prepend = ActiveRecord::QueryLogs.prepend_comment
|
||||||
|
@ -28,9 +28,6 @@ class QueryLogsTest < ActiveRecord::TestCase
|
||||||
ActiveRecord.query_transformers = @original_transformers
|
ActiveRecord.query_transformers = @original_transformers
|
||||||
ActiveRecord::QueryLogs.prepend_comment = @original_prepend
|
ActiveRecord::QueryLogs.prepend_comment = @original_prepend
|
||||||
ActiveRecord::QueryLogs.tags = []
|
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
|
end
|
||||||
|
|
||||||
def test_escaping_good_comment
|
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`.
|
* 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
|
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 }
|
app.executor.to_complete { ActiveSupport::CurrentAttributes.reset_all }
|
||||||
|
|
||||||
ActiveSupport.on_load(:active_support_test_case) do
|
ActiveSupport.on_load(:active_support_test_case) do
|
||||||
require "active_support/executor/test_helper"
|
require "active_support/current_attributes/test_helper"
|
||||||
include ActiveSupport::Executor::TestHelper
|
include ActiveSupport::CurrentAttributes::TestHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "abstract_unit"
|
require_relative "abstract_unit"
|
||||||
|
require "active_support/current_attributes/test_helper"
|
||||||
|
|
||||||
class CurrentAttributesTest < ActiveSupport::TestCase
|
class CurrentAttributesTest < ActiveSupport::TestCase
|
||||||
# CurrentAttributes is automatically reset in Rails app via executor hooks set in railtie
|
# Automatically included in Rails apps via railtie but that don't run here.
|
||||||
# But not in Active Support's own test suite.
|
include ActiveSupport::CurrentAttributes::TestHelper
|
||||||
setup do
|
|
||||||
ActiveSupport::CurrentAttributes.reset_all
|
|
||||||
end
|
|
||||||
|
|
||||||
teardown do
|
|
||||||
ActiveSupport::CurrentAttributes.reset_all
|
|
||||||
end
|
|
||||||
|
|
||||||
Person = Struct.new(:id, :name, :time_zone)
|
Person = Struct.new(:id, :name, :time_zone)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue