From 8cbd563edf62b3bcf62de4a5d67ff43453021174 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 8 Sep 2012 14:51:22 -0500 Subject: set default_headers to nil after use it to avoid order dependent tests --- actionpack/test/dispatch/response_test.rb | 57 +++++++++++++++++-------------- 1 file changed, 32 insertions(+), 25 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 4d699bd739..185a9e9b18 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -178,33 +178,40 @@ class ResponseTest < ActiveSupport::TestCase end test "read x_frame_options, x_content_type_options and x_xss_protection" do - ActionDispatch::Response.default_headers = { - 'X-Frame-Options' => 'DENY', - 'X-Content-Type-Options' => 'nosniff', - 'X-XSS-Protection' => '1;' - } - resp = ActionDispatch::Response.new.tap { |response| - response.body = 'Hello' - } - resp.to_a - - assert_equal('DENY', resp.headers['X-Frame-Options']) - assert_equal('nosniff', resp.headers['X-Content-Type-Options']) - assert_equal('1;', resp.headers['X-XSS-Protection']) - end + begin + ActionDispatch::Response.default_headers = { + 'X-Frame-Options' => 'DENY', + 'X-Content-Type-Options' => 'nosniff', + 'X-XSS-Protection' => '1;' + } + resp = ActionDispatch::Response.new.tap { |response| + response.body = 'Hello' + } + resp.to_a + + assert_equal('DENY', resp.headers['X-Frame-Options']) + assert_equal('nosniff', resp.headers['X-Content-Type-Options']) + assert_equal('1;', resp.headers['X-XSS-Protection']) + ensure + ActionDispatch::Response.default_headers = nil + end + end test "read custom default_header" do - ActionDispatch::Response.default_headers = { - 'X-XX-XXXX' => 'Here is my phone number' - } - resp = ActionDispatch::Response.new.tap { |response| - response.body = 'Hello' - } - resp.to_a - - assert_equal('Here is my phone number', resp.headers['X-XX-XXXX']) - end - + begin + ActionDispatch::Response.default_headers = { + 'X-XX-XXXX' => 'Here is my phone number' + } + resp = ActionDispatch::Response.new.tap { |response| + response.body = 'Hello' + } + resp.to_a + + assert_equal('Here is my phone number', resp.headers['X-XX-XXXX']) + ensure + ActionDispatch::Response.default_headers = nil + end + end end class ResponseIntegrationTest < ActionDispatch::IntegrationTest -- cgit v1.2.3