提交 db1d4d31 编写于 作者: A Aaron Patterson

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.
上级 39df51e1
...@@ -974,6 +974,11 @@ def remove_header ...@@ -974,6 +974,11 @@ def remove_header
headers.delete params[:header] headers.delete params[:header]
head :ok, 'C' => '3' head :ok, 'C' => '3'
end end
# Render a head response, but don't touch default headers
def leave_alone
head :ok
end
end end
def before_setup def before_setup
...@@ -999,9 +1004,13 @@ def setup ...@@ -999,9 +1004,13 @@ def setup
end end
test "response contains default headers" do test "response contains default headers" do
get :leave_alone
# Response headers start out with the defaults # 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' } get :remove_header, params: { header: 'A' }
assert_response :ok assert_response :ok
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册