Methods
S
T
Included Modules
Instance Public methods
setup()
# File actionpack/test/controller/caching_test.rb, line 340
def setup
  super
  reset!
  FileUtils.mkdir_p(FILE_STORE_PATH)
  @path_class = ActionController::Caching::Actions::ActionCachePath
  @mock_controller = ActionCachingMockController.new
end
teardown()
# File actionpack/test/controller/caching_test.rb, line 348
def teardown
  FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
end
test_action_cache_conditional_options()
# File actionpack/test/controller/caching_test.rb, line 411
def test_action_cache_conditional_options
  @request.env['HTTP_ACCEPT'] = 'application/json'
  get :index
  assert_response :success
  assert !fragment_exist?('hostname.com/action_caching_test')
end
test_action_cache_with_custom_cache_path()
# File actionpack/test/controller/caching_test.rb, line 433
def test_action_cache_with_custom_cache_path
  get :show
  assert_response :success
  cached_time = content_to_cache
  assert_equal cached_time, @response.body
  assert fragment_exist?('test.host/custom/show')
  reset!

  get :show
  assert_response :success
  assert_equal cached_time, @response.body
end
test_action_cache_with_custom_cache_path_in_block()
# File actionpack/test/controller/caching_test.rb, line 446
def test_action_cache_with_custom_cache_path_in_block
  get :edit
  assert_response :success
  assert fragment_exist?('test.host/edit')
  reset!

  get :edit, :id => 1
  assert_response :success
  assert fragment_exist?('test.host/1;edit')
end
test_action_cache_with_format_and_http_param()
# File actionpack/test/controller/caching_test.rb, line 418
def test_action_cache_with_format_and_http_param
  get :with_format_and_http_param, :format => 'json'
  assert_response :success
  assert !fragment_exist?('hostname.com/action_caching_test/with_format_and_http_param.json?key=value.json')
  assert fragment_exist?('hostname.com/action_caching_test/with_format_and_http_param.json?key=value')
end
test_action_cache_with_layout()
# File actionpack/test/controller/caching_test.rb, line 380
def test_action_cache_with_layout
  get :with_layout
  assert_response :success
  cached_time = content_to_cache
  assert_not_equal cached_time, @response.body
  assert fragment_exist?('hostname.com/action_caching_test/with_layout')
  reset!

  get :with_layout
  assert_response :success
  assert_not_equal cached_time, @response.body
  body = body_to_string(read_fragment('hostname.com/action_caching_test/with_layout'))
  assert_equal @response.body, body
end
test_action_cache_with_layout_and_layout_cache_false()
# File actionpack/test/controller/caching_test.rb, line 395
def test_action_cache_with_layout_and_layout_cache_false
  get :layout_false
  assert_response :success
  cached_time = content_to_cache
  assert_not_equal cached_time, @response.body
  assert fragment_exist?('hostname.com/action_caching_test/layout_false')
  reset!

  get :layout_false
  assert_response :success
  assert_not_equal cached_time, @response.body

  body = body_to_string(read_fragment('hostname.com/action_caching_test/layout_false'))
  assert_equal cached_time, body
end
test_action_cache_with_store_options()
# File actionpack/test/controller/caching_test.rb, line 425
def test_action_cache_with_store_options
  MockTime.expects(:now).returns(12345).once
  @controller.expects(:read_fragment).with('hostname.com/action_caching_test', :expires_in => 1.hour).once
  @controller.expects(:write_fragment).with('hostname.com/action_caching_test', '12345.0', :expires_in => 1.hour).once
  get :index
  assert_response :success
end
test_action_caching_plus_streaming()
# File actionpack/test/controller/caching_test.rb, line 655
def test_action_caching_plus_streaming
  get :streaming
  assert_response :success
  assert_match(/streaming/, @response.body)
  assert fragment_exist?('hostname.com/action_caching_test/streaming')
end
test_cache_expiration()
# File actionpack/test/controller/caching_test.rb, line 457
def test_cache_expiration
  get :index
  assert_response :success
  cached_time = content_to_cache
  reset!

  get :index
  assert_response :success
  assert_equal cached_time, @response.body
  reset!

  get :expire
  assert_response :success
  reset!

  get :index
  assert_response :success
  new_cached_time = content_to_cache
  assert_not_equal cached_time, @response.body
  reset!

  get :index
  assert_response :success
  assert_equal new_cached_time, @response.body
end
test_cache_expiration_isnt_affected_by_request_format()
# File actionpack/test/controller/caching_test.rb, line 483
def test_cache_expiration_isnt_affected_by_request_format
  get :index
  cached_time = content_to_cache
  reset!

  @request.request_uri = "/action_caching_test/expire.xml"
  get :expire, :format => :xml
  assert_response :success
  reset!

  get :index
  assert_response :success
  assert_not_equal cached_time, @response.body
end
test_cache_expiration_with_url_string()
# File actionpack/test/controller/caching_test.rb, line 498
def test_cache_expiration_with_url_string
  get :index
  cached_time = content_to_cache
  reset!

  @request.request_uri = "/action_caching_test/expire_with_url_string"
  get :expire_with_url_string
  assert_response :success
  reset!

  get :index
  assert_response :success
  assert_not_equal cached_time, @response.body
