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

validates the item purchase fields for diapers, #5076

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jahuang415
Copy link

Resolves #5059

Description

Before the change, a user could a new purchase with negative dollar values for the respective items (other, incontinence, etc.) and it would be valid so long as the total sum was correct and greater than zero.

A validation was added such that each purchase item must be greater than or equal to zero, and a respective rspec test was added to check.

Type of change

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

How Has This Been Tested?

Create a new purchase, and set the following values respectively: 1, -1, 2, 0, 0. This will submit successfully, which is incorrect.

Following the change, this will produce an error and not submit.

adult incontinence, period, other as >= 0, added
tests
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

One nitpick re the test description - otherwise this LGTM

expect(d).not_to be_valid
end

it "is valid if all categories are positive" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would say "is valid if all categories are positive and add up to the total"

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.

In new purchase, Category purchase values must be non-negative
2 participants