diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3efe519c024..7849cc59c379 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -12,22 +12,6 @@ Layout/EmptyLines: Exclude: - 'app/services/products_renderer.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'app/services/products_renderer.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'app/services/products_renderer.rb' - # Offense count: 16 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: @@ -408,7 +392,6 @@ RSpecRails/HaveHttpStatus: - 'spec/controllers/stripe/webhooks_controller_spec.rb' - 'spec/controllers/user_passwords_controller_spec.rb' - 'spec/controllers/user_registrations_controller_spec.rb' - - 'spec/requests/admin/images_spec.rb' - 'spec/requests/api/routes_spec.rb' - 'spec/requests/checkout/stripe_sca_spec.rb' - 'spec/requests/home_controller_spec.rb' @@ -725,7 +708,7 @@ Style/ClassAndModuleChildren: - 'lib/open_food_network/locking.rb' - 'spec/models/spree/payment_method_spec.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -872,7 +855,7 @@ Style/ReturnNilInPredicateMethodDefinition: - 'app/serializers/api/admin/customer_serializer.rb' - 'engines/order_management/app/services/order_management/subscriptions/validator.rb' -# Offense count: 207 +# Offense count: 204 Style/Send: Exclude: - 'spec/controllers/admin/subscriptions_controller_spec.rb' diff --git a/app/controllers/spree/admin/products_controller.rb b/app/controllers/spree/admin/products_controller.rb index 2755f1b36d97..3ae92a38bd1b 100644 --- a/app/controllers/spree/admin/products_controller.rb +++ b/app/controllers/spree/admin/products_controller.rb @@ -46,7 +46,7 @@ def create # Re-fill the form with deleted params on product @on_hand = request.params[:product][:on_hand] @on_demand = request.params[:product][:on_demand] - render :new, status: :unprocessable_entity + render :new end end end diff --git a/spec/controllers/spree/admin/products_controller_spec.rb b/spec/controllers/spree/admin/products_controller_spec.rb index 6752239a8c86..f7f81f2cdc0a 100644 --- a/spec/controllers/spree/admin/products_controller_spec.rb +++ b/spec/controllers/spree/admin/products_controller_spec.rb @@ -168,17 +168,18 @@ spree_put :create, product: product_attrs_with_image - expect(response.status).to eq 422 + expect(response.status).to eq 200 end end describe "when variant attributes are missing" do - it 'renders 422 error' do + it 'renders form with errors' do spree_post :create, product: product_attrs.merge!( { supplier_id: nil, primary_taxon_id: nil } ), button: 'create' - expect(response.status).to eq 422 + expect(response.status).to eq 200 + expect(response).to render_template('spree/admin/products/new') end end end diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index bd19bdcbfdcd..9fad202f7932 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -187,6 +187,23 @@ expect(page).to have_content "Product Category must exist" end + it "creating product with empty product supplier fails" do + fill_in 'product_name', with: 'Hot Cakes' + select "Weight (kg)", from: 'product_variant_unit_with_scale' + fill_in "product_unit_value", with: '1' + fill_in 'product_price', with: '1.99' + select taxon.name, from: "product_primary_taxon_id" + fill_in 'product_on_hand', with: 0 + check 'product_on_demand' + select 'Test Tax Category', from: 'product_tax_category_id' + fill_in_trix_editor 'product_description', + with: 'In demand, and on_demand! The hottest cakes in town.' + click_button 'Create' + + expect(current_path).to eq spree.admin_products_path + expect(page).to have_content "Supplier must exist" + end + describe "localization settings" do shared_examples "with different price values" do |localized_number, price| context "when enable_localized_number is set to #{localized_number}" do