#332 ✓resolved
Bryan Helmkamp

current_url does not reflect redirects in a Mechanize session

Reported by Bryan Helmkamp | January 17th, 2010 @ 06:44 PM

Moved from GitHub issue # 17

Created 4 months ago by sandro | edit
When I visit a protected page within a mechanize session and it redirects me to the sign in page, the current_url still points to the protected url, not the url of the redirect. I assume this happens because mechanize follows redirects by default.

A possible solution:

module Webrat
  class MechanizeSession
    def current_url
      response.uri.to_s
    end
  end

  class Session
    def current_url
      if @adapter.respond_to?(:current_url)
        @adapter.current_url
      else
        @current_url
      end
    end
  end
end

Comments

piglop September 19, 2009

It works, but with "class MechanizeAdapter". instead of "class MechanizeSession"

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Attachments

Referenced by

Pages