Updated

spec/support / forgery_protection.rb

A
25 lines of codes
1 methods
5.0 complexity/method
1 churn
4.96 complexity
23 duplications
RSpec.configure do |config| mod = Module.new do def with_forgery_protection(on_or_off, &block)
  1. with_forgery_protection doesn't depend on instance state (maybe move it to another class?)
begin current = ActionController::Base.allow_forgery_protection ActionController::Base.allow_forgery_protection = on_or_off yield ensure ActionController::Base.allow_forgery_protection = current end end end config.include(mod, type: :request) config.around(:each, type: :request) do |example|
  1. Similar code found in 2 nodes Locations: 0 1
if example.metadata.key?(:csrf) with_forgery_protection(example.metadata[:csrf]) do example.run end else example.run end end end