From ce96094f4923a4b4caa2c4556d81312eacea1890 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 8 Aug 2022 12:23:11 +0100 Subject: [PATCH] Adds around block with time.freeze --- spec/system/admin/reports/packing_report_spec.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/system/admin/reports/packing_report_spec.rb b/spec/system/admin/reports/packing_report_spec.rb index 489df66e78..b5a1f4d1e5 100644 --- a/spec/system/admin/reports/packing_report_spec.rb +++ b/spec/system/admin/reports/packing_report_spec.rb @@ -6,6 +6,13 @@ describe "Packing Reports" do include AuthenticationHelper include WebHelper + around do |example| + Timecop.freeze(Time.zone.now.strftime("%Y-%m-%d 00:00")) { example.run } + end + + let!(:open_datetime) { (Time.zone.now - 1.month).strftime("%Y-%m-%d 00:00") } + let!(:close_datetime) { Time.zone.now.strftime("%Y-%m-%d 00:00") } + describe "Packing reports" do before do login_as_admin @@ -32,9 +39,6 @@ describe "Packing Reports" do let(:variant2) { create(:variant, product: product1, unit_description: "Small") } let(:product2) { create(:simple_product, name: "Product 2", supplier: supplier) } - let(:open_datetime) { (Time.zone.now - 1.month).strftime("%Y-%m-%d 00:00") } - let(:close_datetime) { Time.zone.now.strftime("%Y-%m-%d 00:00") } - before do order1.finalize! order2.finalize! @@ -115,9 +119,6 @@ describe "Packing Reports" do let(:li1) { build(:line_item_with_shipment) } let(:li2) { build(:line_item_with_shipment) } - let(:open_datetime) { (Time.zone.now - 1.month).strftime("%Y-%m-%d 00:00") } - let(:close_datetime) { Time.zone.now.strftime("%Y-%m-%d 00:00") } - before do order.line_items << li1 order.line_items << li2