diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml index 19f6b7006e..6f6b37cc26 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.haml +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -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) diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb index 36fbab0ef2..fe880ed94c 100644 --- a/spec/features/admin/order_spec.rb +++ b/spec/features/admin/order_spec.rb @@ -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)