Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2262/purchase error messages #2267

Merged

Conversation

PhilipDeFraties
Copy link
Collaborator

@PhilipDeFraties PhilipDeFraties commented Apr 5, 2021

Resolves #2262

Description

Changes purchases#create error flash to provide full error messages.
To stay in line with precedent set for error handling I referred to partners#create

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Adds context block for failed purchase creation in purchase_system_spec.rb which contains added test, also moves a similiar test for failed purchase creation concerning item dropdown to within said block.
Screen Shot 2021-04-05 at 1 09 11 PM

Had to edit purchase request POST#create failure test, the previous assertion was different:
Screen Shot 2021-04-05 at 5 29 46 PM

I copied the test that was in the partners_request_spec POST#create failure test. I'm unsure if this is ok, I'm unfamiliar with the assertion that was previously there which stopped working once I changed the error message.

Screenshots

Screen Shot 2021-04-05 at 1 07 40 PM

@@ -71,7 +71,7 @@
it "renders GET#new with error" do
post purchases_path(default_params.merge(purchase: { storage_location_id: nil, amount_spent_in_cents: nil }))
expect(response).to be_successful # Will render :new
expect(response).to have_error(/error/i)
expect(response.body).to include('Failed to create purchase due to: ["Storage location must exist", "Vendor must exist", "Amount spent in cents is not a number"]')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is ok, basically copied from the POST#create failure test in partners_request_spec

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PhilipDeFraties this is okay :)!

Copy link
Collaborator

@edwinthinks edwinthinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PhilipDeFraties excellent work! Thank you for your help here!

@edwinthinks edwinthinks merged commit fb41a89 into rubyforgood:main Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add helpful error messages when purchase creation fails
2 participants