From 8f6f37355ca1b6b670cd74e36adedc3a357b232f Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 6 Dec 2013 14:25:19 +1100 Subject: [PATCH] Can set variant_unit_name when unit type is not items --- app/views/spree/admin/products/bulk_edit.html.haml | 2 +- spec/features/admin/bulk_product_update_spec.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/spree/admin/products/bulk_edit.html.haml b/app/views/spree/admin/products/bulk_edit.html.haml index 272a525831..6a1d7824ab 100644 --- a/app/views/spree/admin/products/bulk_edit.html.haml +++ b/app/views/spree/admin/products/bulk_edit.html.haml @@ -50,7 +50,7 @@ %input{ 'ng-model' => 'product.price', 'ofn-decimal' => :true, :name => 'price', 'ofn-track-product' => 'price', :type => 'text' } %td{ 'ng-show' => 'columns.unit.visible' } %select.select2{ 'ng-model' => 'product.variant_unit_with_scale', :name => 'variant_unit_with_scale', 'ofn-track-product' => 'variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options' } - %input{ 'ng-model' => 'product.variant_unit_name', :name => 'variant_unit_name', 'ofn-track-product' => 'variant_unit_name', 'ng-show' => "product.variant_unit_with_scale == 'items'", :type => 'text' } + %input{ 'ng-model' => 'product.variant_unit_name', :name => 'variant_unit_name', 'ofn-track-product' => 'variant_unit_name', :type => 'text' } %td{ 'ng-show' => 'columns.on_hand.visible' } %span{ 'ng-bind' => 'product.on_hand', :name => 'on_hand', 'ng-show' => 'hasVariants(product)' } %input.field{ 'ng-model' => 'product.on_hand', :name => 'on_hand', 'ofn-track-product' => 'on_hand', 'ng-show' => '!hasVariants(product)', :type => 'number' } diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index bad0bf2f0a..3766b5fd26 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -189,7 +189,7 @@ feature %q{ scenario "updating a product with no variants (except master)" do s1 = FactoryGirl.create(:supplier_enterprise) s2 = FactoryGirl.create(:supplier_enterprise) - p = FactoryGirl.create(:product, supplier: s1, available_on: Date.today, variant_unit: 'volume', variant_unit_scale: 1) + p = FactoryGirl.create(:product, supplier: s1, available_on: Date.today, variant_unit: 'volume', variant_unit_scale: 1, variant_unit_name: '(foo)') p.price = 10.0 p.on_hand = 6; p.save! @@ -203,6 +203,7 @@ feature %q{ page.should have_field "available_on", with: p.available_on.strftime("%F %T") page.should have_field "price", with: "10.0" page.should have_select "variant_unit_with_scale", selected: "Volume (L)" + page.should have_field "variant_unit_name", with: "(foo)" page.should have_field "on_hand", with: "6" fill_in "product_name", with: "Big Bag Of Potatoes" @@ -210,6 +211,7 @@ feature %q{ fill_in "available_on", with: (Date.today-3).strftime("%F %T") fill_in "price", with: "20" select "Weight (kg)", from: "variant_unit_with_scale" + fill_in "variant_unit_name", with: "(bar)" fill_in "on_hand", with: "18" click_button 'Update' @@ -222,6 +224,7 @@ feature %q{ page.should have_field "available_on", with: (Date.today-3).strftime("%F %T") page.should have_field "price", with: "20.0" page.should have_select "variant_unit_with_scale", selected: "Weight (kg)" + page.should have_field "variant_unit_name", with: "(bar)" page.should have_field "on_hand", with: "18" end