end
test_cache_is_scoped_by_subdomain()
# File actionpack/test/controller/caching_test.rb, line 513
def test_cache_is_scoped_by_subdomain
  @request.host = 'jamis.hostname.com'
  get :index
  assert_response :success
  jamis_cache = content_to_cache

  reset!

  @request.host = 'david.hostname.com'
  get :index
  assert_response :success
  david_cache = content_to_cache
  assert_not_equal jamis_cache, @response.body

  reset!

  @request.host = 'jamis.hostname.com'
  get :index
  assert_response :success
  assert_equal jamis_cache, @response.body

  reset!

  @request.host = 'david.hostname.com'
  get :index
  assert_response :success
  assert_equal david_cache, @response.body
end
test_correct_content_type_is_returned_for_cache_hit()
# File actionpack/test/controller/caching_test.rb, line 589
def test_correct_content_type_is_returned_for_cache_hit
  # run it twice to cache it the first time
  get :index, :id => 'content-type', :format => 'xml'
  get :index, :id => 'content-type', :format => 'xml'
  assert_response :success
  assert_equal 'application/xml', @response.content_type
end
test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key()
# File actionpack/test/controller/caching_test.rb, line 597
def test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key
  # run it twice to cache it the first time
  get :show, :format => 'xml'
  get :show, :format => 'xml'
  assert_response :success
  assert_equal 'application/xml', @response.content_type
end
test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key_from_proc()
# File actionpack/test/controller/caching_test.rb, line 605
def test_correct_content_type_is_returned_for_cache_hit_on_action_with_string_key_from_proc
  # run it twice to cache it the first time
  get :edit, :id => 1, :format => 'xml'
  get :edit, :id => 1, :format => 'xml'
  assert_response :success
  assert_equal 'application/xml', @response.content_type
end
test_empty_path_is_normalized()
# File actionpack/test/controller/caching_test.rb, line 613
def test_empty_path_is_normalized
  @mock_controller.mock_url_for = 'http://example.org/'
  @mock_controller.mock_path    = '/'

  assert_equal 'example.org/index', @path_class.new(@mock_controller, {}).path
end
test_file_extensions()
# File actionpack/test/controller/caching_test.rb, line 620
def test_file_extensions
  get :index, :id => 'kitten.jpg'
  get :index, :id => 'kitten.jpg'

  assert_response :success
end
test_forbidden_is_not_cached()
# File actionpack/test/controller/caching_test.rb, line 551
def test_forbidden_is_not_cached
  get :forbidden
  assert_response :forbidden
  reset!

  get :forbidden
  assert_response :forbidden
end
test_four_oh_four_renders_content()
# File actionpack/test/controller/caching_test.rb, line 643
def test_four_oh_four_renders_content
  get :four_oh_four
  assert_equal "404'd!", @response.body
end
test_four_oh_four_returns_404_for_multiple_requests()
# File actionpack/test/controller/caching_test.rb, line 636
def test_four_oh_four_returns_404_for_multiple_requests
  get :four_oh_four
  assert_response 404
  get :four_oh_four
  assert_response 404
end
test_record_not_found_returns_404_for_multiple_requests()
# File actionpack/test/controller/caching_test.rb, line 628
def test_record_not_found_returns_404_for_multiple_requests
  get :record_not_found
  assert_response 404
  get :record_not_found
  assert_response 404
end
test_redirect_is_not_cached()
# File actionpack/test/controller/caching_test.rb, line 542
def test_redirect_is_not_cached
  get :redirected
  assert_response :redirect
  reset!

  get :redirected
  assert_response :redirect
end
test_simple_action_cache()
# File actionpack/test/controller/caching_test.rb, line 352
def test_simple_action_cache
  get :index
  assert_response :success
  cached_time = content_to_cache
  assert_equal cached_time, @response.body
  assert fragment_exist?('hostname.com/action_caching_test')
  reset!

  get :index
  assert_response :success
  assert_equal cached_time, @response.body
end
test_simple_action_not_cached()
# File actionpack/test/controller/caching_test.rb, line 365
def test_simple_action_not_cached
  get :destroy
  assert_response :success
  cached_time = content_to_cache
  assert_equal cached_time, @response.body
  assert !fragment_exist?('hostname.com/action_caching_test/destroy')
  reset!

  get :destroy
  assert_response :success
  assert_not_equal cached_time, @response.body
end
test_simple_runtime_error_returns_500_for_multiple_requests()
# File actionpack/test/controller/caching_test.rb, line 648
def test_simple_runtime_error_returns_500_for_multiple_requests
  get :simple_runtime_error
  assert_response 500
  get :simple_runtime_error
  assert_response 500
end
test_xml_version_of_resource_is_treated_as_different_cache()
# File actionpack/test/controller/caching_test.rb, line 560
def test_xml_version_of_resource_is_treated_as_different_cache
  with_routing do |set|
    set.draw do
      match ':controller(/:action(.:format))'
    end

    get :index, :format => 'xml'
    assert_response :success
    cached_time = content_to_cache
    assert_equal cached_time, @response.body
    assert fragment_exist?('hostname.com/action_caching_test/index.xml')
    reset!

    get :index, :format => 'xml'
    assert_response :success
    assert_equal cached_time, @response.body
    assert_equal 'application/xml', @response.content_type
    reset!

    get :expire_xml
    assert_response :success
    reset!

    get :index, :format => 'xml'
    assert_response :success
    assert_not_equal cached_time, @response.body
  end
end