From 1f9698f7a252518d625fbad5d3a1f3cfc2d2660b Mon Sep 17 00:00:00 2001 From: stveep Date: Mon, 13 Feb 2017 23:14:04 +0000 Subject: [PATCH] Test to reproduce bug with overridden price not being displayed when an order is added manually --- spec/factories.rb | 8 +++++++ spec/features/admin/variant_overrides_spec.rb | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index 5b4df5cf38..cc582f7f69 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -71,6 +71,14 @@ FactoryGirl.define do end end + factory :order_cycle_with_overrides, parent: :order_cycle do + after (:create) do |oc| + oc.variants.each do |variant| + create(:variant_override, variant: variant, hub: oc.coordinator, price: variant.price + 100) + end + end + end + factory :simple_order_cycle, :class => OrderCycle do sequence(:name) { |n| "Order Cycle #{n}" } diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index d21c0998e5..3bb6789211 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -315,6 +315,29 @@ feature %q{ end end end + + end + + describe "when manually placing an order" do + let!(:order_cycle) { create(:order_cycle_with_overrides, name: "Overidden") } + + before do + dist = order_cycle.distributors.first + login_to_admin_section + visit 'admin/orders/new' + select2_select dist.name, from: 'order_distributor_id' + page.should have_select2 'order_order_cycle_id', with_options: ['Overidden (open)'] + select2_select order_cycle.name, from: 'order_order_cycle_id' + end + + # Reproducing a bug, issue #1446 + it "shows the overridden price" do + product = order_cycle.products.first + targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop' + click_link 'Add' + page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS + page.should have_content product.variants.first.variant_overrides.first.price + end end describe "when inventory_items do not exist for variants" do