Merge pull request #6312 from mkllnk/variant-override-loading

Avoid loading variant overrides for no reason
This commit is contained in:
Luis Ramos
2020-11-06 03:59:33 +00:00
committed by GitHub
2 changed files with 6 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ module Spree
def current_order(create_order_if_necessary = false)
order = spree_current_order(create_order_if_necessary)
if order
if order&.line_items.present?
scoper = OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
order.line_items.each do |li|
scoper.scope(li.variant)

View File

@@ -91,6 +91,11 @@ describe BaseController, type: :controller do
expect(session[:order_id]).to_not eq last_cart.id
expect(controller.current_order.line_items.count).to eq 0
end
it "doesn't load variant overrides without line items" do
expect(VariantOverride).to_not receive(:indexed)
controller.current_order(true)
end
end
it "redirects to home with message if order cycle is expired" do