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
|
response_code / 100 == 3
|
||||||
end
|
end
|
||||||
|
|
||||||
# def internal_redirect? #:nodoc:
|
|
||||||
# redirect? && current_host == response_location_host
|
|
||||||
# end
|
|
||||||
|
|
||||||
def internal_redirect?
|
def internal_redirect?
|
||||||
return false unless redirect?
|
return false unless redirect?
|
||||||
#should keep internal_redirects if the subdomain changes
|
#should keep internal_redirects if the subdomain changes
|
||||||
@ -137,6 +133,11 @@ For example:
|
|||||||
current_host_domain == response_location_host_domain
|
current_host_domain == response_location_host_domain
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#easy helper to pull out where we were redirected to
|
||||||
|
def redirected_to
|
||||||
|
redirect? ? response_location : nil
|
||||||
|
end
|
||||||
|
|
||||||
def exception_caught? #:nodoc:
|
def exception_caught? #:nodoc:
|
||||||
response_body =~ /Exception caught/
|
response_body =~ /Exception caught/
|
||||||
end
|
end
|
||||||
|
@ -184,6 +184,24 @@ describe Webrat::Session do
|
|||||||
webrat_session.stub!(:response_location => "http://login.google.com")
|
webrat_session.stub!(:response_location => "http://login.google.com")
|
||||||
webrat_session.internal_redirect?.should be_false
|
webrat_session.internal_redirect?.should be_false
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user