aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/base/mime_responds.rb7
-rw-r--r--actionpack/lib/action_controller/new_base/base.rb20
-rw-r--r--actionpack/lib/action_controller/new_base/renderer.rb20
-rw-r--r--actionpack/lib/action_controller/testing/process2.rb1
4 files changed, 31 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb
index e560376e0d..3c17dda1a1 100644
--- a/actionpack/lib/action_controller/base/mime_responds.rb
+++ b/actionpack/lib/action_controller/base/mime_responds.rb
@@ -122,12 +122,11 @@ module ActionController #:nodoc:
# TODO: Remove this when new base is merged in
if defined?(Http)
@controller.formats = [mime_type.to_sym]
- @controller.template.formats = [mime_type.to_sym]
- else
- @controller.template.formats = [mime_type.to_sym]
- @response.content_type = mime_type.to_s
end
+ @controller.template.formats = [mime_type.to_sym]
+ @response.content_type = mime_type.to_s
+
block_given? ? block.call : @controller.send(:render, :action => @controller.action_name)
end
end
diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb
index 142699326e..b8674d5099 100644
--- a/actionpack/lib/action_controller/new_base/base.rb
+++ b/actionpack/lib/action_controller/new_base/base.rb
@@ -70,7 +70,7 @@ module ActionController
end
end
- def render_to_body(action = nil, options = {})
+ def _normalize_options(action = nil, options = {})
if action.is_a?(Hash)
options, action = action, nil
elsif action.is_a?(String) || action.is_a?(Symbol)
@@ -87,9 +87,21 @@ module ActionController
if options.key?(:action) && options[:action].to_s.index("/")
options[:template] = options.delete(:action)
end
-
- # options = {:template => options.to_s} if options.is_a?(String) || options.is_a?(Symbol)
- super(options) || " "
+ options
+ end
+
+ def render(action = nil, options = {})
+ options = _normalize_options(action, options)
+ super(options)
+ end
+
+ def render_to_string(action = nil, options = {})
+ options = _normalize_options(action, options)
+ super(options)
+ end
+
+ def render_to_body(options)
+ super || [" "]
end
# Redirects the browser to the target specified in +options+. This parameter can take one of three forms:
diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb
index 81685ca9d6..840168397d 100644
--- a/actionpack/lib/action_controller/new_base/renderer.rb
+++ b/actionpack/lib/action_controller/new_base/renderer.rb
@@ -14,6 +14,16 @@ module ActionController
super
end
+ def render(options)
+ super
+ options[:_template] ||= _action_view._partial
+ response.content_type ||= begin
+ mime = options[:_template].mime_type
+ formats.include?(mime && mime.to_sym) || formats.include?(:all) ? mime : Mime::Type.lookup_by_extension(formats.first)
+ end
+ response_body
+ end
+
def render_to_body(options)
_process_options(options)
@@ -35,15 +45,7 @@ module ActionController
options[:_prefix] = _prefix
end
- ret = super(options)
-
- options[:_template] ||= _action_view._partial
- response.content_type ||= begin
- mime = options[:_template].mime_type
- mime &&= mime.to_sym
- formats.include?(mime) ? mime : formats.first
- end
- ret
+ super
end
private
diff --git a/actionpack/lib/action_controller/testing/process2.rb b/actionpack/lib/action_controller/testing/process2.rb
index 6a95e638cd..bee82c280e 100644
--- a/actionpack/lib/action_controller/testing/process2.rb
+++ b/actionpack/lib/action_controller/testing/process2.rb
@@ -40,6 +40,7 @@ module ActionController
@request.recycle!
@response.recycle!
@controller.response_body = nil
+ @controller.formats = nil
@html_document = nil
@request.env['REQUEST_METHOD'] = http_method