public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://gitrdoc.com/brynary/webrat/tree/master/
Clone URL: git://github.com/brynary/webrat.git
Properly set referer and redirect to proper location
joshknowles (author)
Sun Dec 28 17:53:33 -0800 2008
commit  4b6558e7e5c5b5cf9d7d6dae3368715c8d4b9d43
tree    af3383d741c1598c950c94a9916ce497566188c1
parent  29274f9b4b49f98a6d69f43d1b3a309146912bc3
...
90
91
92
93
94
95
 
 
 
 
 
 
96
97
98
...
90
91
92
 
93
 
94
95
96
97
98
99
100
101
102
0
@@ -90,9 +90,13 @@ module ActionController #:nodoc:
0
 
0
       def follow_redirect_with_headers(h = {})
0
         raise "Not a redirect! #{@status} #{@status_message}" unless redirect?
0
-        h['HTTP_REFERER'] = current_url if current_url
0
 
0
-        get(interpret_uri(headers["location"].first), {}, h)
0
+        h['HTTP_REFERER'] = request.url
0
+
0
+        location = headers["location"]
0
+        location = location.first if location.is_a?(Array)
0
+        
0
+        get(location, {}, h)
0
         status
0
       end
0
     end
...
131
132
133
 
134
135
136
...
167
168
169
170
171
172
173
174
...
131
132
133
134
135
136
137
...
168
169
170
 
 
171
172
173
0
@@ -131,6 +131,7 @@ describe ActionController::Integration::Session do
0
   before :each do
0
     Webrat.configuration.mode = :rails
0
     @integration_session = ActionController::Integration::Session.new
0
+    @integration_session.stub!(:request => mock("request", :url => "http://source.url/"))
0
     @integration_session.stub!(:response => mock("response"))
0
   end
0
 
0
@@ -167,8 +168,6 @@ describe ActionController::Integration::Session do
0
     end
0
 
0
     it "should set the HTTP referer header" do
0
-      @integration_session.stub!(:current_url).and_return "http://source.url/"
0
-
0
       headers = {}
0
 
0
       @integration_session.follow_redirect_with_headers(headers)

Comments