lets follow redirects that are on the same domain but a different subdomain...
This commit is contained in:
parent
c06fa90864
commit
ce36e5890f
@ -125,8 +125,16 @@ For example:
|
||||
response_code / 100 == 3
|
||||
end
|
||||
|
||||
def internal_redirect? #:nodoc:
|
||||
redirect? && current_host == response_location_host
|
||||
# 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
|
||||
current_host_domain = current_host.split('.')[-2..-1].join('.') rescue current_host
|
||||
response_location_host_domain = response_location_host.split('.')[-2..-1].join('.') rescue response_location_host
|
||||
current_host_domain == response_location_host_domain
|
||||
end
|
||||
|
||||
def exception_caught? #:nodoc:
|
||||
|
@ -159,6 +159,13 @@ describe Webrat::Session do
|
||||
webrat_session.internal_redirect?.should be_true
|
||||
end
|
||||
|
||||
it "should return true if the last response was a redirect and the hosts are the same but the subdomains are different" do
|
||||
webrat_session.stub!(:redirect? => true)
|
||||
webrat_session.stub!(:current_url => "http://example.com")
|
||||
webrat_session.stub!(:response_location => "http://myName.example.com")
|
||||
webrat_session.internal_redirect?.should be_true
|
||||
end
|
||||
|
||||
it "should return false if the last response was not a redirect" do
|
||||
webrat_session.stub!(:redirect? => false)
|
||||
webrat_session.internal_redirect?.should be_false
|
||||
@ -170,5 +177,13 @@ describe Webrat::Session do
|
||||
webrat_session.stub!(:response_location => "http://google.com")
|
||||
webrat_session.internal_redirect?.should be_false
|
||||
end
|
||||
|
||||
it "should return false if the last response was a redirect but the host of the current_url doesn't matches that of the response location, but they have the same subdomain" do
|
||||
webrat_session.stub!(:redirect? => true)
|
||||
webrat_session.stub!(:current_url => "http://login.example.com")
|
||||
webrat_session.stub!(:response_location => "http://login.google.com")
|
||||
webrat_session.internal_redirect?.should be_false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user