From 0f3a952fd00c5cec66f59c45de783a6b9de00ccc Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 6 Dec 2023 15:07:37 +1100 Subject: [PATCH] Add translation for product cloned message A validation error shouldn't happen. If it does, it's an exception, not an error. --- app/controllers/spree/admin/products_controller.rb | 8 ++------ config/locales/en.yml | 2 ++ spec/system/admin/products_v3/products_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/spree/admin/products_controller.rb b/app/controllers/spree/admin/products_controller.rb index 5b5b5c1d9d..e153faff38 100644 --- a/app/controllers/spree/admin/products_controller.rb +++ b/app/controllers/spree/admin/products_controller.rb @@ -82,13 +82,9 @@ module Spree def clone @new = @product.duplicate + raise "Clone failed" unless @new.save - flash[:success] = if @new.save - Spree.t('notice_messages.product_cloned') - else - Spree.t('notice_messages.product_not_cloned') - end - + flash[:success] = t('.success') redirect_to spree.admin_products_url end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9db09b06a2..fc03585bc0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4348,6 +4348,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using bulk_unit_size: Bulk unit size display_as: display_as: Display As + clone: + success: Product cloned reports: table: select_and_search: "Select filters and click on %{option} to access your data." diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 71c5eea325..c34e40b934 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -237,7 +237,6 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3 expect(page).to have_css "button[aria-label='On Hand']", text: "6" end - pending expect(page).to have_content "Changes saved" end @@ -398,6 +397,8 @@ describe 'As an admin, I can see the new product page', feature: :admin_style_v3 click_link('Clone') end + expect(page).to have_content "Product cloned" + within "table.products" do # Gather input values, because page.content doesn't include them. input_content = page.find_all('input[type=text]').map(&:value).join