Conversation
Enhance the Payment model by adding a presence validation for account_type when the transaction_type is 'ManuallyEntered'. Introduce a manual_entry? method to support this validation. Update the corresponding RSpec tests to ensure proper validation behavior for manual entries.
…for missing account_type scenario
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens Payment model validation so account_type is required for manually entered payments (transaction_type == "ManuallyEntered"), aligns the ActiveAdmin manual-payment form with that requirement, and adds specs to cover the updated behavior.
Changes:
- Added conditional
account_typepresence validation for manual payments and introduced amanual_entry?predicate. - Updated ActiveAdmin
Paymentform to markaccount_typeas required for manual entry. - Added/expanded specs to verify manual-payment validation and ensure gateway-created payments still work without
account_type.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spec/models/payment_spec.rb | Adds validation specs for manual payments requiring account_type. |
| spec/controllers/payments_controller_spec.rb | Adds a controller spec ensuring gateway payments can be created without account_type. |
| app/models/payment.rb | Introduces manual_entry? and uses it to conditionally require account_type. |
| app/admin/payments.rb | Marks account_type as required in the ActiveAdmin manual-payment form. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ry? method Update the manual_payment_decimal and check_manual_amount methods to utilize the new manual_entry? method for improved readability. Add a new test case to validate behavior when transaction_type is not 'ManuallyEntered'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request strengthens validation for the
account_typefield in thePaymentmodel, ensuring that it is required for manually entered payments. It also updates the admin interface and adds comprehensive tests to cover these scenarios.Validation improvements for manual payments:
account_typewhentransaction_typeis"ManuallyEntered"in thePaymentmodel.manual_entry?helper method to encapsulate the logic for identifying manual entries.Admin interface update:
account_typefield in the ActiveAdminpaymentsform to be marked as required.Test coverage enhancements:
account_typeis required for manual payments and optional otherwise.account_typeis missing, as long as the payment is not manually entered.