Check for product_set errors

+ update specs: can't save variant that is not well filled. Now display errors (instead of a generic one)
This commit is contained in:
Jean-Baptiste Bellet
2022-07-05 16:37:14 +02:00
parent c39b00b6c2
commit 6f228781d4
2 changed files with 3 additions and 5 deletions

View File

@@ -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

View File

@@ -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