Skip to content
This repository
Browse code

Added access to remote_addr in integration tests (closes #4266) [Chad…

… Fowler]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3908 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit fe94ba10037088549d4fc619b9e196dfad1dff46 1 parent c651545
David Heinemeier Hansson authored March 18, 2006
15  actionpack/lib/action_controller/integration_test.rb
@@ -26,7 +26,10 @@ class Session
26 26
       attr_reader :path
27 27
 
28 28
       # The hostname used in the last request.
29  
-      attr_reader :host
  29
+      attr_accessor :host
  30
+
  31
+      # The remote_addr used in the last request.
  32
+      attr_accessor :remote_addr
30 33
 
31 34
       # A map of the cookies returned by the last response, and which will be
32 35
       # sent with the next request.
@@ -61,7 +64,8 @@ def reset!
61 64
         @cookies = {}
62 65
         @controller = @request = @response = nil
63 66
       
64  
-        host! "www.example.test"
  67
+        self.host        = "www.example.test"
  68
+        self.remote_addr = "127.0.0.1"
65 69
 
66 70
         unless @named_routes_configured
67 71
           # install the named routes in this session instance.
@@ -99,10 +103,6 @@ def host!(name)
99 103
         @host = name
100 104
       end
101 105
 
102  
-      # To make setting the host more natural when using a session object
103  
-      # directly: foo.host = "blah"
104  
-      alias_method :host=, :host!
105  
-
106 106
       # Follow a single redirect response. If the last response was not a
107 107
       # redirect, an exception will be raised. Otherwise, the redirect is
108 108
       # performed on the location header.
@@ -204,6 +204,7 @@ def process(method, path, parameters=nil, headers=nil)
204 204
             "REQUEST_METHOD" => method.to_s.upcase,
205 205
             "REQUEST_URI"    => path,
206 206
             "HTTP_HOST"      => host,
  207
+            "REMOTE_ADDR"    => remote_addr,
207 208
             "SERVER_PORT"    => (https? ? "443" : "80"),
208 209
             "CONTENT_TYPE"   => "application/x-www-form-urlencoded",
209 210
             "CONTENT_LENGTH" => data ? data.length.to_s : nil,
@@ -429,7 +430,7 @@ def run(*args) #:nodoc:
429 430
     # TestCase, IntegrationTest has already been defined and cannot inherit
430 431
     # changes to those variables. So, we make those two attributes copy-on-write.
431 432
 
432  
-    class<<self
  433
+    class << self
433 434
       def use_transactional_fixtures=(flag) #:nodoc:
434 435
         @_use_transactional_fixtures = true
435 436
         @use_transactional_fixtures = flag

0 notes on commit fe94ba1

Please sign in to comment.
Something went wrong with that request. Please try again.