Closed hoshinotsuyoshi closed 3 years ago
Build failing is due to other flaky test.
I made just another PR to fix that.
https://github.com/spree-contrib/spree_multi_vendor/pull/173
I hope you can see it. @damianlegawiec
Thank you!
Thank you @hoshinotsuyoshi 🙏
Make order-complete hook methods(generate_order_commissions
andsend_notification_mails_to_vendors
) be called inSpree::Order#finalize!
instead of usingafter_transition
. fixes https://github.com/spree-contrib/spree_multi_vendor/issues/162 and https://github.com/spree-contrib/spree_multi_vendor/issues/160So far, even if you don't have problems in production env, but in development env(usually
config.cache_class = false
), you will run into problems such as https://github.com/spree-contrib/spree_multi_vendor/issues/162 or https://github.com/spree-contrib/spree_multi_vendor/issues/160 .It is hard (or difiicult) to avoid re-registering after_transition.
For example, some workaround such as https://github.com/spree-contrib/spree_multi_vendor/issues/162#issuecomment-774948105 will be needed.
This patch approach is focusing on that the
finalize!
method is already set withafter_transition to: :complete
by spree/spree's core.Calling spree-multi-vendor's hook methods in
finalize
(a stable method, I think) will be a simple solution.Fixes #160 and #162 .
PR description
1.
1st commit
47cedb5eeaf08addc17897f0952d7554dbae48e8https://github.com/spree-contrib/spree_multi_vendor/pull/172/commits/e1879a22c74fed8d079eb08d156cb532b91f7206 simply adds a spec(regression test). This spec is related to https://github.com/spree-contrib/spree_multi_vendor/issues/162 . And this spec will be passed.2.
In spec/dummy/config/environments/test.rb, if you set
config.cache_classes = false
, the spec will be failed.And a spec https://github.com/spree-contrib/spree_multi_vendor/blob/bf37f0624cc1a5f7a3b7431136cd8416a54fed60/spec/models/spree/order_spec.rb#L24-L36 will be failed, too. (This spec is related to https://github.com/spree-contrib/spree_multi_vendor/issues/160 .)
4.
the 2nd commit
https://github.com/spree-contrib/spree_multi_vendor/pull/172/commits/ab0dc2503a9d90b38a03ad5e85a1fb594e5029cchttps://github.com/spree-contrib/spree_multi_vendor/pull/172/commits/a5333cfa0ac21010f1693f121a009c10f5d360bd will solve both.