From 318957551f4e09efa672c611c43268b5c233abde Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 16 Apr 2015 12:19:35 +1000 Subject: [PATCH] Freeze time to make spec repeatable --- .../admin/enterprises_controller_spec.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index 4604520c00..c783f958c5 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -283,12 +283,14 @@ module Admin end it "is disallowed" do - spree_post :set_sells, { id: enterprise, sells: 'own' } - expect(response).to redirect_to spree.admin_path - trial_expiry = Date.today.strftime("%Y-%m-%d") - expect(flash[:error]).to eq "Sorry, but you've already had a trial. Expired on: #{trial_expiry}" - expect(enterprise.reload.sells).to eq 'own' - expect(enterprise.reload.shop_trial_start_date).to eq (Date.today - 30.days).to_time + Timecop.freeze(Time.zone.local(2015, 4, 16, 14, 0, 0)) do + spree_post :set_sells, { id: enterprise, sells: 'own' } + expect(response).to redirect_to spree.admin_path + trial_expiry = Date.today.strftime("%Y-%m-%d") + expect(flash[:error]).to eq "Sorry, but you've already had a trial. Expired on: #{trial_expiry}" + expect(enterprise.reload.sells).to eq 'own' + expect(enterprise.reload.shop_trial_start_date).to eq (Date.today - 30.days).to_time + end end end