class ExpiresInRenderTest

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File actionpack/test/controller/render_test.rb, line 285
def setup
  super
  ActionController::Base.view_paths.paths.each(&:clear_cache)
end
test_date_header_when_expires_in() click to toggle source
# File actionpack/test/controller/render_test.rb, line 371
def test_date_header_when_expires_in
  time = Time.mktime(2011, 10, 30)
  Time.stub :now, time do
    get :conditional_hello_with_expires_in
    assert_equal Time.now.httpdate, @response.headers["Date"]
  end
end
test_dynamic_render() click to toggle source
# File actionpack/test/controller/render_test.rb, line 310
def test_dynamic_render
  assert File.exist?(File.expand_path("../../test/abstract_unit.rb", __dir__))
  assert_raises ActionView::MissingTemplate do
    get :dynamic_render, params: { id: '../\\../test/abstract_unit.rb' }
  end
end
test_dynamic_render_file_hash() click to toggle source
# File actionpack/test/controller/render_test.rb, line 324
def test_dynamic_render_file_hash
  assert_raises ArgumentError do
    get :dynamic_render, params: { id: { file: '../\\../test/abstract_unit.rb' } }
  end
end
test_dynamic_render_with_absolute_path() click to toggle source
# File actionpack/test/controller/render_test.rb, line 298
def test_dynamic_render_with_absolute_path
  file = Tempfile.new("name")
  file.write "secrets!"
  file.flush
  assert_raises ActionView::MissingTemplate do
    get :dynamic_render, params: { id: file.path }
  end
ensure
  file.close
  file.unlink
end
test_dynamic_render_with_file() click to toggle source
# File actionpack/test/controller/render_test.rb, line 290
def test_dynamic_render_with_file
  # This is extremely bad, but should be possible to do.
  assert File.exist?(File.expand_path("../../test/abstract_unit.rb", __dir__))
  response = get :dynamic_render_with_file, params: { id: '../\\../test/abstract_unit.rb' }
  assert_equal File.read(File.expand_path("../../test/abstract_unit.rb", __dir__)),
    response.body
end
test_expires_in_header() click to toggle source
# File actionpack/test/controller/render_test.rb, line 330
def test_expires_in_header
  get :conditional_hello_with_expires_in
  assert_equal "max-age=60, private", @response.headers["Cache-Control"]
end
test_expires_in_header_with_additional_headers() click to toggle source
# File actionpack/test/controller/render_test.rb, line 350
def test_expires_in_header_with_additional_headers
  get :conditional_hello_with_expires_in_with_public_with_more_keys
  assert_equal "max-age=60, public, s-maxage=18000", @response.headers["Cache-Control"]
end
test_expires_in_header_with_must_revalidate() click to toggle source
# File actionpack/test/controller/render_test.rb, line 340
def test_expires_in_header_with_must_revalidate
  get :conditional_hello_with_expires_in_with_must_revalidate
  assert_equal "max-age=60, private, must-revalidate", @response.headers["Cache-Control"]
end
test_expires_in_header_with_public() click to toggle source
# File actionpack/test/controller/render_test.rb, line 335
def test_expires_in_header_with_public
  get :conditional_hello_with_expires_in_with_public
  assert_equal "max-age=60, public", @response.headers["Cache-Control"]
end
test_expires_in_header_with_public_and_must_revalidate() click to toggle source
# File actionpack/test/controller/render_test.rb, line 345
def test_expires_in_header_with_public_and_must_revalidate
  get :conditional_hello_with_expires_in_with_public_and_must_revalidate
  assert_equal "max-age=60, public, must-revalidate", @response.headers["Cache-Control"]
end
test_expires_in_old_syntax() click to toggle source
# File actionpack/test/controller/render_test.rb, line 355
def test_expires_in_old_syntax
  get :conditional_hello_with_expires_in_with_public_with_more_keys_old_syntax
  assert_equal "max-age=60, public, s-maxage=18000", @response.headers["Cache-Control"]
end
test_expires_now() click to toggle source
# File actionpack/test/controller/render_test.rb, line 360
def test_expires_now
  get :conditional_hello_with_expires_now
  assert_equal "no-cache", @response.headers["Cache-Control"]
end
test_expires_now_with_cache_control_headers() click to toggle source
# File actionpack/test/controller/render_test.rb, line 365
def test_expires_now_with_cache_control_headers
  get :conditional_hello_with_cache_control_headers
  assert_match(/no-cache/, @response.headers["Cache-Control"])
  assert_match(/no-transform/, @response.headers["Cache-Control"])
end
test_permitted_dynamic_render_file_hash() click to toggle source
# File actionpack/test/controller/render_test.rb, line 317
def test_permitted_dynamic_render_file_hash
  assert File.exist?(File.expand_path("../../test/abstract_unit.rb", __dir__))
  response = get :dynamic_render_permit, params: { id: { file: '../\\../test/abstract_unit.rb' } }
  assert_equal File.read(File.expand_path("../../test/abstract_unit.rb", __dir__)),
    response.body
end