Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone test case is broken #433

Open
dmytro-strukov opened this issue Dec 19, 2024 · 0 comments
Open

Timezone test case is broken #433

dmytro-strukov opened this issue Dec 19, 2024 · 0 comments

Comments

@dmytro-strukov
Copy link

dmytro-strukov commented Dec 19, 2024

It does not change the time zone:

  # https://github.com/travisjeffery/timecop/blob/master/test/time_stack_item_test.rb#L278
  # 
  def test_freezing_a_time_with_zone_returns_proper_zones
    Time.zone = "Hawaii"
    t = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), ActiveSupport::TimeZone['Tokyo'])
    Timecop.freeze(t) do
      local_now = Time.now
      assert_equal t, local_now
      assert_equal t.getlocal.zone, local_now.zone

      zoned_now = Time.zone.now
      assert_equal t, zoned_now
      assert_equal 'HST', zoned_now.zone
    end
  end
[26] pry(#<TestTimeStackItem>)> t.zone
=> "JST"
[27] pry(#<TestTimeStackItem>)> local_now.zone
=> " 04"
[28] pry(#<TestTimeStackItem>)> t.getlocal.zone
=> " 04"

@travisjeffery @joshuacronemeyer Is it expected behavior? I wanted to use in my test cases Time.utc(2024, 1, 1), but because we use localtime here https://github.com/travisjeffery/timecop/blob/master/lib/timecop/time_stack_item.rb#L78 it does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant