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

Add validation for money_raised in Donation model to ensure it is non… #5092

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

Conversation

mateusmsf94
Copy link

Resolves #5065

Description

This pull request addresses issue #5065 by adding validation to ensure that the money_raised attribute in the Donation model cannot be negative. This change was motivated by the need to prevent invalid data entry that could lead to incorrect financial reporting. The solution involves adding a numericality validation to the money_raised attribute and updating the request specs to test for this validation.

Type of change

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

How Has This Been Tested?

The changes have been tested by adding new unit tests in spec/models/donation_spec.rb to verify that the money_raised attribute cannot be negative. Additionally, request specs in spec/requests/donations_requests_spec.rb have been updated to ensure that the correct validation error messages are flashed when attempting to create or update a donation with a negative money_raised value. These tests can be run using bundle exec rake, or bundle exec rspec spec/requests/donations_requests_spec.rb and bundle exec rspec spec/models/donation_spec.rb to verify that all validations and error messages are functioning as expected.

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.

On new/edit donation, Money raised in dollars must be non-negative.
1 participant