From 5279be4dc6b9ee59e5bc1fc14724c87ff73f57b8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Fri, 17 Mar 2023 10:09:33 +0100 Subject: [PATCH] Improve spec: visiting order confirmation with distributor Two cases: - the current distributor is the same than the order of the order confirmation page - the current distributor *is not* the same than the order of the order confirmation page (and has not set `hide_ofn_navigation` preference to `true`) --- spec/system/consumer/white_label_spec.rb | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/spec/system/consumer/white_label_spec.rb b/spec/system/consumer/white_label_spec.rb index 0b6c10a6b8..ce1d52ab13 100644 --- a/spec/system/consumer/white_label_spec.rb +++ b/spec/system/consumer/white_label_spec.rb @@ -91,9 +91,31 @@ describe 'White label setting' do set_order(complete_order) end - it "hides the OFN navigation when visiting the order confirmation page" do - visit order_path(complete_order, order_token: complete_order.token) - expect(page).to have_no_selector ofn_navigation + shared_examples "hides the OFN navigation when needed only for the order confirmation" do + it "hides" do + visit order_path(complete_order, order_token: complete_order.token) + expect(page).to have_no_selector ofn_navigation + end + end + + context "when the current distributor is the distributor of the order" do + before do + allow_any_instance_of(EnterprisesHelper).to receive(:current_distributor). + and_return(distributor) + end + + it_behaves_like "hides the OFN navigation when needed only for the order confirmation" + end + + context "when the user has a current distributor that is not the distributor's order" do + let!(:another_distributor) { create(:distributor_enterprise) } + before do + another_distributor.update_attribute(:preferred_hide_ofn_navigation, false) + allow_any_instance_of(EnterprisesHelper).to receive(:current_distributor). + and_return(another_distributor) + end + + it_behaves_like "hides the OFN navigation when needed only for the order confirmation" end end