Namespace
Methods
C
S
T
Instance Public methods
call(env)
# File activerecord/test/cases/connection_management_test.rb, line 85
def call(env); raise NotImplementedError; end
setup()
# File activerecord/test/cases/connection_management_test.rb, line 19
def setup
  @env = {}
  @app = App.new
  @management = ConnectionManagement.new(@app)

  # make sure we have an active connection
  assert ActiveRecord::Base.connection
  assert ActiveRecord::Base.connection_handler.active_connections?
end
test_active_connections_are_not_cleared_on_body_close_during_test()
# File activerecord/test/cases/connection_management_test.rb, line 77
def test_active_connections_are_not_cleared_on_body_close_during_test
  @env['rack.test'] = true
  _, _, body = @management.call(@env)
  body.close
  assert ActiveRecord::Base.connection_handler.active_connections?
end
test_app_delegation()
# File activerecord/test/cases/connection_management_test.rb, line 52
def test_app_delegation
  manager = ConnectionManagement.new(@app)

  manager.call @env
  assert_equal [@env], @app.calls
end
test_body_responds_to_each()
# File activerecord/test/cases/connection_management_test.rb, line 64
def test_body_responds_to_each
  _, _, body = @management.call(@env)
  bits = []
  body.each { |bit| bits << bit }
  assert_equal ['hi mom'], bits
end
test_connection_pool_per_pid()
# File activerecord/test/cases/connection_management_test.rb, line 30
def test_connection_pool_per_pid
  object_id = ActiveRecord::Base.connection.object_id

  rd, wr = IO.pipe
  rd.binmode
  wr.binmode

  pid = fork {
    rd.close
    wr.write Marshal.dump ActiveRecord::Base.connection.object_id
    wr.close
    exit!
  }

  wr.close

  Process.waitpid pid
  assert_not_equal object_id, Marshal.load(rd.read)
  rd.close
end
test_connections_are_active_after_call()
# File activerecord/test/cases/connection_management_test.rb, line 59
def test_connections_are_active_after_call
  @management.call(@env)
  assert ActiveRecord::Base.connection_handler.active_connections?
end
test_connections_are_cleared_after_body_close()
# File activerecord/test/cases/connection_management_test.rb, line 71
def test_connections_are_cleared_after_body_close
  _, _, body = @management.call(@env)
  body.close
  assert !ActiveRecord::Base.connection_handler.active_connections?
end
test_connections_closed_if_exception()
# File activerecord/test/cases/connection_management_test.rb, line 84
def test_connections_closed_if_exception
  app       = Class.new(App) { def call(env); raise NotImplementedError; end }.new
  explosive = ConnectionManagement.new(app)
  assert_raises(NotImplementedError) { explosive.call(@env) }
  assert !ActiveRecord::Base.connection_handler.active_connections?
end
test_connections_closed_if_exception_and_explicitly_not_test()
# File activerecord/test/cases/connection_management_test.rb, line 99
def test_connections_closed_if_exception_and_explicitly_not_test
  @env['rack.test'] = false
  app       = Class.new(App) { def call(env); raise NotImplementedError; end }.new
  explosive = ConnectionManagement.new(app)
  assert_raises(NotImplementedError) { explosive.call(@env) }
  assert !ActiveRecord::Base.connection_handler.active_connections?
end
test_connections_not_closed_if_exception_and_test()
# File activerecord/test/cases/connection_management_test.rb, line 91
def test_connections_not_closed_if_exception_and_test
  @env['rack.test'] = true
  app               = Class.new(App) { def call(env); raise; end }.new
  explosive         = ConnectionManagement.new(app)
  assert_raises(RuntimeError) { explosive.call(@env) }
  assert ActiveRecord::Base.connection_handler.active_connections?
end
to_path()
# File activerecord/test/cases/connection_management_test.rb, line 114
def to_path; "/path"; end