From db1d4d31c9a270bdb8b8873ec59f18eade94a55f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 23 Sep 2015 12:08:32 -0700 Subject: don't access the response object before a request was made It doesn't make sense to access the response object before a request is made (how was a response object created without making a request?) This commit splits testing default headers and default header mutation tests and removes access to the pre-request response object. --- actionpack/test/controller/test_case_test.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 06bf9dec74..40c97abd35 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -974,6 +974,11 @@ class ResponseDefaultHeadersTest < ActionController::TestCase headers.delete params[:header] head :ok, 'C' => '3' end + + # Render a head response, but don't touch default headers + def leave_alone + head :ok + end end def before_setup @@ -999,9 +1004,13 @@ class ResponseDefaultHeadersTest < ActionController::TestCase end test "response contains default headers" do + get :leave_alone + # Response headers start out with the defaults - assert_equal @defaults, response.headers + assert_equal @defaults.merge('Content-Type' => 'text/html'), response.headers + end + test "response deletes a default header" do get :remove_header, params: { header: 'A' } assert_response :ok -- cgit v1.2.3