Skip to content
This repository was archived by the owner on Mar 2, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/mail_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ def not_found(pass = false)
end

def build_mail(name)
mail = send(name)
Mail.inform_interceptors(mail) if defined? Mail
mail = nil
ActiveRecord::Base.transaction do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know this is the only database connection that's being acted on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't, we cannot account for all side effects, unfortunately, this is just a little something that covers reasonable scenarios, including the case with factories.


mail = send(name)
Mail.inform_interceptors(mail) if defined? Mail

raise ActiveRecord::Rollback
end
mail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we're returning a record that was rolled back, now in inconsistent state. Seems fishy 😁

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which record? Still relevant after the update?

end

Expand Down