Sha256: 7ffbe532e161d52d6ade3dedb0a4db7fedd5d22280fa6d488033ba9bba239b52

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

if Mack.env == "test"
  module Mack
    module Testing # :nodoc: 
    end
  end

  # Wrap it so we don't accidentally alias the run method n times and run out of db connections!
  unless Mack::Testing.const_defined?("AR_TEST_EXTENSIONS")
    
    module Mack
      module Testing
        AR_TEST_EXTENSIONS = 1
        
        def rollback_transaction
          begin
            ActiveRecord::Base.transaction do
              yield if block_given?
              raise "Rollback!"
            end
          rescue => ex
            # we need to do this so we can throw up actual errors!
            unless ex.to_s == "Rollback!"
              raise ex
            end
          end
        end # rollback_transaction

      end # Testing
    end # Mack
  
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mack-active_record-0.8.3 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.3.1 lib/mack-active_record/test_extensions.rb