Skip to content

Commit

Permalink
Don't encourage using octals for dates and times
Browse files Browse the repository at this point in the history
This could result in confusing errors or inconsistency for 08 and 09
  • Loading branch information
ianfleeton committed Jan 15, 2020
1 parent bdc7ebc commit 684ae07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion actionmailer/test/message_delivery_test.rb
Expand Up @@ -76,7 +76,7 @@ def test_should_enqueue_and_run_correctly_in_activejob
end

test "should enqueue a delivery with a delay" do
travel_to Time.new(2004, 11, 24, 01, 04, 44) do
travel_to Time.new(2004, 11, 24, 1, 4, 44) do
assert_performed_with(job: ActionMailer::MailDeliveryJob, at: Time.current + 10.minutes, args: ["DelayedMailer", "test_message", "deliver_now", args: [1, 2, 3]]) do
@mail.deliver_later wait: 10.minutes
end
Expand Down
8 changes: 4 additions & 4 deletions activesupport/lib/active_support/testing/time_helpers.rb
Expand Up @@ -86,7 +86,7 @@ def travel(duration, &block)
# The stubs are automatically removed at the end of the test.
#
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
# travel_to Time.zone.local(2004, 11, 24, 1, 4, 44)
# Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
# Date.current # => Wed, 24 Nov 2004
# DateTime.current # => Wed, 24 Nov 2004 01:04:44 -0500
Expand All @@ -108,7 +108,7 @@ def travel(duration, &block)
# state at the end of the block:
#
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44) do
# travel_to Time.zone.local(2004, 11, 24, 1, 4, 44) do
# Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
# end
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
Expand Down Expand Up @@ -165,7 +165,7 @@ def travel_to(date_or_time)
#
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
#
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
# travel_to Time.zone.local(2004, 11, 24, 1, 4, 44)
# Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
#
# travel_back
Expand All @@ -175,7 +175,7 @@ def travel_to(date_or_time)
#
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
#
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
# travel_to Time.zone.local(2004, 11, 24, 1, 4, 44)
# Time.current # => Wed, 24 Nov 2004 01:04:44 EST -05:00
#
# travel_back do
Expand Down
20 changes: 10 additions & 10 deletions activesupport/test/time_travel_test.rb
Expand Up @@ -43,7 +43,7 @@ def test_time_helper_travel_with_block

def test_time_helper_travel_to
Time.stub(:now, Time.now) do
expected_time = Time.new(2004, 11, 24, 01, 04, 44)
expected_time = Time.new(2004, 11, 24, 1, 4, 44)
travel_to expected_time

assert_equal expected_time, Time.now
Expand All @@ -56,7 +56,7 @@ def test_time_helper_travel_to

def test_time_helper_travel_to_with_block
Time.stub(:now, Time.now) do
expected_time = Time.new(2004, 11, 24, 01, 04, 44)
expected_time = Time.new(2004, 11, 24, 1, 4, 44)

travel_to expected_time do
assert_equal expected_time, Time.now
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_time_helper_travel_to_with_time_zone

def test_time_helper_travel_back
Time.stub(:now, Time.now) do
expected_time = Time.new(2004, 11, 24, 01, 04, 44)
expected_time = Time.new(2004, 11, 24, 1, 4, 44)

travel_to expected_time
assert_equal expected_time, Time.now
Expand All @@ -104,7 +104,7 @@ def test_time_helper_travel_back

def test_time_helper_travel_back_with_block
Time.stub(:now, Time.now) do
expected_time = Time.new(2004, 11, 24, 01, 04, 44)
expected_time = Time.new(2004, 11, 24, 1, 4, 44)

travel_to expected_time
assert_equal expected_time, Time.now
Expand All @@ -127,8 +127,8 @@ def test_time_helper_travel_back_with_block

def test_time_helper_travel_to_with_nested_calls_with_blocks
Time.stub(:now, Time.now) do
outer_expected_time = Time.new(2004, 11, 24, 01, 04, 44)
inner_expected_time = Time.new(2004, 10, 24, 01, 04, 44)
outer_expected_time = Time.new(2004, 11, 24, 1, 4, 44)
inner_expected_time = Time.new(2004, 10, 24, 1, 4, 44)
travel_to outer_expected_time do
e = assert_raises(RuntimeError) do
travel_to(inner_expected_time) do
Expand All @@ -142,8 +142,8 @@ def test_time_helper_travel_to_with_nested_calls_with_blocks

def test_time_helper_travel_to_with_nested_calls
Time.stub(:now, Time.now) do
outer_expected_time = Time.new(2004, 11, 24, 01, 04, 44)
inner_expected_time = Time.new(2004, 10, 24, 01, 04, 44)
outer_expected_time = Time.new(2004, 11, 24, 1, 4, 44)
inner_expected_time = Time.new(2004, 10, 24, 1, 4, 44)
travel_to outer_expected_time do
assert_nothing_raised do
travel_to(inner_expected_time)
Expand All @@ -156,8 +156,8 @@ def test_time_helper_travel_to_with_nested_calls

def test_time_helper_travel_to_with_subsequent_calls
Time.stub(:now, Time.now) do
initial_expected_time = Time.new(2004, 11, 24, 01, 04, 44)
subsequent_expected_time = Time.new(2004, 10, 24, 01, 04, 44)
initial_expected_time = Time.new(2004, 11, 24, 1, 4, 44)
subsequent_expected_time = Time.new(2004, 10, 24, 1, 4, 44)
assert_nothing_raised do
travel_to initial_expected_time
travel_to subsequent_expected_time
Expand Down

0 comments on commit 684ae07

Please sign in to comment.