Created
June 28, 2013 16:08
-
-
Save victorhazbunanuff/5885872 to your computer and use it in GitHub Desktop.
refactor
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
def delayed_deletion | |
begin | |
Account.transaction do | |
update_column(:deleted_at, Date.current) | |
destroy_subscription | |
end | |
rescue Exception; end; | |
AccountAlertMailer.deletion_notification(admin).deliver | |
end |
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
context "transaction" do | |
it "should rollback if exception found in update_column" do | |
@account.stubs(:update_column).raises(Exception) | |
@account.delayed_deletion | |
@account.deleted_at.should be_nil | |
end | |
it "should rollback if exception found in destroy_subscription" do | |
@account.stubs(:destroy_subscription).raises(Exception) | |
@account.delayed_deletion | |
@account.reload.deleted_at.should be_nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment