diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2014-05-28 12:03:50 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2014-05-28 12:03:50 -0300 |
commit | abd6461e2881a09cb7b719ffb016c0c85d89ffe0 (patch) | |
tree | 3699537fbb7ac9a187bd8cd4ba9e5c1e0efc45e1 | |
parent | 7fcbc3681eeb7b7e093fba47c5b881c932219bdd (diff) | |
parent | e354b335ce95ab3464c6cfdc4d7b0376577b4de0 (diff) | |
download | rails-abd6461e2881a09cb7b719ffb016c0c85d89ffe0.tar.gz rails-abd6461e2881a09cb7b719ffb016c0c85d89ffe0.tar.bz2 rails-abd6461e2881a09cb7b719ffb016c0c85d89ffe0.zip |
Merge pull request #15386 from zuhao/refactor_actionpack_request_forgery_protection_test
Avoid hardcoded `request_forgery_protection_token` value in teardown.
-rw-r--r-- | actionpack/test/controller/request_forgery_protection_test.rb | 9 |
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 |