From 621933c727071e1f540b90cd897b5d1aeab65be0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 17 Mar 2022 10:40:38 +0100 Subject: [PATCH] Improve spec by creating its opposite ie. when distributor don't allow order changes --- spec/system/consumer/split_checkout_spec.rb | 39 +++++++++++++-------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index dad1655300..6244f74534 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -506,8 +506,7 @@ describe "As a consumer, I want to checkout my order", js: true do context "summary step" do let(:order) { - create(:order_ready_for_confirmation, distributor: distributor, - order_cycle: order_cycle, user_id: user.id) + create(:order_ready_for_confirmation, distributor: distributor) } describe "completing the checkout" do @@ -670,22 +669,32 @@ describe "As a consumer, I want to checkout my order", js: true do expect(page).to have_current_path checkout_step_path(:payment) end end + end - context "with previous open orders" do - let!(:prev_order) { - create(:completed_order_with_totals, - order_cycle: order_cycle, distributor: distributor, user_id: order.user_id) - } + context "with previous open orders" do + let(:order) { + create(:order_ready_for_confirmation, distributor: distributor, + order_cycle: order_cycle, user_id: user.id) + } + let!(:prev_order) { + create(:completed_order_with_totals, + order_cycle: order_cycle, distributor: distributor, user_id: order.user_id) + } - before do - order.distributor.allow_order_changes = true - order.distributor.save - end + it "informs about previous orders if distributor allow order changes" do + order.distributor.allow_order_changes = true + order.distributor.save + visit checkout_step_path(:summary) - it "informs about previous orders" do - pending("issue #9007") - expect(page).to have_content("You have an order for this order cycle already.") - end + expect(page).to have_content("You have an order for this order cycle already.") + end + + it "don't display any message if distributor don't allow order changes" do + order.distributor.allow_order_changes = false + order.distributor.save + visit checkout_step_path(:summary) + + expect(page).to_not have_content("You have an order for this order cycle already.") end end end