aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/request_forgery_protection_test.rb
diff options
context:
space:
mode:
authorZuhao Wan <wanzuhao@gmail.com>2014-05-28 22:35:48 +0800
committerZuhao Wan <wanzuhao@gmail.com>2014-05-28 22:35:48 +0800
commite354b335ce95ab3464c6cfdc4d7b0376577b4de0 (patch)
treedd67c2d93abc90e22fb1d14593bf7b6f4a7e6165 /actionpack/test/controller/request_forgery_protection_test.rb
parentb22b1882238b08ed341bebc32335b6b6f6f64dfb (diff)
downloadrails-e354b335ce95ab3464c6cfdc4d7b0376577b4de0.tar.gz
rails-e354b335ce95ab3464c6cfdc4d7b0376577b4de0.tar.bz2
rails-e354b335ce95ab3464c6cfdc4d7b0376577b4de0.zip
Avoid hardcoded value in teardown.
Diffstat (limited to 'actionpack/test/controller/request_forgery_protection_test.rb')
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index 07c2115832..2a5aad9c0e 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -127,11 +127,12 @@ module RequestForgeryProtectionTests
@token = "cf50faa3fe97702ca1ae"
SecureRandom.stubs(:base64).returns(@token)
+ @old_request_forgery_protection_token = ActionController::Base.request_forgery_protection_token
ActionController::Base.request_forgery_protection_token = :custom_authenticity_token
end
def teardown
- ActionController::Base.request_forgery_protection_token = nil
+ ActionController::Base.request_forgery_protection_token = @old_request_forgery_protection_token
end
def test_should_render_form_with_token_tag
@@ -376,11 +377,12 @@ class RequestForgeryProtectionControllerUsingResetSessionTest < ActionController
include RequestForgeryProtectionTests
setup do
+ @old_request_forgery_protection_token = ActionController::Base.request_forgery_protection_token
ActionController::Base.request_forgery_protection_token = :custom_authenticity_token
end
teardown do
- ActionController::Base.request_forgery_protection_token = nil
+ ActionController::Base.request_forgery_protection_token = @old_request_forgery_protection_token
end
test 'should emit a csrf-param meta tag and a csrf-token meta tag' do
@@ -465,11 +467,12 @@ class CustomAuthenticityParamControllerTest < ActionController::TestCase
@old_logger = ActionController::Base.logger
@logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new
@token = "foobar"
+ @old_request_forgery_protection_token = ActionController::Base.request_forgery_protection_token
ActionController::Base.request_forgery_protection_token = @token
end
def teardown
- ActionController::Base.request_forgery_protection_token = nil
+ ActionController::Base.request_forgery_protection_token = @old_request_forgery_protection_token
super
end