From fe94ba10037088549d4fc619b9e196dfad1dff46 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 18 Mar 2006 03:27:37 +0000 Subject: 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 --- actionpack/lib/action_controller/integration_test.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'actionpack/lib/action_controller/integration_test.rb') 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<