Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@dhh dhh authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 actionpack/lib/action_controller/integration_test.rb
View
15 actionpack/lib/action_controller/integration_test.rb
@@ -26,7 +26,10 @@ class Session
attr_reader :path
# The hostname used in the last request.
- attr_reader :host
+ attr_accessor :host
+
+ # The remote_addr used in the last request.
+ attr_accessor :remote_addr
# A map of the cookies returned by the last response, and which will be
# sent with the next request.
@@ -61,7 +64,8 @@ def reset!
@cookies = {}
@controller = @request = @response = nil
- host! "www.example.test"
+ self.host = "www.example.test"
+ self.remote_addr = "127.0.0.1"
unless @named_routes_configured
# install the named routes in this session instance.
@@ -99,10 +103,6 @@ def host!(name)
@host = name
end
- # To make setting the host more natural when using a session object
- # directly: foo.host = "blah"
- alias_method :host=, :host!
-
# Follow a single redirect response. If the last response was not a
# redirect, an exception will be raised. Otherwise, the redirect is
# performed on the location header.
@@ -204,6 +204,7 @@ def process(method, path, parameters=nil, headers=nil)
"REQUEST_METHOD" => method.to_s.upcase,
"REQUEST_URI" => path,
"HTTP_HOST" => host,
+ "REMOTE_ADDR" => remote_addr,
"SERVER_PORT" => (https? ? "443" : "80"),
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
"CONTENT_LENGTH" => data ? data.length.to_s : nil,
@@ -429,7 +430,7 @@ def run(*args) #:nodoc:
# TestCase, IntegrationTest has already been defined and cannot inherit
# changes to those variables. So, we make those two attributes copy-on-write.
- class<<self
+ class << self
def use_transactional_fixtures=(flag) #:nodoc:
@_use_transactional_fixtures = true
@use_transactional_fixtures = flag
Please sign in to comment.
Something went wrong with that request. Please try again.