aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 03:27:37 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-18 03:27:37 +0000
commitfe94ba10037088549d4fc619b9e196dfad1dff46 (patch)
treeb545cfd04b6ee54b01f738e1f23b623d9ddf2138 /actionpack/lib
parentc6515451dc0a7f59ecbb0c76dad244f1248d03ee (diff)
downloadrails-fe94ba10037088549d4fc619b9e196dfad1dff46.tar.gz
rails-fe94ba10037088549d4fc619b9e196dfad1dff46.tar.bz2
rails-fe94ba10037088549d4fc619b9e196dfad1dff46.zip
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
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/integration_test.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/integration_test.rb b/actionpack/lib/action_controller/integration_test.rb
index 4569ee6ebd..fd9f848f5e 100644
--- a/actionpack/lib/action_controller/integration_test.rb
+++ b/actionpack/lib/action_controller/integration_test.rb
@@ -26,7 +26,10 @@ module ActionController
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 @@ module ActionController
@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 @@ module ActionController
@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 @@ module ActionController
"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 @@ module ActionController
# 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