diff options
-rw-r--r-- | actionpack/lib/action_controller/metal/responder.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/handlers.rb | 1 | ||||
-rw-r--r-- | actionpack/test/fixtures/with_format.json.erb | 1 | ||||
-rw-r--r-- | actionpack/test/template/render_test.rb | 13 | ||||
-rw-r--r-- | actionpack/test/template/template_test.rb | 2 |
6 files changed, 19 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index 4ad64bff20..daa1ddd65f 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -267,7 +267,7 @@ module ActionController #:nodoc: end def resource_errors - respond_to?("#{format}_resource_errors") ? send("#{format}_resource_errors") : resource.errors + respond_to?("#{format}_resource_errors", true) ? send("#{format}_resource_errors") : resource.errors end def json_resource_errors diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index edb3d427d5..644debd49c 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -163,6 +163,7 @@ module ActionView pieces = @virtual_path.split("/") name = pieces.pop partial = !!name.sub!(/^_/, "") + lookup.formats = @formats lookup.disable_cache do lookup.find_template(name, [ pieces.join('/') ], partial, @locals) end diff --git a/actionpack/lib/action_view/template/handlers.rb b/actionpack/lib/action_view/template/handlers.rb index 67978ada7e..4e22bec6cc 100644 --- a/actionpack/lib/action_view/template/handlers.rb +++ b/actionpack/lib/action_view/template/handlers.rb @@ -23,6 +23,7 @@ module ActionView #:nodoc: # and should return the rendered template as a String. def register_template_handler(extension, handler) @@template_handlers[extension.to_sym] = handler + @@template_extensions = nil end def template_handler_extensions diff --git a/actionpack/test/fixtures/with_format.json.erb b/actionpack/test/fixtures/with_format.json.erb new file mode 100644 index 0000000000..a7f480ab1d --- /dev/null +++ b/actionpack/test/fixtures/with_format.json.erb @@ -0,0 +1 @@ +<%= render :partial => 'missing', :formats => [:json] %> diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 5d3dc73ed2..e4ce756bf8 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -51,6 +51,13 @@ module RenderTestCases assert_match "<error>No Comment</error>", @view.render(:template => "comments/empty", :formats => [:xml]) end + def test_render_template_with_a_missing_partial_of_another_format + assert_raise ActionView::Template::Error, "Missing partial /missing with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder]}" do + @view.lookup_context.freeze_formats([:html]) + @view.render(:template => "with_format", :formats => [:json]) + end + end + def test_render_file_with_locale assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => [:de]) assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => :de) @@ -299,6 +306,12 @@ module RenderTestCases ActionView::Template.register_template_handler :foo, CustomHandler assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) end + + def test_render_knows_about_types_registered_when_extensions_are_checked_earlier_in_initialization + ActionView::Template::Handlers.extensions + ActionView::Template.register_template_handler :foo, CustomHandler + assert ActionView::Template::Handlers.extensions.include?(:foo) + end def test_render_ignores_templates_with_malformed_template_handlers ActiveSupport::Deprecation.silence do diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 3084527f70..63f1d3a6c0 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -11,6 +11,8 @@ class TestERBTemplate < ActiveSupport::TestCase def find_template(*args) end + + attr_writer :formats end class Context |