Skip to content

Commit

Permalink
Catch Time.zone before TestHelper resets it to UTC
Browse files Browse the repository at this point in the history
This is most easiest done by switching to before_setup, which fits since
we're also testing the ordering of the reset calls provided by the
TestHelper.
  • Loading branch information
kaspth committed Jun 1, 2020
1 parent a9c27de commit 3b953da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions activesupport/test/current_attributes_test.rb
Expand Up @@ -47,8 +47,17 @@ class Session < ActiveSupport::CurrentAttributes
# Eagerly set-up `instance`s by reference.
[ Current.instance, Session.instance ]

setup { @original_time_zone = Time.zone }
teardown { Time.zone = @original_time_zone }
# Use library specific minitest hook to catch Time.zone before reset is called via TestHelper
def before_setup
@original_time_zone = Time.zone
super
end

# Use library specific minitest hook to set Time.zone after reset is called via TestHelper
def after_teardown
super
Time.zone = @original_time_zone
end

setup { assert_nil Session.previous, "Expected Session to not have leaked state" }

Expand Down

0 comments on commit 3b953da

Please sign in to comment.