mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #12857 from chahmedejaz/task/12626-add-clone-failure-explaination
[BUU] Fix No explanation why cloning failed
This commit is contained in:
@@ -88,8 +88,8 @@ module Admin
|
||||
@producer_options = producers
|
||||
@category_options = categories
|
||||
@tax_category_options = tax_category_options
|
||||
rescue ActiveRecord::ActiveRecordError => _e
|
||||
flash.now[:error] = t('.error')
|
||||
rescue ActiveRecord::ActiveRecordError => e
|
||||
flash.now[:error] = clone_error_message(e)
|
||||
status = :unprocessable_entity
|
||||
@product_index = "-1" # Create a unique enough index
|
||||
end
|
||||
@@ -213,6 +213,15 @@ module Admin
|
||||
params.permit(products: ::PermittedAttributes::Product.attributes)
|
||||
.to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
def clone_error_message(error)
|
||||
case error
|
||||
when ActiveRecord::RecordInvalid
|
||||
error.record.errors.full_messages.to_sentence
|
||||
else
|
||||
t('.error')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/ClassLength
|
||||
|
||||
@@ -70,7 +70,7 @@ en:
|
||||
price: "Price"
|
||||
primary_taxon_id: "Product Category"
|
||||
shipping_category_id: "Shipping Category"
|
||||
variant_unit: "Variant Unit"
|
||||
variant_unit: "Unit Scale"
|
||||
variant_unit_name: "Variant Unit Name"
|
||||
unit_value: "Unit value"
|
||||
spree/variant:
|
||||
|
||||
@@ -303,7 +303,7 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
|
||||
|
||||
click_product_clone "Apples"
|
||||
|
||||
expect(page).to have_content "Unable to clone the product"
|
||||
expect(page).to have_content "Unit Scale can't be blank"
|
||||
|
||||
within "table.products" do
|
||||
# Products does not include the cloned product.
|
||||
|
||||
Reference in New Issue
Block a user