Fix RedundantPresenceValidationOnBelongs on Spree::Order model #12548
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.
What? Why?
This is the last file to be checked.
What should we test?
Run the tests. They should all passes
What did I do what I have done ?
No migration, no checks here, contrary to the last PRs.
My goal was to ensure some of the presence of foreign ids was done, even though they appeared optional.
But, by doing tests, it appears they should be called optional.
This is what I found:
order_cycle_id
,distributor_id
&customer_id mandatory
, I can not even pass the first page, because:File:
File: lib/spree/core/controller_helpers/order.rb
Line:
Regarding
created_by
&user_id
:spec/models/spree/order_spec.rb
)app/controllers/spree/admin/orders/customer_details_controller.rb
)app/services/orders/cart_reset_service.rb
The associate_user tells me that creating an order before assigning it to a user is commonplace. Same with created_by.
There are other occurrences of this in the code.
To me, the app needs these fields to be not null.
It might be a bit unusual, these fields that should be required as they are foreign keys, but that describes how the app works.
But, we can also leave the file as it is and add a line in the .rubocop_to_do not to touche it :)
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates