From 6f228781d47552eabf2de7a1a5c020504a9d28ca Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 5 Jul 2022 16:37:14 +0200 Subject: [PATCH] Check for product_set errors + update specs: can't save variant that is not well filled. Now display errors (instead of a generic one) --- app/controllers/spree/admin/products_controller.rb | 2 +- spec/system/admin/bulk_product_update_spec.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/spree/admin/products_controller.rb b/app/controllers/spree/admin/products_controller.rb index 17d4487560..cce9b363c8 100644 --- a/app/controllers/spree/admin/products_controller.rb +++ b/app/controllers/spree/admin/products_controller.rb @@ -76,7 +76,7 @@ module Spree product_set.collection.each { |p| authorize! :update, p } - if product_set.save + if product_set.save && product_set.errors.empty? redirect_to main_app.bulk_products_api_v0_products_path(bulk_index_query) elsif product_set.errors.present? render json: { errors: product_set.errors }, status: :bad_request diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 5d49e19b3a..4d65ac78a7 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -303,7 +303,6 @@ describe ' end it "creating a variant with unit value is: '120g' and 'on_hand' filled" do - pending "#9068" within "tr#v_#{Spree::Variant.second.id}" do page.find(".add-variant").click end @@ -315,11 +314,10 @@ describe ' end click_button 'Save Changes', match: :first - expect(page.find("#status-message")).to have_content "Changes saved." + expect(page.find("#status-message")).to have_content "Unit value can't be blank Unit value is not a number" end it "creating a variant with unit value is: '120g' and 'on_demand' checked" do - pending "#9068" within "tr#v_#{Spree::Variant.second.id}" do page.find(".add-variant").click end @@ -331,7 +329,7 @@ describe ' end click_button 'Save Changes', match: :first - expect(page.find("#status-message")).to have_content "Changes saved." + expect(page.find("#status-message")).to have_content "Unit value can't be blank Unit value is not a number" end end end