提交 a29c681d 编写于 作者: J José Valim

Merge pull request #4119 from lucasmazza/render_without_options

raises an ArgumentError on TemplateRenderer#determine_template
......@@ -25,6 +25,8 @@ def determine_template(options) #:nodoc:
elsif options.key?(:template)
options[:template].respond_to?(:render) ?
options[:template] : find_template(options[:template], options[:prefixes], false, keys, @details)
else
raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file or :text option."
end
end
......
......@@ -20,6 +20,13 @@ def setup_view(paths)
assert_equal ORIGINAL_LOCALES, I18n.available_locales.map {|l| l.to_s }.sort
end
def test_render_without_options
@view.render()
flunk "Render did not raise ArgumentError"
rescue ArgumentError => e
assert_match "You invoked render but did not give any of :partial, :template, :inline, :file or :text option.", e.message
end
def test_render_file
assert_equal "Hello world!", @view.render(:file => "test/hello_world")
end
......@@ -43,21 +50,21 @@ def test_render_template_with_format
assert_match "<h1>No Comment</h1>", @view.render(:template => "comments/empty", :formats => [:html])
assert_match "<error>No Comment</error>", @view.render(:template => "comments/empty", :formats => [:xml])
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)
end
def test_render_template_with_locale
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:template => "comments/empty", :locale => [:de])
end
def test_render_file_with_handlers
assert_equal "<h1>No Comment</h1>\n", @view.render(:file => "comments/empty", :handlers => [:builder])
assert_equal "<h1>No Comment</h1>\n", @view.render(:file => "comments/empty", :handlers => :builder)
end
def test_render_template_with_handlers
assert_equal "<h1>No Comment</h1>\n", @view.render(:template => "comments/empty", :handlers => [:builder])
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册