diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index 60de9e33a1..d3d1a155c1 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -18,7 +18,7 @@ module Spree def changeable_orders # Only returns open order for the current user + shop + oc combo @changeable_orders ||= if spree_current_user && - current_distributor&.allow_order_changes? && current_order_cycle + current_order_cycle && current_distributor&.allow_order_changes? Spree::Order.complete.where( state: 'complete', diff --git a/spec/helpers/spree/orders_helper_spec.rb b/spec/helpers/spree/orders_helper_spec.rb index 1b47d33a0e..a44bd9afab 100644 --- a/spec/helpers/spree/orders_helper_spec.rb +++ b/spec/helpers/spree/orders_helper_spec.rb @@ -31,6 +31,11 @@ describe Spree::OrdersHelper, type: :helper do before { allow(current_distributor).to receive(:allow_order_changes?) { false } } it { expect(helper.changeable_orders).to eq [] } end + + context "when a current_distributor is not defined" do + let(:current_distributor) { nil } + it { expect(helper.changeable_orders).to eq [] } + end end context "when a current_order_cycle is not defined" do @@ -38,11 +43,6 @@ describe Spree::OrdersHelper, type: :helper do it { expect(helper.changeable_orders).to eq [] } end end - - context "when a current_distributor is not defined" do - let(:current_distributor) { nil } - it { expect(helper.changeable_orders).to eq [] } - end end context "when spree_current_user is not defined" do