Support forwarding headers when following redirects when using the SinatraSession
This commit is contained in:
parent
d0504d9344
commit
89e9ea91e9
@ -11,10 +11,9 @@ module Webrat
|
|||||||
path, data, headers = *args
|
path, data, headers = *args
|
||||||
params = data.merge({:env => headers || {}})
|
params = data.merge({:env => headers || {}})
|
||||||
self.__send__("#{verb}_it", path, params)
|
self.__send__("#{verb}_it", path, params)
|
||||||
follow! while @response.redirect?
|
get_it(@response.location, params) while @response.redirect?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,6 +29,16 @@ describe Webrat::SinatraSession do
|
|||||||
@sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
|
@sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
|
||||||
@sinatra_session.delete("url", {}, "headers")
|
@sinatra_session.delete("url", {}, "headers")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should forward headers when following redirects" do
|
||||||
|
@response.should_receive(:redirect?).twice.and_return(true, false)
|
||||||
|
@response.should_receive(:location).and_return("redirect url")
|
||||||
|
|
||||||
|
@sinatra_session.should_receive(:get_it).with("original url", { :env => "headers" })
|
||||||
|
@sinatra_session.should_receive(:get_it).with("redirect url", { :env => "headers" })
|
||||||
|
|
||||||
|
@sinatra_session.get("original url", {}, "headers")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Hack required to reset configuration mode to play nice with other specs that depend on this being rails
|
# Hack required to reset configuration mode to play nice with other specs that depend on this being rails
|
||||||
|
Loading…
Reference in New Issue
Block a user