-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate public visibility of
order#finalize!
The only invocation of `order#finalize!` comes from the state machine transaction to `complete`: https://github.com/solidusio/solidus/blob/e18f34541bcb9b396cc026f9579d01bfae12182e/core/lib/spree/core/state_machines/order.rb#L122 Calling it standalone should not be encouraged, as all the safety checks implemented as before hooks would be skipped. Consequently, we're updating the test suite only to reference the public API. I.e, `Spree::Order#complete!`. That has forced us to refactor some tests. From `core/spec/models/spree/order/finalizing_spec.rb`: - `should set completed_at`: Before being called with `:completed_at` as an argument, `touch` is called by the state machine transition. It's easier if we just assert on the field value. - `should sell inventory units`: During the transaction, the shipment's `#object_id` gets changed, so we can't longer assert on those instances. Instead, we test the actual behavior. The assertion about `#update_state` is already covered in the following test. - `should change the shipment state to ready if order is paid`: We take the ocassion to assert on the actual behavior. - `should freeze all adjustments`: There're other methods called on the collection of adjustments that are not covered by the double. It's easier to test the actual behavior. Besides, we're moving some tests about the order completion from `order_spec.rb` to `finalizing_spec.rb`, also adapting them to test `#complete!` instead of `finalize!`. These added tests explain the removal of others which were simple duplication.
- Loading branch information
1 parent
e9ca0fb
commit 5f22628
Showing
3 changed files
with
79 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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