FIX: Rollback when multisite tests raise exceptions

FIX: Rollback when multisite tests raise exceptions

diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index c5dcc9b..339f117 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -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

GitHub sha: 23dd5031

Since writing the commit message, I realized I misread ensure for else. The new version is much simpler though.

1 Like