From b89c84e8bdaeada9c9626708927c1e55eb41a67f Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 5 Mar 2014 15:08:54 +1100 Subject: [PATCH] BPE: Do not show product price when product has variants --- app/views/spree/admin/products/bulk_edit.html.haml | 2 +- spec/features/admin/bulk_product_update_spec.rb | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/views/spree/admin/products/bulk_edit.html.haml b/app/views/spree/admin/products/bulk_edit.html.haml index 28cefe564f..faac29fa79 100644 --- a/app/views/spree/admin/products/bulk_edit.html.haml +++ b/app/views/spree/admin/products/bulk_edit.html.haml @@ -122,7 +122,7 @@ %input{ 'ng-model' => 'product.master.unit_value_with_description', :name => 'master_unit_value_with_description', 'ofn-track-product' => 'master.unit_value_with_description', :type => 'text', :placeholder => 'value', 'ng-show' => "!hasVariants(product) && hasUnit(product)" } %input{ 'ng-model' => 'product.variant_unit_name', :name => 'variant_unit_name', 'ofn-track-product' => 'variant_unit_name', :placeholder => 'unit', 'ng-show' => "product.variant_unit_with_scale == 'items'", :type => 'text' } %td{ 'ng-show' => 'columns.price.visible' } - %input{ 'ng-model' => 'product.price', 'ofn-decimal' => :true, :name => 'price', 'ofn-track-product' => 'price', :type => 'text' } + %input{ 'ng-model' => 'product.price', 'ofn-decimal' => :true, :name => 'price', 'ofn-track-product' => 'price', :type => 'text', 'ng-hide' => 'hasVariants(product)' } %td{ 'ng-show' => 'columns.on_hand.visible' } %span{ 'ng-bind' => 'product.on_hand', :name => 'on_hand', 'ng-show' => '!hasOnDemandVariants(product) && (hasVariants(product) || product.on_demand)' } %input.field{ 'ng-model' => 'product.on_hand', :name => 'on_hand', 'ofn-track-product' => 'on_hand', 'ng-hide' => 'hasVariants(product) || product.on_demand', :type => 'number' } diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 4644aae8c1..336792a3ae 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -85,18 +85,21 @@ feature %q{ page.should have_field "available_on", with: p2.available_on.strftime("%F %T") end - it "displays a price input for each product (ie. for master variant)" do + it "displays a price input for each product without variants (ie. for master variant)" do p1 = FactoryGirl.create(:product) p2 = FactoryGirl.create(:product) - p1.price = 22.00 - p2.price = 44.00 - p1.save! - p2.save! + p3 = FactoryGirl.create(:product) + v = FactoryGirl.create(:variant, product: p3) + + p1.update_attribute :price, 22.0 + p2.update_attribute :price, 44.0 + p3.update_attribute :price, 66.0 visit '/admin/products/bulk_edit' page.should have_field "price", with: "22.0" page.should have_field "price", with: "44.0" + page.should_not have_field "price", with: "66.0", visible: true end it "displays an on hand count input for each product (ie. for master variant) if no regular variants exist" do