FIX: Rollback when multisite tests raise exceptions

This commit is contained in:
Daniel Waterworth 2019-08-01 15:25:59 +01:00
parent b76a1df27d
commit 23dd50316c
1 changed files with 3 additions and 11 deletions

View File

@ -264,18 +264,10 @@ RSpec.configure do |config|
# force a rollback after using a multisite connection.
def test_multisite_connection(name)
RailsMultisite::ConnectionManagement.with_connection(name) do
spec_exception = nil
ActiveRecord::Base.transaction do
begin
yield
rescue Exception => spec_exception
ensure
raise ActiveRecord::Rollback
end
ActiveRecord::Base.transaction(joinable: false) do
yield
raise ActiveRecord::Rollback
end
raise spec_exception if spec_exception
end
end