From c12edda766bddd557742619074e68444e3edcd72 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 24 Jul 2017 15:40:57 +0900 Subject: [PATCH] Use `Timecop.freeze` instead of `Timecop.travel`. --- spec/services/post_alerter_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb index 8f04f48e5ec..3dd7334e184 100644 --- a/spec/services/post_alerter_spec.rb +++ b/spec/services/post_alerter_spec.rb @@ -147,8 +147,9 @@ describe PostAlerter do admin2 = Fabricate(:admin) # Travel 1 hour in time to test that order post_actions by `created_at` - Timecop.travel(Time.zone.now + 1.hour) - PostAction.act(admin2, post, PostActionType.types[:like]) + Timecop.freeze(1.hour.from_now) do + PostAction.act(admin2, post, PostActionType.types[:like]) + end expect(Notification.where(post_number: 1, topic_id: post.topic_id).count) .to eq(1)