Skip to content

Commit 35ca222

Browse files
author
Alireza Bashiri
committed
Test DST both in local and utc timezone
Also? Updated failing test.
1 parent e8747cb commit 35ca222

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

activerecord/test/cases/quoting_test.rb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def test_quoted_time_utc
7171
with_timezone_config default: :utc do
7272
t = Time.now.change(usec: 0)
7373

74-
expected = t.getutc.change(year: 2000, month: 1, day: 1)
75-
expected = expected.to_s(:db).sub("2000-01-01 ", "")
74+
expected = t.change(year: 2000, month: 1, day: 1)
75+
expected = expected.getutc.to_s(:db).slice(11..-1)
7676

7777
assert_equal expected, @quoter.quoted_time(t)
7878
end
@@ -89,6 +89,28 @@ def test_quoted_time_local
8989
end
9090
end
9191

92+
def test_quoted_time_dst_utc
93+
with_timezone_config default: :utc do
94+
t = Time.new(2000, 7, 1, 0, 0, 0, "+04:30")
95+
96+
expected = t.change(year: 2000, month: 1, day: 1)
97+
expected = expected.getutc.to_s(:db).slice(11..-1)
98+
99+
assert_equal expected, @quoter.quoted_time(t)
100+
end
101+
end
102+
103+
def test_quoted_time_dst_local
104+
with_timezone_config default: :local do
105+
t = Time.new(2000, 7, 1, 0, 0, 0, "+04:30")
106+
107+
expected = t.change(year: 2000, month: 1, day: 1)
108+
expected = expected.getlocal.to_s(:db).slice(11..-1)
109+
110+
assert_equal expected, @quoter.quoted_time(t)
111+
end
112+
end
113+
92114
def test_quoted_time_crazy
93115
with_timezone_config default: :asdfasdf do
94116
t = Time.now.change(usec: 0)

0 commit comments

Comments
 (0)