Namespace
Methods
S
T
Instance Public methods
setup()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 6
def setup
  super
  @enabled = IdentityMap.enabled
  IdentityMap.enabled = false
end
teardown()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 12
def teardown
  super
  IdentityMap.enabled = @enabled
  IdentityMap.clear
end
test_delegates()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 18
def test_delegates
  called = false
  mw = Middleware.new lambda { |env|
    called = true
  }
  mw.call({})
  assert called, 'middleware delegated'
end
test_im_cleared_after_body_close()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 59
def test_im_cleared_after_body_close
  mw = Middleware.new lambda { |env| [200, {}, []] }
  body = mw.call({}).last

  IdentityMap.repository['hello'] = 'world'
  assert !IdentityMap.repository.empty?, 'repo should not be empty'

  body.close
  assert IdentityMap.repository.empty?, 'repo should be empty'
end
test_im_disabled_after_body_close()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 51
def test_im_disabled_after_body_close
  mw = Middleware.new lambda { |env| [200, {}, []] }
  body = mw.call({}).last
  assert IdentityMap.enabled?, 'identity map should be enabled'
  body.close
  assert !IdentityMap.enabled?, 'identity map should be disabled'
end
test_im_enabled_during_body_each()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 40
def test_im_enabled_during_body_each
  mw = Middleware.new lambda { |env|
    [200, {}, Enum.new(lambda { |&b|
      assert IdentityMap.enabled?, 'identity map should be enabled'
      b.call "hello"
    })]
  }
  body = mw.call({}).last
  body.each { |x| assert_equal 'hello', x }
end
test_im_enabled_during_delegation()
# File activerecord/test/cases/identity_map/middleware_test.rb, line 27
def test_im_enabled_during_delegation
  mw = Middleware.new lambda { |env|
    assert IdentityMap.enabled?, 'identity map should be enabled'
  }
  mw.call({})
end