0
@@ -8,14 +8,18 @@ module Fun
0
-# FIXME: crashes Ruby 1.9
0
class TestController < ActionController::Base
0
layout :determine_layout
0
+ last_modified! Time.now.utc.beginning_of_day
0
+ render :action => 'hello_world' unless performed?
0
render :template => "test/hello_world"
0
@@ -408,6 +412,72 @@ class RenderTest < Test::Unit::TestCase
0
assert_equal "Goodbye, Local David", @response.body
0
+ def test_should_render_formatted_template
0
+ get :formatted_html_erb
0
+ assert_equal 'formatted html erb', @response.body
0
+ def test_should_render_formatted_xml_erb_template
0
+ get :formatted_xml_erb, :format => :xml
0
+ assert_equal '<test>passed formatted xml erb</test>', @response.body
0
+ def test_should_render_formatted_html_erb_template
0
+ get :formatted_xml_erb
0
+ assert_equal '<test>passed formatted html erb</test>', @response.body
0
+ def test_should_render_formatted_html_erb_template_with_faulty_accepts_header
0
+ @request.env["HTTP_ACCEPT"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*"
0
+ get :formatted_xml_erb
0
+ assert_equal '<test>passed formatted html erb</test>', @response.body
0
+ def test_should_render_html_formatted_partial
0
+ assert_equal 'partial html', @response.body
0
+ def test_should_render_html_partial_with_dot
0
+ assert_equal 'partial html', @response.body
0
+ def test_should_render_html_formatted_partial_with_rjs
0
+ xhr :get, :partial_as_rjs
0
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
0
+ def test_should_render_html_formatted_partial_with_rjs_and_js_format
0
+ xhr :get, :respond_to_partial_as_rjs
0
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
0
+ def test_should_render_js_partial
0
+ xhr :get, :partial, :format => 'js'
0
+ assert_equal 'partial js', @response.body
0
+ def test_should_render_with_alternate_default_render
0
+ xhr :get, :render_alternate_default
0
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
0
+ def test_should_render_xml_but_keep_custom_content_type
0
+ get :render_xml_with_custom_content_type
0
+ assert_equal "application/atomsvc+xml", @response.content_type
0
+class EtagRenderTest < Test::Unit::TestCase
0
+ @request = ActionController::TestRequest.new
0
+ @response = ActionController::TestResponse.new
0
+ @controller = TestController.new
0
+ @request.host = "www.nextangle.com"
0
def test_render_200_should_set_etag
0
get :render_hello_world_from_variable
0
assert_equal etag_for("hello david"), @response.headers['ETag']
0
@@ -460,64 +530,40 @@ class RenderTest < Test::Unit::TestCase
0
assert_equal etag_for("<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n"), @response.headers['ETag']
0
- def test_should_render_formatted_template
0
- get :formatted_html_erb
0
- assert_equal 'formatted html erb', @response.body
0
- def test_should_render_formatted_xml_erb_template
0
- get :formatted_xml_erb, :format => :xml
0
- assert_equal '<test>passed formatted xml erb</test>', @response.body
0
- def test_should_render_formatted_html_erb_template
0
- get :formatted_xml_erb
0
- assert_equal '<test>passed formatted html erb</test>', @response.body
0
- def test_should_render_formatted_html_erb_template_with_faulty_accepts_header
0
- @request.env["HTTP_ACCEPT"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*"
0
- get :formatted_xml_erb
0
- assert_equal '<test>passed formatted html erb</test>', @response.body
0
- def test_should_render_html_formatted_partial
0
- assert_equal 'partial html', @response.body
0
- def test_should_render_html_partial_with_dot
0
- assert_equal 'partial html', @response.body
0
+ %("#{Digest::MD5.hexdigest(text)}")
0
- def test_should_render_html_formatted_partial_with_rjs
0
- xhr :get, :partial_as_rjs
0
- assert_equal %(Element.replace("foo", "partial html");), @response.body
0
+class LastModifiedRenderTest < Test::Unit::TestCase
0
+ @request = ActionController::TestRequest.new
0
+ @response = ActionController::TestResponse.new
0
+ @controller = TestController.new
0
- def test_should_render_html_formatted_partial_with_rjs_and_js_format
0
- xhr :get, :respond_to_partial_as_rjs
0
- assert_equal %(Element.replace("foo", "partial html");), @response.body
0
+ @request.host = "www.nextangle.com"
0
+ @last_modified = Time.now.utc.beginning_of_day.httpdate
0
- def test_should_render_js_partial
0
- xhr :get, :partial, :format => 'js'
0
- assert_equal 'partial js', @response.body
0
+ def test_responds_with_last_modified
0
+ get :conditional_hello
0
+ assert_equal @last_modified, @response.headers['Last-Modified']
0
- def test_should_render_with_alternate_default_render
0
- xhr :get, :render_alternate_default
0
- assert_equal %(Element.replace("foo", "partial html");), @response.body
0
+ def test_request_not_modified
0
+ @request.headers["HTTP_IF_MODIFIED_SINCE"] = @last_modified
0
+ get :conditional_hello
0
+ assert_equal "304 Not Modified", @response.headers['Status']
0
+ assert @response.body.blank?, @response.body
0
+ assert_equal @last_modified, @response.headers['Last-Modified']
0
- def test_should_render_xml_but_keep_custom_content_type
0
- get :render_xml_with_custom_content_type
0
- assert_equal "application/atomsvc+xml", @response.content_type
0
+ def test_request_modified
0
+ @request.headers["HTTP_IF_MODIFIED_SINCE"] = 'Thu, 16 Jul 2008 00:00:00 GMT'
0
+ get :conditional_hello
0
+ assert_equal "200 OK", @response.headers['Status']
0
+ assert !@response.body.blank?
0
+ assert_equal @last_modified, @response.headers['Last-Modified']
0
- %("#{Digest::MD5.hexdigest(text)}")
Comments
No one has commented yet.