Methods
S
T
Instance Public methods
setup()
# File actionpack/test/controller/caching_test.rb, line 179
def setup
  super
  @store = ActiveSupport::Cache::MemoryStore.new
  @controller = FunctionalCachingController.new
  @controller.perform_caching = true
  @controller.cache_store = @store
  @request = ActionController::TestRequest.new
  @response = ActionController::TestResponse.new
end
test_fragment_cache_instrumentation()
# File actionpack/test/controller/caching_test.rb, line 230
def test_fragment_cache_instrumentation
  payload = nil

  subscriber = proc do |*args|
    event = ActiveSupport::Notifications::Event.new(*args)
    payload = event.payload
  end

  ActiveSupport::Notifications.subscribed(subscriber, "read_fragment.action_controller") do
    get :inline_fragment_cached
  end

  assert_equal "functional_caching", payload[:controller]
  assert_equal "inline_fragment_cached", payload[:action]
end
test_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 189
  def test_fragment_caching
    get :fragment_cached
    assert_response :success
    expected_body = <<-CACHED
Hello
This bit's fragment cached
Ciao
CACHED
    assert_equal expected_body, @response.body

    assert_equal "This bit's fragment cached",
      @store.read("views/test.host/functional_caching/fragment_cached/#{template_digest("functional_caching/fragment_cached")}")
  end
test_fragment_caching_in_partials()
# File actionpack/test/controller/caching_test.rb, line 203
def test_fragment_caching_in_partials
  get :html_fragment_cached_with_partial
  assert_response :success
  assert_match(/Old fragment caching in a partial/, @response.body)

  assert_match("Old fragment caching in a partial",
    @store.read("views/test.host/functional_caching/html_fragment_cached_with_partial/#{template_digest("functional_caching/_partial")}"))
end
test_fragment_caching_with_variant()
# File actionpack/test/controller/caching_test.rb, line 269
def test_fragment_caching_with_variant
  @request.variant = :phone

  get :formatted_fragment_cached_with_variant, :format => "html"
  assert_response :success
  expected_body = "<body>\n<p>PHONE</p>\n</body>\n"

  assert_equal expected_body, @response.body

  assert_equal "<p>PHONE</p>",
    @store.read("views/test.host/functional_caching/formatted_fragment_cached_with_variant/#{template_digest("functional_caching/formatted_fragment_cached_with_variant")}")
end
test_html_formatted_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 246
def test_html_formatted_fragment_caching
  get :formatted_fragment_cached, :format => "html"
  assert_response :success
  expected_body = "<body>\n<p>ERB</p>\n</body>\n"

  assert_equal expected_body, @response.body

  assert_equal "<p>ERB</p>",
    @store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached")}")
end
test_render_inline_before_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 221
def test_render_inline_before_fragment_caching
  get :inline_fragment_cached
  assert_response :success
  assert_match(/Some inline content/, @response.body)
  assert_match(/Some cached content/, @response.body)
  assert_match("Some cached content",
    @store.read("views/test.host/functional_caching/inline_fragment_cached/#{template_digest("functional_caching/inline_fragment_cached")}"))
end
test_skipping_fragment_cache_digesting()
# File actionpack/test/controller/caching_test.rb, line 212
def test_skipping_fragment_cache_digesting
  get :fragment_cached_without_digest, :format => "html"
  assert_response :success
  expected_body = "<body>\n<p>ERB</p>\n</body>\n"

  assert_equal expected_body, @response.body
  assert_equal "<p>ERB</p>", @store.read("views/nodigest")
end
test_xml_formatted_fragment_caching()
# File actionpack/test/controller/caching_test.rb, line 257
def test_xml_formatted_fragment_caching
  get :formatted_fragment_cached, :format => "xml"
  assert_response :success
  expected_body = "<body>\n  <p>Builder</p>\n</body>\n"

  assert_equal expected_body, @response.body

  assert_equal "  <p>Builder</p>\n",
    @store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached")}")
end