From f7e56a3ab6f54ae5b9b021212b3d4e98eae6eeec Mon Sep 17 00:00:00 2001 From: Matthew Daubert Date: Tue, 25 Oct 2011 15:11:45 -0400 Subject: Fix deprecation warnings in action pack test suite due to passing template formats in the template name. --- actionpack/test/template/render_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/test/template/render_test.rb') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 0ef3239f83..77659918f7 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -429,7 +429,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase if '1.9'.respond_to?(:force_encoding) def test_render_utf8_template_with_magic_comment with_external_encoding Encoding::ASCII_8BIT do - result = @view.render(:file => "test/utf8_magic.html", :layouts => "layouts/yield") + result = @view.render(:file => "test/utf8_magic", :formats => [:html], :layouts => "layouts/yield") assert_equal Encoding::UTF_8, result.encoding assert_equal "\nРусский \nтекст\n\nUTF-8\nUTF-8\nUTF-8\n", result end @@ -437,7 +437,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase def test_render_utf8_template_with_default_external_encoding with_external_encoding Encoding::UTF_8 do - result = @view.render(:file => "test/utf8.html", :layouts => "layouts/yield") + result = @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") assert_equal Encoding::UTF_8, result.encoding assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result end @@ -446,7 +446,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase def test_render_utf8_template_with_incompatible_external_encoding with_external_encoding Encoding::SHIFT_JIS do begin - @view.render(:file => "test/utf8.html", :layouts => "layouts/yield") + @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") flunk 'Should have raised incompatible encoding error' rescue ActionView::Template::Error => error assert_match 'Your template was not saved as valid Shift_JIS', error.original_exception.message @@ -457,7 +457,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase def test_render_utf8_template_with_partial_with_incompatible_encoding with_external_encoding Encoding::SHIFT_JIS do begin - @view.render(:file => "test/utf8_magic_with_bare_partial.html", :layouts => "layouts/yield") + @view.render(:file => "test/utf8_magic_with_bare_partial", :formats => [:html], :layouts => "layouts/yield") flunk 'Should have raised incompatible encoding error' rescue ActionView::Template::Error => error assert_match 'Your template was not saved as valid Shift_JIS', error.original_exception.message -- cgit v1.2.3 From 771635e858e486e1e9f2d181b710d81205e6bb4e Mon Sep 17 00:00:00 2001 From: Tobias Svensson Date: Sat, 19 Nov 2011 13:02:56 +0000 Subject: Meaningful errors for unexpected partial arguments. Fixes #3573 --- actionpack/test/template/render_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/template/render_test.rb') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 77659918f7..c29519276d 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -142,6 +142,13 @@ module RenderTestCases "and is followed by any combinations of letters, numbers, or underscores.", e.message end + def test_render_partial_with_incompatible_object + @view.render(:partial => nil) + flunk "Render did not raise ArgumentError" + rescue ArgumentError => e + assert_equal "'#{nil.inspect}' is not an ActiveModel-compatible object that returns a valid partial path.", e.message + end + def test_render_partial_with_errors @view.render(:partial => "test/raise") flunk "Render did not raise Template::Error" -- cgit v1.2.3 From 6c57177f2c7f4f934716d588545902d5fc00fa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 20 Dec 2011 15:12:38 +0100 Subject: Remove deprecation warnings from Action Pack. --- actionpack/test/template/render_test.rb | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'actionpack/test/template/render_test.rb') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index c29519276d..2ba86306f4 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -146,7 +146,7 @@ module RenderTestCases @view.render(:partial => nil) flunk "Render did not raise ArgumentError" rescue ArgumentError => e - assert_equal "'#{nil.inspect}' is not an ActiveModel-compatible object that returns a valid partial path.", e.message + assert_equal "'#{nil.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.", e.message end def test_render_partial_with_errors @@ -243,36 +243,6 @@ module RenderTestCases @controller_view.render(customers, :greeting => "Hello") end - class CustomerWithDeprecatedPartialPath - attr_reader :name - - def self.model_name - Struct.new(:partial_path).new("customers/customer") - end - - def initialize(name) - @name = name - end - end - - def test_render_partial_using_object_with_deprecated_partial_path - assert_deprecated(/#model_name.*#partial_path.*#to_partial_path/) do - assert_equal "Hello: nertzy", - @controller_view.render(CustomerWithDeprecatedPartialPath.new("nertzy"), :greeting => "Hello") - end - end - - def test_render_partial_using_collection_with_deprecated_partial_path - assert_deprecated(/#model_name.*#partial_path.*#to_partial_path/) do - customers = [ - CustomerWithDeprecatedPartialPath.new("nertzy"), - CustomerWithDeprecatedPartialPath.new("peeja") - ] - assert_equal "Hello: nertzyHello: peeja", - @controller_view.render(customers, :greeting => "Hello") - end - end - # TODO: The reason for this test is unclear, improve documentation def test_render_partial_and_fallback_to_layout assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" }) -- cgit v1.2.3 From 9fbaf9f0777485b32ae12d0cc261695b9bb26eea Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Wed, 21 Dec 2011 17:31:53 -0200 Subject: raises an ArgumentError if no valid options are given to TemplateRenderer#determine_template --- actionpack/test/template/render_test.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'actionpack/test/template/render_test.rb') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 2ba86306f4..761bcf61f2 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -20,6 +20,13 @@ module RenderTestCases 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 @@ module RenderTestCases assert_match "

No Comment

", @view.render(:template => "comments/empty", :formats => [:html]) assert_match "No Comment", @view.render(:template => "comments/empty", :formats => [:xml]) end - + def test_render_file_with_locale assert_equal "

Kein Kommentar

", @view.render(:file => "comments/empty", :locale => [:de]) assert_equal "

Kein Kommentar

", @view.render(:file => "comments/empty", :locale => :de) end - + def test_render_template_with_locale assert_equal "

Kein Kommentar

", @view.render(:template => "comments/empty", :locale => [:de]) end - + def test_render_file_with_handlers assert_equal "

No Comment

\n", @view.render(:file => "comments/empty", :handlers => [:builder]) assert_equal "

No Comment

\n", @view.render(:file => "comments/empty", :handlers => :builder) end - + def test_render_template_with_handlers assert_equal "

No Comment

\n", @view.render(:template => "comments/empty", :handlers => [:builder]) end -- cgit v1.2.3 From 1e9e88fcd335c7d5a99159d592c3e1b605510a16 Mon Sep 17 00:00:00 2001 From: Sergey Nartimov Date: Sun, 25 Dec 2011 14:34:58 +0300 Subject: remove checks for encodings availability --- actionpack/test/template/render_test.rb | 70 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'actionpack/test/template/render_test.rb') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 761bcf61f2..5d3dc73ed2 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -410,51 +410,49 @@ class LazyViewRenderTest < ActiveSupport::TestCase GC.start end - if '1.9'.respond_to?(:force_encoding) - def test_render_utf8_template_with_magic_comment - with_external_encoding Encoding::ASCII_8BIT do - result = @view.render(:file => "test/utf8_magic", :formats => [:html], :layouts => "layouts/yield") - assert_equal Encoding::UTF_8, result.encoding - assert_equal "\nРусский \nтекст\n\nUTF-8\nUTF-8\nUTF-8\n", result - end + def test_render_utf8_template_with_magic_comment + with_external_encoding Encoding::ASCII_8BIT do + result = @view.render(:file => "test/utf8_magic", :formats => [:html], :layouts => "layouts/yield") + assert_equal Encoding::UTF_8, result.encoding + assert_equal "\nРусский \nтекст\n\nUTF-8\nUTF-8\nUTF-8\n", result end + end - def test_render_utf8_template_with_default_external_encoding - with_external_encoding Encoding::UTF_8 do - result = @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") - assert_equal Encoding::UTF_8, result.encoding - assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result - end + def test_render_utf8_template_with_default_external_encoding + with_external_encoding Encoding::UTF_8 do + result = @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") + assert_equal Encoding::UTF_8, result.encoding + assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result end + end - def test_render_utf8_template_with_incompatible_external_encoding - with_external_encoding Encoding::SHIFT_JIS do - begin - @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") - flunk 'Should have raised incompatible encoding error' - rescue ActionView::Template::Error => error - assert_match 'Your template was not saved as valid Shift_JIS', error.original_exception.message - end + def test_render_utf8_template_with_incompatible_external_encoding + with_external_encoding Encoding::SHIFT_JIS do + begin + @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") + flunk 'Should have raised incompatible encoding error' + rescue ActionView::Template::Error => error + assert_match 'Your template was not saved as valid Shift_JIS', error.original_exception.message end end + end - def test_render_utf8_template_with_partial_with_incompatible_encoding - with_external_encoding Encoding::SHIFT_JIS do - begin - @view.render(:file => "test/utf8_magic_with_bare_partial", :formats => [:html], :layouts => "layouts/yield") - flunk 'Should have raised incompatible encoding error' - rescue ActionView::Template::Error => error - assert_match 'Your template was not saved as valid Shift_JIS', error.original_exception.message - end + def test_render_utf8_template_with_partial_with_incompatible_encoding + with_external_encoding Encoding::SHIFT_JIS do + begin + @view.render(:file => "test/utf8_magic_with_bare_partial", :formats => [:html], :layouts => "layouts/yield") + flunk 'Should have raised incompatible encoding error' + rescue ActionView::Template::Error => error + assert_match 'Your template was not saved as valid Shift_JIS', error.original_exception.message end end + end - def with_external_encoding(encoding) - old = Encoding.default_external - silence_warnings { Encoding.default_external = encoding } - yield - ensure - silence_warnings { Encoding.default_external = old } - end + def with_external_encoding(encoding) + old = Encoding.default_external + silence_warnings { Encoding.default_external = encoding } + yield + ensure + silence_warnings { Encoding.default_external = old } end end -- cgit v1.2.3