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
This commit is contained in:
David Heinemeier Hansson 2006-03-18 03:27:37 +00:00
parent c6515451dc
commit fe94ba1003

@ -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