Notify when stock limit reached on cart rather than silently capping

This commit is contained in:
Rohan Mitchell
2016-04-27 15:10:54 +10:00
parent 1220ff8a06
commit 1384140e41
2 changed files with 11 additions and 3 deletions

View File

@@ -30,7 +30,7 @@
-# "price-breakdown-placement" => "left",
-# "price-breakdown-animation" => true}
%td.text-center.cart-item-quantity{"data-hook" => "cart_item_quantity"}
= item_form.number_field :quantity, :min => 0, :max => variant.on_hand, :class => "line_item_quantity", :size => 5
= item_form.number_field :quantity, :min => 0, "ofn-on-hand" => variant.on_hand, :class => "line_item_quantity", :size => 5
%td.cart-item-total.text-right{"data-hook" => "cart_item_total"}
= line_item.display_amount_with_adjustments.to_html unless line_item.quantity.nil?

View File

@@ -32,12 +32,20 @@ feature "full-page cart", js: true do
describe "updating quantities with insufficient stock available" do
let(:li) { order.line_items(true).last }
use_short_wait 10
before do
variant.update_attributes! on_hand: 2
end
it "prevents me from entering an invalid value" do
visit spree.cart_path
accept_alert 'Insufficient stock available, only 2 remaining' do
fill_in "order_line_items_attributes_0_quantity", with: '4'
end
page.should have_field "order_line_items_attributes_0_quantity", with: '2'
end
it "shows the quantities saved, not those submitted" do
fill_in "order_line_items_attributes_0_quantity", with: '4'