Methods
S
T
Instance Public methods
setup()
# File actionpack/test/controller/caching_test.rb, line 689
def setup
  super
  @store = ActiveSupport::Cache::MemoryStore.new
  @controller = FragmentCachingTestController.new
  @controller.perform_caching = true
  @controller.cache_store = @store
  @params = {:controller => 'posts', :action => 'index'}
  @request = ActionController::TestRequest.new
  @response = ActionController::TestResponse.new
  @controller.params = @params
  @controller.request = @request
  @controller.response = @response
end
test_expire_fragment_with_regexp()
# File actionpack/test/controller/caching_test.rb, line 752
def test_expire_fragment_with_regexp
  @store.write('views/name', 'value')
  @store.write('views/another_name', 'another_value')
  @store.write('views/primalgrasp', 'will not expire ;-)')

  @controller.expire_fragment(/name/)

  assert_nil @store.read('views/name')
  assert_nil @store.read('views/another_name')
  assert_equal 'will not expire ;-)', @store.read('views/primalgrasp')
end
test_expire_fragment_with_simple_key()
# File actionpack/test/controller/caching_test.rb, line 746
def test_expire_fragment_with_simple_key
  @store.write('views/name', 'value')
  @controller.expire_fragment 'name'
  assert_nil @store.read('views/name')
end
test_fragment_cache_key()
# File actionpack/test/controller/caching_test.rb, line 703
def test_fragment_cache_key
  assert_equal 'views/what a key', @controller.fragment_cache_key('what a key')
  assert_equal "views/test.host/fragment_caching_test/some_action",
                @controller.fragment_cache_key(:controller => 'fragment_caching_test',:action => 'some_action')
end
test_fragment_exist_with_caching_disabled()
# File actionpack/test/controller/caching_test.rb, line 726
def test_fragment_exist_with_caching_disabled
  @controller.perform_caching = false
  @store.write('views/name', 'value')
  assert !@controller.fragment_exist?('name')
  assert !@controller.fragment_exist?('other_name')
end
test_fragment_exist_with_caching_enabled()
# File actionpack/test/controller/caching_test.rb, line 720
def test_fragment_exist_with_caching_enabled
  @store.write('views/name', 'value')
  assert @controller.fragment_exist?('name')
  assert !@controller.fragment_exist?('other_name')
end
test_fragment_for()
# File actionpack/test/controller/caching_test.rb, line 764
def test_fragment_for
  @store.write('views/expensive', 'fragment content')
  fragment_computed = false

  view_context = @controller.view_context

  buffer = 'generated till now -> '.html_safe
  buffer << view_context.send(:fragment_for, 'expensive') { fragment_computed = true }

  assert !fragment_computed
  assert_equal 'generated till now -> fragment content', buffer
end
test_html_safety()
# File actionpack/test/controller/caching_test.rb, line 777
def test_html_safety
  assert_nil @store.read('views/name')
  content = 'value'.html_safe
  assert_equal content, @controller.write_fragment('name', content)

  cached = @store.read('views/name')
  assert_equal content, cached
  assert_equal String, cached.class

  html_safe = @controller.read_fragment('name')
  assert_equal content, html_safe
  assert html_safe.html_safe?
end
test_read_fragment_with_caching_disabled()
# File actionpack/test/controller/caching_test.rb, line 714
def test_read_fragment_with_caching_disabled
  @controller.perform_caching = false
  @store.write('views/name', 'value')
  assert_nil @controller.read_fragment('name')
end
test_read_fragment_with_caching_enabled()
# File actionpack/test/controller/caching_test.rb, line 709
def test_read_fragment_with_caching_enabled
  @store.write('views/name', 'value')
  assert_equal 'value', @controller.read_fragment('name')
end
test_write_fragment_with_caching_disabled()
# File actionpack/test/controller/caching_test.rb, line 739
def test_write_fragment_with_caching_disabled
  assert_nil @store.read('views/name')
  @controller.perform_caching = false
  assert_equal 'value', @controller.write_fragment('name', 'value')
  assert_nil @store.read('views/name')
end
test_write_fragment_with_caching_enabled()
# File actionpack/test/controller/caching_test.rb, line 733
def test_write_fragment_with_caching_enabled
  assert_nil @store.read('views/name')
  assert_equal 'value', @controller.write_fragment('name', 'value')
  assert_equal 'value', @store.read('views/name')
end