mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
allow any quantity if variant is set to on demand
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
= "#{count} x #{t(state.humanize.downcase, scope: [:spree, :shipment_states], default: [:missing, "none"])}"
|
||||
- unless shipment.shipped?
|
||||
%td.item-qty-edit.hidden
|
||||
= number_field_tag :quantity, item.quantity, :min => 0, :class => "line_item_quantity", :size => 5, :max => item.variant.on_hand + item.quantity
|
||||
- html_options = { :min => 0, :class => "line_item_quantity", :size => 5 }
|
||||
- html_options.merge!({ :max => item.variant.on_hand + item.quantity }) unless item.variant.on_demand
|
||||
= number_field_tag :quantity, item.quantity, html_options
|
||||
%td.item-total.align-center
|
||||
= line_item_shipment_price(line_item, item.quantity)
|
||||
|
||||
|
||||
@@ -146,6 +146,27 @@ feature '
|
||||
expect(order.reload.line_items.first.quantity).to eq(max_quantity)
|
||||
end
|
||||
|
||||
scenario "there are infinite items available (variant is on demand)" do
|
||||
# Move the order back to the cart state
|
||||
order.state = 'cart'
|
||||
order.completed_at = nil
|
||||
order.line_items.first.variant.update_attribute(:on_demand, true)
|
||||
|
||||
login_as_admin_and_visit spree.edit_admin_order_path(order)
|
||||
|
||||
within("tr.stock-item", text: order.products.first.name) do
|
||||
find("a.edit-item").click
|
||||
expect(page).to have_input(:quantity)
|
||||
fill_in(:quantity, with: 1000)
|
||||
find("a.save-item").click
|
||||
end
|
||||
|
||||
within("tr.stock-item", text: order.products.first.name) do
|
||||
expect(page).to have_text("1000 x")
|
||||
end
|
||||
expect(order.reload.line_items.first.quantity).to eq(1000)
|
||||
end
|
||||
|
||||
scenario "can't change distributor or order cycle once order has been finalized" do
|
||||
login_as_admin_and_visit spree.edit_admin_order_path(order)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user