From 24cd5209d68ad5c304b63bf185a9f6b7c8b34107 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Mon, 19 Aug 2013 10:41:01 +1000 Subject: [PATCH] Do not error when attempting to mix product and order cycle distribution --- ..._to_cart_order_cycle_unavailable.html.haml | 2 +- spec/features/consumer/checkout_spec.rb | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/views/spree/products/_add_to_cart_order_cycle_unavailable.html.haml b/app/views/spree/products/_add_to_cart_order_cycle_unavailable.html.haml index ba3a99dbbb..d061f0595c 100644 --- a/app/views/spree/products/_add_to_cart_order_cycle_unavailable.html.haml +++ b/app/views/spree/products/_add_to_cart_order_cycle_unavailable.html.haml @@ -1,4 +1,4 @@ .error-distributor Please complete your order from - = link_to current_order_cycle.name, root_path + = link_to (current_order_cycle.andand.name || 'your current order cycle'), root_path before shopping in a different order cycle. diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index 58be496f59..8717e6062a 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -109,8 +109,6 @@ feature %q{ table = page.find 'tbody#cart_adjustments' rows = table.all 'tr' - binding.pry - rows.map { |row| row.all('td').map { |cell| cell.text.strip } }.should == [["Bananas - packing fee by supplier Supplier 1", "$3.00", ""], ["Bananas - transport fee by supplier Supplier 1", "$4.00", ""], @@ -128,7 +126,29 @@ feature %q{ page.should have_selector 'span.distribution-total', :text => '$54.00' end - #scenario "viewing delivery fees for mixed product and order cycle distribution" + scenario "attempting to purchase products that mix product and order cycle distribution" do + # Given some products, one with product distribution only, (@product1) + # one with order cycle distribution only, (@product_oc) + supplier = create(:supplier_enterprise) + product_oc = create(:simple_product, name: 'Feijoas') + @order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [@distributor], variants: [product_oc.master]) + @order_cycle.coordinator_fees << create(:enterprise_fee, enterprise: @order_cycle.coordinator) + + # And I am logged in + login_to_consumer_section + + # When I add the first to my cart + click_link 'Fuji apples' + select @distributor.name, :from => 'distributor_id' + click_button 'Add To Cart' + click_link 'Continue shopping' + + # And I attempt to add another + click_link 'Feijoas' + + # Then I should see an error about changing order cycle + page.should have_content 'Please complete your order from your current order cycle before shopping in a different order cycle.' + end scenario "changing distributor updates delivery fees" do # Given two distributors and enterprise fees