Methods
S
T
Instance Public methods
setup()
# File actionpack/test/controller/caching_test.rb, line 78
def setup
  super

  @request = ActionController::TestRequest.new
  @request.host = 'hostname.com'
  @request.env.delete('PATH_INFO')

  @controller = PageCachingTestController.new
  @controller.perform_caching = true
  @controller.cache_store = :file_store, FILE_STORE_PATH

  @response   = ActionController::TestResponse.new

  @params = {:controller => 'posts', :action => 'index', :only_path => true}

  FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
  FileUtils.mkdir_p(FILE_STORE_PATH)
end
teardown()
# File actionpack/test/controller/caching_test.rb, line 97
def teardown
  FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
  @controller.perform_caching = false
end
test_cached_page_should_not_have_trailing_slash_even_if_url_has_trailing_slash()
# File actionpack/test/controller/caching_test.rb, line 170
def test_cached_page_should_not_have_trailing_slash_even_if_url_has_trailing_slash
  @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash/'
  assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html")
end
test_page_caching_conditional_options()
# File actionpack/test/controller/caching_test.rb, line 194
def test_page_caching_conditional_options
  get :ok, :format=>'json'
  assert_page_not_cached :ok
end
test_page_caching_directory_set_as_pathname()
# File actionpack/test/controller/caching_test.rb, line 199
def test_page_caching_directory_set_as_pathname
  begin
    ActionController::Base.page_cache_directory = Pathname.new(FILE_STORE_PATH)
    get :ok
    assert_response :ok
    assert_page_cached :ok
  ensure
    ActionController::Base.page_cache_directory = FILE_STORE_PATH
  end
end
test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route()
# File actionpack/test/controller/caching_test.rb, line 102
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
  with_routing do |set|
    set.draw do
      match 'posts.:format', :to => 'posts#index', :as => :formatted_posts
      match '/', :to => 'posts#index', :as => :main
    end
    @params[:format] = 'rss'
    assert_equal '/posts.rss', @routes.url_for(@params)
    @params[:format] = nil
    assert_equal '/', @routes.url_for(@params)
  end
end
test_should_allow_to_disable_gzip()
# File actionpack/test/controller/caching_test.rb, line 142
def test_should_allow_to_disable_gzip
  get :no_gzip
  assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/no_gzip.html")
  assert !File.exist?("#{FILE_STORE_PATH}/page_caching_test/no_gzip.html.gz")
end
test_should_cache_get_with_ok_status()
# File actionpack/test/controller/caching_test.rb, line 115
def test_should_cache_get_with_ok_status
  get :ok
  assert_response :ok
  assert_page_cached :ok, "get with ok status should have been cached"
end
test_should_cache_ok_at_custom_path()
# File actionpack/test/controller/caching_test.rb, line 175
def test_should_cache_ok_at_custom_path
  @request.env['PATH_INFO'] = '/index.html'
  get :ok
  assert_response :ok
  assert File.exist?("#{FILE_STORE_PATH}/index.html")
end
test_should_cache_with_custom_path()
# File actionpack/test/controller/caching_test.rb, line 121
def test_should_cache_with_custom_path
  get :custom_path
  assert File.exist?("#{FILE_STORE_PATH}/index.html")
end
test_should_cache_without_trailing_slash_on_url()
# File actionpack/test/controller/caching_test.rb, line 158
def test_should_cache_without_trailing_slash_on_url
  @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash'
  assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html")
end
test_should_expire_cache_with_custom_path()
# File actionpack/test/controller/caching_test.rb, line 126
def test_should_expire_cache_with_custom_path
  get :custom_path
  assert File.exist?("#{FILE_STORE_PATH}/index.html")

  get :expire_custom_path
  assert !File.exist?("#{FILE_STORE_PATH}/index.html")
end
test_should_gzip_cache()
# File actionpack/test/controller/caching_test.rb, line 134
def test_should_gzip_cache
  get :custom_path
  assert File.exist?("#{FILE_STORE_PATH}/index.html.gz")

  get :expire_custom_path
  assert !File.exist?("#{FILE_STORE_PATH}/index.html.gz")
end
test_should_obey_http_accept_attribute()
# File actionpack/test/controller/caching_test.rb, line 163
def test_should_obey_http_accept_attribute
  @request.env['HTTP_ACCEPT'] = 'text/xml'
  get :about_me
  assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/about_me.xml")
  assert_equal 'I am xml', @response.body
end
test_should_set_gzip_level()
# File actionpack/test/controller/caching_test.rb, line 153
def test_should_set_gzip_level
  @controller.expects(:cache_page).with(nil, nil, Zlib::BEST_SPEED)
  get :gzip_level
end
test_should_use_config_gzip_by_default()
# File actionpack/test/controller/caching_test.rb, line 148
def test_should_use_config_gzip_by_default
  @controller.expects(:cache_page).with(nil, nil, Zlib::BEST_COMPRESSION)
  get :default_gzip
end