diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-19 02:25:01 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-19 02:25:01 +0000 |
commit | 9e4c8b88584ba09c46abcd484969da6244416946 (patch) | |
tree | d09b4b372c66fe1e07770b8d6fcfa3575f39122c | |
parent | 94fa0ed053a92b4dc48501d7dc7e7ebcec7e1ca6 (diff) | |
download | rails-9e4c8b88584ba09c46abcd484969da6244416946.tar.gz rails-9e4c8b88584ba09c46abcd484969da6244416946.tar.bz2 rails-9e4c8b88584ba09c46abcd484969da6244416946.zip |
Fix tests depending too deep
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6169 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
4 files changed, 12 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/response.rb b/actionpack/lib/action_controller/response.rb index 22dc502395..38647670f2 100755 --- a/actionpack/lib/action_controller/response.rb +++ b/actionpack/lib/action_controller/response.rb @@ -41,9 +41,10 @@ module ActionController set_content_length! end + private def handle_conditional_get! - if body.is_a?(String) && headers['Status'][0..2] == '200' && !body.empty? + if body.is_a?(String) && (headers['Status'] ? headers['Status'][0..2] == '200' : true) && !body.empty? self.headers['ETag'] ||= %("#{Digest::MD5.hexdigest(body)}") self.headers['Cache-Control'] = 'private' if headers['Cache-Control'] == DEFAULT_HEADERS['Cache-Control'] diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index f9a641a1ec..4e79117c7b 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -462,18 +462,18 @@ class ActionPackHeaderTest < Test::Unit::TestCase def test_rendering_xml_sets_content_type assert_deprecated(/render/) { process :hello_xml_world } - assert_equal('application/xml; charset=utf-8', @controller.headers['Content-Type']) + assert_equal('application/xml; charset=utf-8', @response.headers['type']) end def test_rendering_xml_respects_content_type - @response.headers['Content-Type'] = 'application/pdf' + @response.headers['type'] = 'application/pdf' assert_deprecated(/render/) { process :hello_xml_world } - assert_equal('application/pdf; charset=utf-8', @controller.headers['Content-Type']) + assert_equal('application/pdf; charset=utf-8', @response.headers['type']) end def test_render_text_with_custom_content_type get :render_text_with_custom_content_type - assert_equal 'application/rss+xml; charset=utf-8', @response.headers['Content-Type'] + assert_equal 'application/rss+xml; charset=utf-8', @response.headers['type'] end end diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 70bb18cadc..d3967791a0 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -669,14 +669,14 @@ EOS def test_update_page get :update_page assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'] + assert_equal 'text/javascript; charset=utf-8', @response.headers['type'] assert_equal 2, @response.body.split($/).length end def test_update_page_with_instance_variables get :update_page_with_instance_variables assert_template nil - assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type'] + assert_equal 'text/javascript; charset=utf-8', @response.headers['type'] assert_match /balance/, @response.body assert_match /\$37/, @response.body end diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 77f1c3614b..86f83d4539 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -73,10 +73,10 @@ class SendFileTest < Test::Unit::TestCase def test_headers_after_send_shouldnt_include_charset response = process('data') - assert_equal "application/octet-stream", response.headers["Content-Type"] + assert_equal "application/octet-stream", response.content_type response = process('file') - assert_equal "application/octet-stream", response.headers["Content-Type"] + assert_equal "application/octet-stream", response.content_type end # Test that send_file_headers! is setting the correct HTTP headers. @@ -113,13 +113,13 @@ class SendFileTest < Test::Unit::TestCase define_method "test_send_#{method}_status" do @controller.options = { :stream => false, :status => 500 } assert_nothing_raised { assert_not_nil process(method) } - assert_equal '500 Internal Server Error', @controller.headers['Status'] + assert_equal '500 Internal Server Error', @response.headers['Status'] end define_method "test_default_send_#{method}_status" do @controller.options = { :stream => false } assert_nothing_raised { assert_not_nil process(method) } - assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @controller.headers['Status'] + assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @response.headers['Status'] end end end |