diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-05-08 22:41:09 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-05-08 23:24:00 +0100 |
commit | bbc53f2b86f6bc3453e1dc29cc56c2792cee9f49 (patch) | |
tree | f96a85dc222227f1caedf8032877c3f4492565a7 | |
parent | 892b371dadeec0baf28bf401d2ef26906957d81c (diff) | |
download | gitlab-ce-bbc53f2b86f6bc3453e1dc29cc56c2792cee9f49.tar.gz |
Backport with_forgery_protection spec helper
-rw-r--r-- | spec/support/forgery_protection.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/spec/support/forgery_protection.rb b/spec/support/forgery_protection.rb index a5e7b761651..fa87d5fa881 100644 --- a/spec/support/forgery_protection.rb +++ b/spec/support/forgery_protection.rb @@ -1,11 +1,18 @@ +module ForgeryProtection + def with_forgery_protection + ActionController::Base.allow_forgery_protection = true + yield + ensure + ActionController::Base.allow_forgery_protection = false + end + + module_function :with_forgery_protection +end + RSpec.configure do |config| config.around(:each, :allow_forgery_protection) do |example| - begin - ActionController::Base.allow_forgery_protection = true - + ForgeryProtection.with_forgery_protection do example.call - ensure - ActionController::Base.allow_forgery_protection = false end end end |