-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix transaction extensions to handle failures correctly
The `intercepting_failure` method was not handling the block's output correctly when it was a failure. It wasn't throwing `:halt` with the failure as the given handlers were raising and therefore the throwing part was never reached. We modify the method to pass the failure to the handler and skip the throwing part, while extensions need to work in two phases: 1 - From within the transaction block, they intercept a failure a first time and assign it to a `result` variable available from the outer scope. After that, they raise to rollback the transaction but return the `result` variable after that. 2 - From outside the transaction block, they throw again the failure when the `result` is actually a failure. We also make public the `throw_failure` method so that other extensions can create similar behavior. We also add a warning in the ActiveRecord extension to make it clear that the `:requires_new` option is not yet supported for this approach. We should find a way to make it work in the future. Closes #23
- Loading branch information
1 parent
c7d757b
commit 9919891
Showing
7 changed files
with
132 additions
and
33 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
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
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