mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user