mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
12626: use rails default error messages
This commit is contained in:
@@ -8,16 +8,6 @@ module Admin
|
||||
before_action :init_filters_params
|
||||
before_action :init_pagination_params
|
||||
|
||||
VIEW_FIELD_NAME_MAPPER = {
|
||||
name: I18n.t("admin.products_page.columns.name"),
|
||||
sku: I18n.t('admin.products_page.columns.sku'),
|
||||
variant_unit: I18n.t('admin.products_page.columns.unit_scale'),
|
||||
unit_presentation: I18n.t('admin.products_page.columns.unit'),
|
||||
supplier_id: I18n.t('admin.products_page.columns.producer'),
|
||||
primary_taxon_id: I18n.t('admin.products_page.columns.category'),
|
||||
tax_category_id: I18n.t('admin.products_page.columns.tax_category')
|
||||
}.freeze
|
||||
|
||||
def index
|
||||
fetch_products
|
||||
render "index", locals: { producers:, categories:, tax_category_options:, flash: }
|
||||
@@ -223,10 +213,7 @@ module Admin
|
||||
def clone_error_message(error)
|
||||
case error
|
||||
when ActiveRecord::RecordInvalid
|
||||
field_names = error.record.errors.attribute_names
|
||||
.map{ |field_name| VIEW_FIELD_NAME_MAPPER[field_name] }.join(', ')
|
||||
|
||||
field_names.present? ? t('.invalid_fields_error', field_names:) : t('.error')
|
||||
error.record.errors.full_messages.to_sentence
|
||||
else
|
||||
t('.error')
|
||||
end
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -269,7 +269,7 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
|
||||
|
||||
click_product_clone "Apples"
|
||||
|
||||
expect(page).to have_content "Product being cloned has invalid Unit scale"
|
||||
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