Skip to content

Commit fdeba4a

Browse files
authored
Merge pull request rails#53268 from kamipo/fix_current_timestamp_test_failure
Fix `CURRENT_TIMESTAMP` test failure by setting time_zone correctly
2 parents f942221 + 19d01d1 commit fdeba4a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

activerecord/test/cases/date_time_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ def test_default_timezone_validation
1717
ActiveRecord.default_timezone = :utc
1818
end
1919

20+
def test_high_precision_current_timestamp
21+
current_timestamp = Task.with_connection { |conn| conn.high_precision_current_timestamp }
22+
23+
task = Task.create!
24+
task = Task.select(current_timestamp => :starting).find(task.id)
25+
26+
assert_in_delta Time.now, task.starting, 1
27+
end
28+
2029
def test_saves_both_date_and_time
2130
with_env_tz "America/New_York" do
2231
with_timezone_config default: :utc do

activerecord/test/config.example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ connections:
1818
<% if ENV['MYSQL_SOCK'] %>
1919
socket: "<%= ENV['MYSQL_SOCK'] %>"
2020
<% end %>
21+
variables:
22+
time_zone: '+00:00'
2123
arunit2:
2224
username: rails
2325
encoding: utf8mb4
@@ -52,6 +54,8 @@ connections:
5254
<% if ENV['MYSQL_SOCK'] %>
5355
socket: "<%= ENV['MYSQL_SOCK'] %>"
5456
<% end %>
57+
variables:
58+
time_zone: '+00:00'
5559
arunit2:
5660
username: rails
5761
encoding: utf8mb4

0 commit comments

Comments
 (0)