diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-08 13:00:46 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-08 13:00:46 -0700 |
commit | f6296601a2fcd440cc12bbc5e0b6c61ce7269ecb (patch) | |
tree | 4f83303f5a90919e02a83d7e15121ebc9327d326 /actionpack | |
parent | 0617808a9d0700abe5f26abbb2220bc043e812aa (diff) | |
parent | 8cbd563edf62b3bcf62de4a5d67ff43453021174 (diff) | |
download | rails-f6296601a2fcd440cc12bbc5e0b6c61ce7269ecb.tar.gz rails-f6296601a2fcd440cc12bbc5e0b6c61ce7269ecb.tar.bz2 rails-f6296601a2fcd440cc12bbc5e0b6c61ce7269ecb.zip |
Merge pull request #7577 from frodsan/fix_ap_response
set default_headers to nil after use it to avoid order dependent tests
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/dispatch/response_test.rb | 57 |
1 files changed, 32 insertions, 25 deletions
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 |