From 6795237a2d61390bc2f0d82f4252e8eddbe66dc2 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 25 Nov 2016 11:18:39 +1100 Subject: [PATCH] Put timecop into safe mode and fix leaky Timecop.freeze --- Gemfile.lock | 2 +- config/initializers/timecop.rb | 1 + spec/models/spree/product_spec.rb | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 config/initializers/timecop.rb diff --git a/Gemfile.lock b/Gemfile.lock index d346f7aa03..0dc7a067ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -594,7 +594,7 @@ GEM ref thor (0.19.1) tilt (1.4.1) - timecop (0.6.2.2) + timecop (0.8.1) timers (1.1.0) treetop (1.4.15) polyglot diff --git a/config/initializers/timecop.rb b/config/initializers/timecop.rb new file mode 100644 index 0000000000..f14c7d622d --- /dev/null +++ b/config/initializers/timecop.rb @@ -0,0 +1 @@ +Timecop.safe_mode = true diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 568d701ec9..4f63fe882b 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -33,9 +33,10 @@ module Spree end it "defaults available_on to now" do - Timecop.freeze - product = Product.new - product.available_on.should == Time.zone.now + Timecop.freeze do + product = Product.new + product.available_on.should == Time.zone.now + end end describe "tax category" do