diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 3009d8cdfc..e3690577e1 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -386,11 +386,6 @@ def formats [:"*/*"] end - # Refactor out all mailer_name - def _prefix - mailer_name - end - class << self attr_writer :mailer_name diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index f4f1d41360..8293e79b0a 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -195,7 +195,7 @@ def _layout_for_option(name, details) def _determine_template(options) super - return if (options.key?(:text) || options.key?(:inline) || options.key?(:partial)) && !options.key?(:layout) + return unless (options.keys & [:text, :inline, :partial]).empty? || options.key?(:layout) layout = options.key?(:layout) ? options[:layout] : :default options[:_layout] = _layout_for_option(layout, options[:_template].details) end diff --git a/actionpack/lib/abstract_controller/rendering_controller.rb b/actionpack/lib/abstract_controller/rendering_controller.rb index 07deda77a2..0aae2b18e9 100644 --- a/actionpack/lib/abstract_controller/rendering_controller.rb +++ b/actionpack/lib/abstract_controller/rendering_controller.rb @@ -118,9 +118,6 @@ def _determine_template(options) options[:_template_name] = options[:template] elsif options.key?(:file) options[:_template_name] = options[:file] - elsif !options.key?(:partial) - options[:_template_name] ||= options[:action] - options[:_prefix] = _prefix end name = (options[:_template_name] || action_name).to_s @@ -138,10 +135,6 @@ def template_exists?(name, details, options) view_paths.exists?(name, details, options[:_prefix], options[:_partial]) end - def _prefix - self.class.name.underscore - end - def with_template_cache(name) yield end diff --git a/actionpack/lib/action_controller/metal/rendering_controller.rb b/actionpack/lib/action_controller/metal/rendering_controller.rb index 9e8bc82385..c5ade26702 100644 --- a/actionpack/lib/action_controller/metal/rendering_controller.rb +++ b/actionpack/lib/action_controller/metal/rendering_controller.rb @@ -65,6 +65,15 @@ def _prefix controller_path end + def _determine_template(options) + if (options.keys & [:partial, :file, :template, :text, :inline]).empty? + options[:_template_name] ||= options[:action] + options[:_prefix] = _prefix + end + + super + end + def format_for_text formats.first end diff --git a/actionpack/test/abstract/render_test.rb b/actionpack/test/abstract/render_test.rb new file mode 100644 index 0000000000..45a4763fe4 --- /dev/null +++ b/actionpack/test/abstract/render_test.rb @@ -0,0 +1,88 @@ +require 'abstract_unit' + +module AbstractController + module Testing + + class ControllerRenderer < AbstractController::Base + include AbstractController::RenderingController + + self.view_paths = [ActionView::FixtureResolver.new( + "default.erb" => "With Default", + "template.erb" => "With Template", + "some/file.erb" => "With File", + "template_name.erb" => "With Template Name" + )] + + def template + render :template => "template" + end + + def file + render :file => "some/file" + end + + def inline + render :inline => "With <%= :Inline %>" + end + + def text + render :text => "With Text" + end + + def default + render + end + + def template_name + render :_template_name => :template_name + end + + def object + render :_template => ActionView::TextTemplate.new("With Object") + end + end + + class TestRenderer < ActiveSupport::TestCase + + def setup + @controller = ControllerRenderer.new + end + + def test_render_template + @controller.process(:template) + assert_equal "With Template", @controller.response_body + end + + def test_render_file + @controller.process(:file) + assert_equal "With File", @controller.response_body + end + + def test_render_inline + @controller.process(:inline) + assert_equal "With Inline", @controller.response_body + end + + def test_render_text + @controller.process(:text) + assert_equal "With Text", @controller.response_body + end + + def test_render_default + @controller.process(:default) + assert_equal "With Default", @controller.response_body + end + + def test_render_template_name + @controller.process(:template_name) + assert_equal "With Template Name", @controller.response_body + end + + def test_render_object + @controller.process(:object) + assert_equal "With Object", @controller.response_body + end + + end + end +end