Ensure transition to payment processing state happens outside transaction#4542
Ensure transition to payment processing state happens outside transaction#4542shioyama wants to merge 4 commits intospree:masterfrom
Conversation
|
Sorry, there appear to be a bunch of other errors on master with this commit that didn't come up in #4499. Will investigate. |
This test is now failing but it is unclear if it was ever really testing what it claims to be testing. An order with no email is not valid and should not save, so the test should not pass.
|
Ok fixed, problem was with the test which was not cleaning up properly in the |
There was a problem hiding this comment.
I'm curious about the use of save_state here. Why are you calling that method which is just an alias to save?
There was a problem hiding this comment.
There was a problem hiding this comment.
Yes this is an issue with state_machine. Using save as the action name triggers methods which run the state callbacks as ActiveRecord callbacks on the model, which means that they are inside the save transaction. To get around that, you rename save to save_state and alias the method itself. It seems to no longer be mentioned in the inline comments on state machine 1.2.0 but it was there in 1.1.2.
|
Looks good 👍 thanks! I'm ok with marking that spec as pending for now. |
|
Ah forgot changelog. Will add now. |
Add failing test showing payment processing is set in a transaction. Mark test of subclassed order as pending. This test is now failing but it is unclear if it was ever really testing what it claims to be testing. An order with no email is not valid and should not save, so the test should not pass. Add changelog entry. Fixes spree#4542
The current method for preventing double payment submissions is simply not working, because the payment state is set in a transaction (see discusion in #4499). This PR turns off transactions on the order state machine and in addition aliases
save_statetosaveto make this work (see these inline notes for more details on why this is necessary).