From 81b279f1b6c676b4b5ecd081c7d4941a9caa35ed Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 7 May 2023 21:04:21 +0200 Subject: [PATCH] Floor times in tests This passed locally for me on macOS but does not pass on Linux due to a difference in precision for timestamps. --- spec/controllers/inbox_controller_spec.rb | 2 +- spec/controllers/notifications_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/inbox_controller_spec.rb b/spec/controllers/inbox_controller_spec.rb index c09663ba..94a8accf 100644 --- a/spec/controllers/inbox_controller_spec.rb +++ b/spec/controllers/inbox_controller_spec.rb @@ -68,7 +68,7 @@ describe InboxController, type: :controller do it "updates the the timestamp used for caching" do user.update(inbox_updated_at: original_inbox_updated_at) travel 1.second do - expect { subject }.to change { user.reload.inbox_updated_at }.from(original_inbox_updated_at).to(Time.now.utc) + expect { subject }.to change { user.reload.inbox_updated_at.floor }.from(original_inbox_updated_at.floor).to(Time.now.utc.floor) end end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 85241645..4eea29cf 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -45,7 +45,7 @@ describe NotificationsController do it "updates the the timestamp used for caching" do user.update(notifications_updated_at: original_notifications_updated_at) travel 1.second do - expect { subject }.to change { user.reload.notifications_updated_at }.from(original_notifications_updated_at).to(Time.now.utc) + expect { subject }.to change { user.reload.notifications_updated_at.floor }.from(original_notifications_updated_at.floor).to(Time.now.utc.floor) end end end