Skip to content

Commit

Permalink
Merge pull request #3574 from softr8/improve/taxon-edit
Browse files Browse the repository at this point in the history
[Backend] Handle errors and flash messages editing a taxon
  • Loading branch information
aldesantis committed Apr 17, 2020
2 parents e9a5f29 + 5975bf0 commit 874d54f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/spec/requests/spree/api/taxons_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
8 changes: 7 additions & 1 deletion backend/app/controllers/spree/admin/taxons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 874d54f

Please sign in to comment.