Permalink
Browse files

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

…rect
  • Loading branch information...
1 parent bdc9c87 commit 209d4744b545fb2c3a56cc84d87966a90eb4a160 @jferris jferris committed Aug 2, 2010
View
1 lib/capybara_envjs_fixes/cucumber_fixes.rb
@@ -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'
View
28 lib/capybara_envjs_fixes/cucumber_fixes/redirect_fix.rb
@@ -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)

0 comments on commit 209d474

Please sign in to comment.