diff --git a/api/spec/requests/spree/api/taxons_controller_spec.rb b/api/spec/requests/spree/api/taxons_controller_spec.rb index 78025312f3e..55ad7859a29 100644 --- a/api/spec/requests/spree/api/taxons_controller_spec.rb +++ b/api/spec/requests/spree/api/taxons_controller_spec.rb @@ -189,7 +189,7 @@ module Spree end it "cannot create a new taxon with invalid attributes" do - post spree.api_taxonomy_taxons_path(taxonomy), params: { taxon: { foo: :bar } } + post spree.api_taxonomy_taxons_path(taxonomy), params: { taxon: { name: '' } } expect(response.status).to eq(422) expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.") diff --git a/backend/app/controllers/spree/admin/taxons_controller.rb b/backend/app/controllers/spree/admin/taxons_controller.rb index 3831269f60c..51005b3604e 100644 --- a/backend/app/controllers/spree/admin/taxons_controller.rb +++ b/backend/app/controllers/spree/admin/taxons_controller.rb @@ -62,7 +62,13 @@ def update end respond_with(@taxon) do |format| - format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) } + format.html do + if @taxon.valid? + redirect_to edit_admin_taxonomy_url(@taxonomy) + else + render :edit + end + end end end