adding a helper method to make it easier to see where the user was redirected_to
This commit is contained in:
parent
ce36e5890f
commit
4e3cf59920
@ -125,10 +125,6 @@ For example:
|
||||
response_code / 100 == 3
|
||||
end
|
||||
|
||||
# def internal_redirect? #:nodoc:
|
||||
# redirect? && current_host == response_location_host
|
||||
# end
|
||||
|
||||
def internal_redirect?
|
||||
return false unless redirect?
|
||||
#should keep internal_redirects if the subdomain changes
|
||||
@ -136,6 +132,11 @@ For example:
|
||||
response_location_host_domain = response_location_host.split('.')[-2..-1].join('.') rescue response_location_host
|
||||
current_host_domain == response_location_host_domain
|
||||
end
|
||||
|
||||
#easy helper to pull out where we were redirected to
|
||||
def redirected_to
|
||||
redirect? ? response_location : nil
|
||||
end
|
||||
|
||||
def exception_caught? #:nodoc:
|
||||
response_body =~ /Exception caught/
|
||||
|
@ -184,6 +184,24 @@ describe Webrat::Session do
|
||||
webrat_session.stub!(:response_location => "http://login.google.com")
|
||||
webrat_session.internal_redirect?.should be_false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#redirected_to" do
|
||||
before(:each) do
|
||||
webrat_session = Webrat::Session.new
|
||||
end
|
||||
|
||||
it "should return nil if not redirected" do
|
||||
webrat_session.stub!(:redirect? => false)
|
||||
webrat_session.redirected_to.should be_nil
|
||||
end
|
||||
|
||||
it "should return the response_location if redirected" do
|
||||
webrat_session.stub!(:redirect? => true)
|
||||
webrat_session.stub!(:response_location => "http://www.example.com")
|
||||
webrat_session.redirected_to.should == "http://www.example.com"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user