mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Merge pull request #6312 from mkllnk/variant-override-loading
Avoid loading variant overrides for no reason
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user