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

OBPIH-3759 Make order adjustment description required #2336

Merged
merged 1 commit into from
Apr 15, 2021
Merged

Conversation

awalkowiak
Copy link
Collaborator

No description provided.

@@ -286,7 +286,7 @@ class OrderController {
orderAdjustment.orderItem.removeFromOrderAdjustments(orderAdjustment)
}
orderAdjustment.properties = params
if (!orderAdjustment.hasErrors() && orderAdjustment.save(flush: true)) {
if (orderAdjustment.validate() && !orderAdjustment.hasErrors() && orderAdjustment.save(flush: true)) {
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need validate and hasErrors. You can remove the && !orderAdjustment.hasErrors() as validate and save should return false if there are validation errors. In fact you can probably remove all of this except orderAdjustment.save() as that should be enough to trigger the error handling.

Copy link
Member

Choose a reason for hiding this comment

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

@awalkowiak This is actually probably a case where the change doesn't justify holding up testing since the additional code is basically a no-op. But this should definitely be addressed in our coding conventions. In this case, we'd want to move persistence logic to a service and find a consistent pattern for validation and saving domain objects.

The binding in line 288 should cause a validate() to occur, so if that's not happening then something weird is happening here. I'm ok if you merge this but can you investigate this further and let me know why the validate was necessary?

@awalkowiak awalkowiak merged commit 0e57bb9 into develop Apr 15, 2021
@awalkowiak awalkowiak deleted the OBPIH-3759 branch April 15, 2021 07:23
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.

None yet

2 participants