aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-02 15:21:19 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-02 15:21:19 -0700
commit186fee48c796b104b76ef69decb32ef396f435db (patch)
tree9f8b8c8c83af7bd2913c1283f51fd3c3492fea82 /actionpack/lib/action_dispatch
parent945bf9c254b5bfb56df874c1a3f7f0f1e89dc8b8 (diff)
parent24affdc88c4a4af03ce1ec5b23c3def18b90effe (diff)
downloadrails-186fee48c796b104b76ef69decb32ef396f435db.tar.gz
rails-186fee48c796b104b76ef69decb32ef396f435db.tar.bz2
rails-186fee48c796b104b76ef69decb32ef396f435db.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb4
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/response.rb9
-rw-r--r--actionpack/lib/action_dispatch/testing/test_request.rb5
-rw-r--r--actionpack/lib/action_dispatch/testing/test_response.rb24
4 files changed, 20 insertions, 22 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 2b969323ca..133b4f7335 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -34,8 +34,6 @@ module ActionDispatch # :nodoc:
DEFAULT_HEADERS = { "Cache-Control" => "no-cache" }
attr_accessor :request
- attr_accessor :redirected_to, :redirected_to_method_params
-
attr_writer :header
alias_method :headers=, :header=
@@ -187,7 +185,7 @@ module ActionDispatch # :nodoc:
@writer = lambda { |x| callback.call(x) }
@body.call(self, self)
else
- @body.each(&callback)
+ @body.each { |part| callback.call(part.to_s) }
end
@writer = callback
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index a72ce9084f..92e3da580e 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -60,14 +60,9 @@ module ActionDispatch
validate_request!
assert_response(:redirect, message)
- return true if options == @response.redirected_to
+ return true if options == @response.location
- # Support partial arguments for hash redirections
- if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
- return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
- end
-
- redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
+ redirected_to_after_normalisation = normalize_argument_to_redirection(@response.location)
options_after_normalisation = normalize_argument_to_redirection(options)
if redirected_to_after_normalisation != options_after_normalisation
diff --git a/actionpack/lib/action_dispatch/testing/test_request.rb b/actionpack/lib/action_dispatch/testing/test_request.rb
index 5d8cd7e619..20288aa7a5 100644
--- a/actionpack/lib/action_dispatch/testing/test_request.rb
+++ b/actionpack/lib/action_dispatch/testing/test_request.rb
@@ -16,6 +16,7 @@ module ActionDispatch
def env
write_cookies!
+ delete_nil_values!
super
end
@@ -74,5 +75,9 @@ module ActionDispatch
@env['HTTP_COOKIE'] = @cookies.map { |name, value| "#{name}=#{value};" }.join(' ')
end
end
+
+ def delete_nil_values!
+ @env.delete_if { |k, v| v.nil? }
+ end
end
end
diff --git a/actionpack/lib/action_dispatch/testing/test_response.rb b/actionpack/lib/action_dispatch/testing/test_response.rb
index 50c6d85828..c35982e075 100644
--- a/actionpack/lib/action_dispatch/testing/test_response.rb
+++ b/actionpack/lib/action_dispatch/testing/test_response.rb
@@ -1,4 +1,10 @@
module ActionDispatch
+ # Integration test methods such as ActionController::Integration::Session#get
+ # and ActionController::Integration::Session#post return objects of class
+ # TestResponse, which represent the HTTP response results of the requested
+ # controller actions.
+ #
+ # See Response for more information on controller response objects.
class TestResponse < Response
def self.from_response(response)
new.tap do |resp|
@@ -87,6 +93,12 @@ module ActionDispatch
ActiveSupport::Deprecation.warn("response.has_template_object? has been deprecated. Use tempate.assigns[name].nil? instead", caller)
!template_objects[name].nil?
end
+
+ # Returns binary content (downloadable file), converted to a String
+ def binary_content
+ ActiveSupport::Deprecation.warn("response.binary_content has been deprecated. Use response.body instead", caller)
+ body
+ end
end
include DeprecatedHelpers
@@ -115,17 +127,5 @@ module ActionDispatch
def client_error?
(400..499).include?(response_code)
end
-
- # Returns binary content (downloadable file), converted to a String
- def binary_content
- raise "Response body is not a Proc: #{body_parts.inspect}" unless body_parts.kind_of?(Proc)
- require 'stringio'
-
- sio = StringIO.new
- body_parts.call(self, sio)
-
- sio.rewind
- sio.read
- end
end
end