Allow access to CurrentAttributes in test teardown

This commit is contained in:
Étienne Barrié 2020-11-09 15:15:42 -05:00
parent f432f70aeb
commit 0400be279b
2 changed files with 10 additions and 2 deletions

View File

@ -6,8 +6,8 @@ module ActiveSupport::CurrentAttributes::TestHelper # :nodoc:
super super
end end
def before_teardown def after_teardown
ActiveSupport::CurrentAttributes.reset_all
super super
ActiveSupport::CurrentAttributes.reset_all
end end
end end

View File

@ -126,6 +126,14 @@ class CurrentAttributesTest < ActiveSupport::TestCase
assert_equal "account/1", Current.account assert_equal "account/1", Current.account
end end
setup { @testing_teardown = false }
teardown { assert_equal 42, Session.current if @testing_teardown }
test "accessing attributes in teardown" do
Session.current = 42
@testing_teardown = true
end
test "delegation" do test "delegation" do
Current.person = Person.new(42, "David", "Central Time (US & Canada)") Current.person = Person.new(42, "David", "Central Time (US & Canada)")
assert_equal "Central Time (US & Canada)", Current.time_zone assert_equal "Central Time (US & Canada)", Current.time_zone