spec/requests/minicart_spec.rb in spree_minicart-1.1.2 vs spec/requests/minicart_spec.rb in spree_minicart-1.1.3

- old
+ new

@@ -1,9 +1,9 @@ require 'spec_helper' feature "minicart", :js => true do - background { @product = FactoryGirl.create(:product, :name => "ror mug", :price => 30) } + background { @product = FactoryGirl.create(:product, :name => "ror mug", :price => 30, :on_hand => 2) } scenario "customer should be able to add and delete a product in the minicart" do visit spree.products_path click_link("ror mug") @@ -98,6 +98,40 @@ scenario 'minicart should not create new order for every visitor', :js => false do expect { visit spree.products_path }.to_not change(Spree::Order, :count) end + + scenario 'with allowbackorders to false minicart should not be able to item multiple time' do + reset_spree_preferences do |config| + config[:allow_backorders] = false + end + @product.master.update_column :count_on_hand, 1 + + visit spree.products_path + click_link("ror mug") + + within("li#link-to-cart") do + page.should have_content("Cart: (Empty)") + end + + click_button "Add To Cart" + click_button "Add To Cart" + + within("#link-to-cart a") do + page.should have_content("(2)") + end + + within("#minicart") do + page.should have_content("ror mug") + page.should have_content('Insufficient stock available, only 1 remaining') + end + + visit spree.products_path + + within("#link-to-cart a") do + page.should have_content("(1)") + end + + end + end