Skip to content

Timezone test case is broken  #433

Description

@dmytro-strukov

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions