diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 2bae14214c..ab2b5e5a7c 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -10,20 +10,23 @@ feature "full-page cart", js: true do let!(:zone) { create(:zone_with_member) } let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true, charges_sales_tax: true) } let(:supplier) { create(:supplier_enterprise) } - let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.variants.first]) } - let(:enterprise_fee) { create(:enterprise_fee, amount: 11.00, tax_category: product.tax_category) } - let(:product) { create(:taxed_product, supplier: supplier, zone: zone, price: 110.00, tax_rate_amount: 0.1) } - let(:variant) { product.variants.first } + let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product_tax.variants.first, product_fee.variants.first]) } + let(:enterprise_fee) { create(:enterprise_fee, amount: 11.00, tax_category: product_tax.tax_category) } + let(:product_tax) { create(:taxed_product, supplier: supplier, zone: zone, price: 110.00, tax_rate_amount: 0.1) } + let(:product_fee) { create(:simple_product, supplier: supplier, price: 0.86) } let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) } before do add_enterprise_fee enterprise_fee set_order order - add_product_to_cart order, product - visit spree.cart_path end describe "tax" do + before do + add_product_to_cart order, product_tax + visit spree.cart_path + end + it "shows the total tax for the order, including product tax and tax on fees" do page.should have_selector '.tax-total', text: '11.00' # 10 + 1 end @@ -31,12 +34,15 @@ feature "full-page cart", js: true do describe "updating quantities with insufficient stock available" do let(:li) { order.line_items(true).last } + let(:variant) { product_tax.variants.first } before do - variant.update_attributes! on_hand: 2 + add_product_to_cart order, product_tax end it "prevents me from entering an invalid value" do + # Given we have 2 on hand, and we've loaded the page after that fact + variant.update_attributes! on_hand: 2 visit spree.cart_path accept_alert 'Insufficient stock available, only 2 remaining' do @@ -47,6 +53,10 @@ feature "full-page cart", js: true do end it "shows the quantities saved, not those submitted" do + # Given we load the page with 3 on hand, then the number available drops to 2 + visit spree.cart_path + variant.update_attributes! on_hand: 2 + fill_in "order_line_items_attributes_0_quantity", with: '4' click_button 'Update'