Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -1,3 +1,4 @@
require 'capybara_envjs_fixes/cucumber_fixes/javascript'
require 'capybara_envjs_fixes/cucumber_fixes/capybara_extensions'
require 'capybara_envjs_fixes/cucumber_fixes/base64_upload'
+require 'capybara_envjs_fixes/cucumber_fixes/redirect_fix'
28 lib/capybara_envjs_fixes/cucumber_fixes/redirect_fix.rb
View
@@ -0,0 +1,28 @@
+class RedirectContentTypeRemover
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ remove_content_type_from_redirect(env)
+ @app.call(env)
+ end
+
+ private
+
+ def remove_content_type_from_redirect(env)
+ if input_blank?(env)
+ env.delete('CONTENT_TYPE')
+ end
+ end
+
+ def input_blank?(env)
+ input = env['rack.input']
+ return true unless input
+ content = input.read
+ input.rewind
+ content.blank?
+ end
+end
+
+Capybara.app = RedirectContentTypeRemover.new(Capybara.app)
Please sign in to comment.
Something went wrong with that request. Please try again.