Patch for Rails 3 controller redirects #46

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
7 participants

Now that Rails 3 is an actual Rack application the testing urls are not working with controller redirects (redirect_to some_path). These return a page with only "You are being redirected." as the content currently and on webrat/master. This corrects that issue and allows for the redirects to happen as would be expected.

raid5 commented Jan 10, 2011

Can't wait for this patch to be accepted. A lot of people seem to be having issues related to this at the moment.

+1 I've been banging my head against this for the past 4 hours. Glad to see it's not just me.

jphpsf commented Feb 14, 2011

+1

For now, I've been placing the a webrat_host_fix.rb file under features/support/ (I am using cucumber)

# Fix the issue between webrat 0.7.3 using "example.org" and rails 3.x using "example.com"
Webrat::Session.class_eval do
    def current_host
        URI.parse(current_url).host || @custom_headers["Host"] || default_current_host
    end

    def default_current_host
        adapter.class == Webrat::RackAdapter ? "example.org" : "www.example.com"
    end
end

+1

Difficult to perform any valuable testing with cucumber and webrat without this fix.

+1

Can't wait to remove the hack that override the DEFAULT_HOST constant to avoid the "already initialized constant DEFAULT_HOST" warning.

Contributor

dlibanori commented Mar 3, 2011

Nice work, but I think it is tightly coupled with Rack::Test internals. I did another patch, improving Webrat specs and less coupled with Rack::Test.

#52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment