diff --git a/app/controllers/admin/products_v3_controller.rb b/app/controllers/admin/products_v3_controller.rb index f5baaf310c4c..28f352009ff4 100644 --- a/app/controllers/admin/products_v3_controller.rb +++ b/app/controllers/admin/products_v3_controller.rb @@ -82,9 +82,9 @@ def clone @producer_options = producers @category_options = categories @tax_category_options = tax_category_options - rescue StandardError => _e + rescue ActiveRecord::ActiveRecordError => _e flash.now[:error] = t('.error') - status = :internal_server_error + status = :unprocessable_entity @product_index = "-1" # Create a unique enough index end diff --git a/spec/lib/spree/core/product_duplicator_spec.rb b/spec/lib/spree/core/product_duplicator_spec.rb index 2ea637e4acb4..141030048a85 100644 --- a/spec/lib/spree/core/product_duplicator_spec.rb +++ b/spec/lib/spree/core/product_duplicator_spec.rb @@ -106,7 +106,9 @@ } subject { Spree::Core::ProductDuplicator.new(product).duplicate } - it "returns an invalid record" + it "raises RecordInvalid error" do + expect{ subject }.to raise_error(ActiveRecord::RecordInvalid) + end end context "invalid variant" do