aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-08 14:51:22 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-08 14:51:22 -0500
commit8cbd563edf62b3bcf62de4a5d67ff43453021174 (patch)
tree55e9f26a8e29937ac1387e58c606e0ce823d41a4 /actionpack/test
parent7b31a430858c40238dec0a7530937a4b7ee95c7b (diff)
downloadrails-8cbd563edf62b3bcf62de4a5d67ff43453021174.tar.gz
rails-8cbd563edf62b3bcf62de4a5d67ff43453021174.tar.bz2
rails-8cbd563edf62b3bcf62de4a5d67ff43453021174.zip
set default_headers to nil after use it to avoid order dependent tests
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/dispatch/response_test.rb57
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