Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed capybara-envjs-driver keeping the content type header on a redi…

…rect
  • Loading branch information...
commit 209d4744b545fb2c3a56cc84d87966a90eb4a160 1 parent bdc9c87
Joe Ferris jferris authored
1  lib/capybara_envjs_fixes/cucumber_fixes.rb
... ... @@ -1,3 +1,4 @@
1 1 require 'capybara_envjs_fixes/cucumber_fixes/javascript'
2 2 require 'capybara_envjs_fixes/cucumber_fixes/capybara_extensions'
3 3 require 'capybara_envjs_fixes/cucumber_fixes/base64_upload'
  4 +require 'capybara_envjs_fixes/cucumber_fixes/redirect_fix'
28 lib/capybara_envjs_fixes/cucumber_fixes/redirect_fix.rb
... ... @@ -0,0 +1,28 @@
  1 +class RedirectContentTypeRemover
  2 + def initialize(app)
  3 + @app = app
  4 + end
  5 +
  6 + def call(env)
  7 + remove_content_type_from_redirect(env)
  8 + @app.call(env)
  9 + end
  10 +
  11 + private
  12 +
  13 + def remove_content_type_from_redirect(env)
  14 + if input_blank?(env)
  15 + env.delete('CONTENT_TYPE')
  16 + end
  17 + end
  18 +
  19 + def input_blank?(env)
  20 + input = env['rack.input']
  21 + return true unless input
  22 + content = input.read
  23 + input.rewind
  24 + content.blank?
  25 + end
  26 +end
  27 +
  28 +Capybara.app = RedirectContentTypeRemover.new(Capybara.app)

0 comments on commit 209d474

Please sign in to comment.
Something went wrong with that request. Please try again.