From 1c94ba03328775a79541e3240ff2469d237b9f3b Mon Sep 17 00:00:00 2001 From: Brian Cardarella Date: Fri, 29 Jul 2011 12:08:35 -0400 Subject: Instead of removing the instance variable just set it to nil, resolves the warnings because of a missing instance variable --- actionpack/test/template/sprockets_helper_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index b9161b62c5..f4b5344d63 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -97,7 +97,7 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheets served without a controller in scope cannot access the request" do - remove_instance_variable("@controller") + @controller = nil @config.action_controller.asset_host = Proc.new do |asset, request| fail "This should not have been called." end @@ -107,7 +107,7 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheets served without a controller in do not use asset hosts when the default protocol is :request" do - remove_instance_variable("@controller") + @controller = nil @config.action_controller.asset_host = "assets-%d.example.com" @config.action_controller.default_asset_host_protocol = :request @config.action_controller.perform_caching = true -- cgit v1.2.3 From dc8773b19f61af2ba818d66923fc65e17bad6c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 1 Aug 2011 11:42:00 +0200 Subject: Rename new method to_path to to_partial_path to avoid conflicts with File#to_path and similar. --- actionpack/test/template/form_helper_test.rb | 2 +- actionpack/test/template/render_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 71a2c46d92..f898c22e1e 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1895,7 +1895,7 @@ class FormHelperTest < ActionView::TestCase path = nil form_for(@post, :builder => LabelledFormBuilder) do |f| - path = f.to_path + path = f.to_partial_path '' end diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 0b91e55091..6f02f8662d 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -214,14 +214,14 @@ module RenderTestCases end def test_render_partial_using_object_with_deprecated_partial_path - assert_deprecated(/#model_name.*#partial_path.*#to_path/) do + 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_path/) do + assert_deprecated(/#model_name.*#partial_path.*#to_partial_path/) do customers = [ CustomerWithDeprecatedPartialPath.new("nertzy"), CustomerWithDeprecatedPartialPath.new("peeja") -- cgit v1.2.3 From 54b83566ccb55ae4a9bdb163a6224fa946814457 Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Fri, 29 Jul 2011 17:43:05 -0700 Subject: fix stringify_keys destructive behavior for most FormTagHelper functions add four new tests to verify that the other three methods that called stringify_keys! are fixed. verified that the tests break in master without the code patch. Closes #2355 --- actionpack/test/template/form_tag_helper_test.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 979251bfd1..ad31812273 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -505,6 +505,30 @@ class FormTagHelperTest < ActionView::TestCase expected = %(
Hello world!
) assert_dom_equal expected, output_buffer end + + def test_text_area_tag_options_symbolize_keys_side_effects + options = { :option => "random_option" } + actual = text_area_tag "body", "hello world", options + assert_equal options, { :option => "random_option" } + end + + def test_submit_tag_options_symbolize_keys_side_effects + options = { :option => "random_option" } + actual = submit_tag "submit value", options + assert_equal options, { :option => "random_option" } + end + + def test_button_tag_options_symbolize_keys_side_effects + options = { :option => "random_option" } + actual = button_tag "button value", options + assert_equal options, { :option => "random_option" } + end + + def test_image_submit_tag_options_symbolize_keys_side_effects + options = { :option => "random_option" } + actual = image_submit_tag "submit source", options + assert_equal options, { :option => "random_option" } + end def protect_against_forgery? false -- cgit v1.2.3 From f0034c75d5a9bc5065652c2fedf39250a6f1847b Mon Sep 17 00:00:00 2001 From: Casebook Developer Date: Thu, 4 Aug 2011 13:34:47 -0400 Subject: ActionView::Helpers::TextHelper#simple_format should not change the text in place. Now it duplicates it. --- actionpack/test/template/text_helper_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index f7c3986bb1..02f9609483 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -48,10 +48,10 @@ class TextHelperTest < ActionView::TestCase assert_equal "

test with unsafe string

", simple_format(" test with unsafe string ", {}, :sanitize => false) end - def test_simple_format_should_not_change_the_frozen_text_passed + def test_simple_format_should_not_change_the_text_passed text = "Ok" text_clone = text.dup - simple_format(text.freeze) + simple_format(text) assert_equal text_clone, text end -- cgit v1.2.3 From ed5c6d254c9ef5d44a11159561fddde7a3033874 Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Thu, 4 Aug 2011 23:48:40 -0400 Subject: generate environment dependent asset digests If two different environments are configured to use the pipeline, but one has an extra step (such as compression) then without taking the environment into account you may end up serving wrong assets --- actionpack/test/template/sprockets_helper_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index f4b5344d63..dfa635335e 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -205,4 +205,17 @@ class SprocketsHelperTest < ActionView::TestCase stubs(:asset_environment).returns(assets) assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", "css") end + + test "alternate hash based on environment" do + assets = Sprockets::Environment.new + assets.version = 'development' + assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets")) + stubs(:asset_environment).returns(assets) + dev_path = asset_path("style", "css") + + assets.version = 'production' + prod_path = asset_path("style", "css") + + assert_not_equal prod_path, dev_path + end end -- cgit v1.2.3 From f9f423fa183aeddb8c65bc7974860d0c6c670427 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 9 Aug 2011 12:10:25 -0700 Subject: deprecating process_view_paths --- actionpack/test/template/compiled_templates_test.rb | 2 +- actionpack/test/template/render_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index 3f31edd5ce..8be0f452fb 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -42,7 +42,7 @@ class CompiledTemplatesTest < Test::Unit::TestCase def render_without_cache(*args) path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) - view_paths = ActionView::Base.process_view_paths(path) + view_paths = ActionView::PathSet.new([path]) ActionView::Base.new(view_paths, {}).render(*args) end diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 6f02f8662d..8a582030f6 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -380,7 +380,7 @@ class LazyViewRenderTest < ActiveSupport::TestCase # is not eager loaded def setup path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) - view_paths = ActionView::Base.process_view_paths(path) + view_paths = ActionView::PathSet.new([path]) assert_equal ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH), view_paths.first setup_view(view_paths) end -- cgit v1.2.3 From 895d64531d25a76c1de2d4fec9aba68c0ee8c104 Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Thu, 11 Aug 2011 00:30:45 -0700 Subject: fix destructive stringify_keys for label_tag --- actionpack/test/template/form_tag_helper_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index ad31812273..c8e47e4f71 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -530,6 +530,12 @@ class FormTagHelperTest < ActionView::TestCase assert_equal options, { :option => "random_option" } end + def test_image_label_tag_options_symbolize_keys_side_effects + options = { :option => "random_option" } + actual = label_tag "submit source", "title", options + assert_equal options, { :option => "random_option" } + end + def protect_against_forgery? false end -- cgit v1.2.3 From 45ccd648664d894ee2a6a8812193ae47a4db6418 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Mon, 15 Aug 2011 21:49:12 +0530 Subject: Unused variable removed. --- actionpack/test/template/form_tag_helper_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index ad31812273..eb569c7308 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -508,25 +508,25 @@ class FormTagHelperTest < ActionView::TestCase def test_text_area_tag_options_symbolize_keys_side_effects options = { :option => "random_option" } - actual = text_area_tag "body", "hello world", options + text_area_tag "body", "hello world", options assert_equal options, { :option => "random_option" } end def test_submit_tag_options_symbolize_keys_side_effects options = { :option => "random_option" } - actual = submit_tag "submit value", options + submit_tag "submit value", options assert_equal options, { :option => "random_option" } end def test_button_tag_options_symbolize_keys_side_effects options = { :option => "random_option" } - actual = button_tag "button value", options + button_tag "button value", options assert_equal options, { :option => "random_option" } end def test_image_submit_tag_options_symbolize_keys_side_effects options = { :option => "random_option" } - actual = image_submit_tag "submit source", options + image_submit_tag "submit source", options assert_equal options, { :option => "random_option" } end -- cgit v1.2.3 From 586a944ddd4d03e66dea1093306147594748037a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 16 Aug 2011 15:17:49 -0700 Subject: Tags with invalid names should also be stripped in order to prevent XSS attacks. Thanks Sascha Depold for the report. --- actionpack/test/template/html-scanner/sanitizer_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/html-scanner/sanitizer_test.rb b/actionpack/test/template/html-scanner/sanitizer_test.rb index 678cb9eeeb..62ad6be680 100644 --- a/actionpack/test/template/html-scanner/sanitizer_test.rb +++ b/actionpack/test/template/html-scanner/sanitizer_test.rb @@ -5,6 +5,13 @@ class SanitizerTest < ActionController::TestCase @sanitizer = nil # used by assert_sanitizer end + def test_strip_tags_with_quote + sanitizer = HTML::FullSanitizer.new + string = '<" hi' + + assert_equal ' hi', sanitizer.sanitize(string) + end + def test_strip_tags sanitizer = HTML::FullSanitizer.new assert_equal("<< Date: Thu, 18 Aug 2011 14:59:27 -0500 Subject: Debug assets by default in development and test environments --- actionpack/test/template/sprockets_helper_test.rb | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index dfa635335e..d303acad0f 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -141,6 +141,8 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript include tag" do + Rails.env.stubs(:test?).returns(false) + assert_match %r{}, javascript_include_tag(:application) @@ -151,11 +153,17 @@ class SprocketsHelperTest < ActionView::TestCase assert_equal '', javascript_include_tag("http://www.example.com/xmlhr") + assert_match %r{\n}, + javascript_include_tag("xmlhr", "extra") + + Rails.env.stubs(:test?).returns(true) + assert_match %r{\n}, - javascript_include_tag(:application, :debug => true) + javascript_include_tag(:application) + + assert_match %r{}, + javascript_include_tag(:application, :debug => false) - assert_match %r{\n}, - javascript_include_tag("xmlhr", "extra") end test "stylesheet path" do @@ -172,6 +180,8 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet link tag" do + Rails.env.stubs(:test?).returns(false) + assert_match %r{}, stylesheet_link_tag(:application) @@ -187,11 +197,17 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{}, stylesheet_link_tag("style", :media => "print") - assert_match %r{\n}, - stylesheet_link_tag(:application, :debug => true) - assert_match %r{\n}, stylesheet_link_tag("style", "extra") + + Rails.env.stubs(:test?).returns(true) + + assert_match %r{\n}, + stylesheet_link_tag(:application) + + assert_match %r{}, + stylesheet_link_tag(:application, :debug => false) + end test "alternate asset prefix" do -- cgit v1.2.3 From f6ceb944eaea525362db38aa990cac3e6f76ac5a Mon Sep 17 00:00:00 2001 From: Teng Siong Ong Date: Sun, 21 Aug 2011 15:14:45 -0500 Subject: fix escape_javascript for unicode character \u2028. --- actionpack/test/template/javascript_helper_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionpack/test/template/javascript_helper_test.rb index dd8b7b7cd5..bab9d42472 100644 --- a/actionpack/test/template/javascript_helper_test.rb +++ b/actionpack/test/template/javascript_helper_test.rb @@ -27,6 +27,7 @@ class JavaScriptHelperTest < ActionView::TestCase assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) assert_equal %(backslash\\\\test), escape_javascript( %(backslash\\test) ) assert_equal %(dont <\\/close> tags), escape_javascript(%(dont tags)) + assert_equal %(unicode 
 newline), escape_javascript(%(unicode \342\200\250 newline)) assert_equal %(dont <\\/close> tags), j(%(dont tags)) end -- cgit v1.2.3 From 18b2223b3290c4b3daa310edfc06b4d51161c312 Mon Sep 17 00:00:00 2001 From: "Andrey A.I. Sitnik" Date: Mon, 22 Aug 2011 09:36:36 +1100 Subject: Allow to debug assets by config.assets.debug --- actionpack/test/template/sprockets_helper_test.rb | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index d303acad0f..cac277cf11 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -141,8 +141,6 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript include tag" do - Rails.env.stubs(:test?).returns(false) - assert_match %r{}, javascript_include_tag(:application) @@ -156,14 +154,12 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, javascript_include_tag("xmlhr", "extra") - Rails.env.stubs(:test?).returns(true) + assert_match %r{\n}, + javascript_include_tag(:application, :debug => true) + @config.assets.debug = true assert_match %r{\n}, javascript_include_tag(:application) - - assert_match %r{}, - javascript_include_tag(:application, :debug => false) - end test "stylesheet path" do @@ -180,8 +176,6 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet link tag" do - Rails.env.stubs(:test?).returns(false) - assert_match %r{}, stylesheet_link_tag(:application) @@ -200,14 +194,12 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, stylesheet_link_tag("style", "extra") - Rails.env.stubs(:test?).returns(true) + assert_match %r{\n}, + stylesheet_link_tag(:application, :debug => true) + @config.assets.debug = true assert_match %r{\n}, stylesheet_link_tag(:application) - - assert_match %r{}, - stylesheet_link_tag(:application, :debug => false) - end test "alternate asset prefix" do -- cgit v1.2.3 From 13400ac289344dae002c77a3c2b820268f08745e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 23 Aug 2011 14:55:31 +0100 Subject: Ensure regexp and hash key are UTF-8 --- actionpack/test/template/javascript_helper_test.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionpack/test/template/javascript_helper_test.rb index bab9d42472..4b9c3c97b1 100644 --- a/actionpack/test/template/javascript_helper_test.rb +++ b/actionpack/test/template/javascript_helper_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'active_support/core_ext/string/encoding' class JavaScriptHelperTest < ActionView::TestCase tests ActionView::Helpers::JavaScriptHelper @@ -27,7 +28,11 @@ class JavaScriptHelperTest < ActionView::TestCase assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) assert_equal %(backslash\\\\test), escape_javascript( %(backslash\\test) ) assert_equal %(dont <\\/close> tags), escape_javascript(%(dont tags)) - assert_equal %(unicode 
 newline), escape_javascript(%(unicode \342\200\250 newline)) + if "ruby".encoding_aware? + assert_equal %(unicode 
 newline), escape_javascript(%(unicode \342\200\250 newline).force_encoding('UTF-8').encode!) + else + assert_equal %(unicode 
 newline), escape_javascript(%(unicode \342\200\250 newline)) + end assert_equal %(dont <\\/close> tags), j(%(dont tags)) end -- cgit v1.2.3 From d133fd6d290a4812a17cc58c0d7e5cd3895e23f6 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Tue, 23 Aug 2011 21:36:21 -0500 Subject: Debug assets shouldn't ignore media type for stylesheets. Closes #2625 --- actionpack/test/template/sprockets_helper_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index cac277cf11..b5a0e6cf04 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -200,6 +200,9 @@ class SprocketsHelperTest < ActionView::TestCase @config.assets.debug = true assert_match %r{\n}, stylesheet_link_tag(:application) + + assert_match %r{\n}, + stylesheet_link_tag(:application, :media => "print") end test "alternate asset prefix" do -- cgit v1.2.3 From 827cdae6fb5e21056b68ab8a89047ae82738871f Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Mon, 22 Aug 2011 23:19:25 -0500 Subject: Add config.allow_debugging option to determine if the debug_assets query param can be passed by user --- actionpack/test/template/sprockets_helper_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index cac277cf11..5b4023809d 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -157,6 +157,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, javascript_include_tag(:application, :debug => true) + @config.assets.allow_debugging = true @config.assets.debug = true assert_match %r{\n}, javascript_include_tag(:application) @@ -197,6 +198,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, stylesheet_link_tag(:application, :debug => true) + @config.assets.allow_debugging = true @config.assets.debug = true assert_match %r{\n}, stylesheet_link_tag(:application) -- cgit v1.2.3 From 651ef614f1934578886ca792bb5e3eca8b5d1b48 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Fri, 26 Aug 2011 11:29:05 +0530 Subject: Removed Unused Variable. --- actionpack/test/template/form_tag_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 091f4e65b7..6eae9bf846 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -532,7 +532,7 @@ class FormTagHelperTest < ActionView::TestCase def test_image_label_tag_options_symbolize_keys_side_effects options = { :option => "random_option" } - actual = label_tag "submit source", "title", options + label_tag "submit source", "title", options assert_equal options, { :option => "random_option" } end -- cgit v1.2.3 From f236e00189b5a6cf0cebac5c275f64d41d73428d Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Wed, 31 Aug 2011 12:47:33 -0500 Subject: Backport f443f9cb0c64 to master --- actionpack/test/template/sprockets_helper_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 6c1f97a44a..ae4cb1f0aa 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -30,6 +30,8 @@ class SprocketsHelperTest < ActionView::TestCase @config = config @config.action_controller ||= ActiveSupport::InheritableOptions.new @config.perform_caching = true + @config.assets.digest = true + @config.assets.compile = true end def url_for(*args) @@ -157,7 +159,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, javascript_include_tag(:application, :debug => true) - @config.assets.allow_debugging = true + @config.assets.compile = true @config.assets.debug = true assert_match %r{\n}, javascript_include_tag(:application) @@ -198,7 +200,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, stylesheet_link_tag(:application, :debug => true) - @config.assets.allow_debugging = true + @config.assets.compile = true @config.assets.debug = true assert_match %r{\n}, stylesheet_link_tag(:application) -- cgit v1.2.3 From fddf7ea1c1e520f33fa26fe340f3fc107bcc95c8 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Fri, 2 Sep 2011 18:20:10 +0400 Subject: current_page? returns false for non-GET requests --- actionpack/test/template/url_helper_test.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 78245c1f95..dbac2e1fc0 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -304,8 +304,8 @@ class UrlHelperTest < ActiveSupport::TestCase assert_equal "Showing", link_to_if(false, "Showing", url_hash) end - def request_for_url(url) - env = Rack::MockRequest.env_for("http://www.example.com#{url}") + def request_for_url(url, opts = {}) + env = Rack::MockRequest.env_for("http://www.example.com#{url}", opts) ActionDispatch::Request.new(env) end @@ -329,6 +329,12 @@ class UrlHelperTest < ActiveSupport::TestCase assert current_page?("http://www.example.com/?order=desc&page=1") end + def test_current_page_with_not_get_verb + @request = request_for_url("/events", :method => :post) + + assert !current_page?('/events') + end + def test_link_unless_current @request = request_for_url("/") -- cgit v1.2.3 From b84cee08c6129717d7c3291918f06f95cc9eb916 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 2 Sep 2011 21:35:24 +0700 Subject: Make `content_tag_for` and `div_for` accepts the array of records So instead of having to do this: @items.each do |item| content_tag_for(:li, item) do Title: <%= item.title %> end end You can now do this: content_tag_for(:li, @items) do |item| Title: <%= item.title %> end --- actionpack/test/template/record_tag_helper_test.rb | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 1ba14e8bc9..edc2689896 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -4,11 +4,12 @@ require 'controller/fake_models' class Post extend ActiveModel::Naming include ActiveModel::Conversion + attr_writer :id, :body def id - 45 + @id || 45 end def body - super || "What a wonderful world!" + super || @body || "What a wonderful world!" end end @@ -58,4 +59,23 @@ class RecordTagHelperTest < ActionView::TestCase actual = div_for(@post, :class => "bar") { concat @post.body } assert_dom_equal expected, actual end + + def test_content_tag_for_collection + post_1 = Post.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } + post_2 = Post.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true } + expected = %(
  • Hello!
  • \n
  • World!
  • ) + actual = content_tag_for(:li, [post_1, post_2]) { |post| concat post.body } + assert_dom_equal expected, actual + end + + def test_content_tag_for_collection_is_html_safe + end + + def test_div_for_collection + post_1 = Post.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } + post_2 = Post.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true } + expected = %(
    Hello!
    \n
    World!
    ) + actual = div_for([post_1, post_2]) { |post| concat post.body } + assert_dom_equal expected, actual + end end -- cgit v1.2.3 From fa0ebf4c98da483beb86da4e11f2a73729e3983a Mon Sep 17 00:00:00 2001 From: Ray Baxter Date: Sun, 4 Sep 2011 13:11:54 -0700 Subject: Tests shouldn't produce warnings --- actionpack/test/template/record_tag_helper_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index edc2689896..150e44b864 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -5,6 +5,11 @@ class Post extend ActiveModel::Naming include ActiveModel::Conversion attr_writer :id, :body + def initialize + @id = nil + @body = nil + super + end def id @id || 45 end -- cgit v1.2.3 From 4f8777333d6afe15f821f59691f95aa5003e48cb Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 5 Sep 2011 00:43:51 -0300 Subject: Remove empty test --- actionpack/test/template/record_tag_helper_test.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 150e44b864..81a1642ed8 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -73,9 +73,6 @@ class RecordTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end - def test_content_tag_for_collection_is_html_safe - end - def test_div_for_collection post_1 = Post.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } post_2 = Post.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true } -- cgit v1.2.3 From 24ee573d6ce8bb11f7eb62224feca5a87fdd2a69 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 5 Sep 2011 13:41:25 +0530 Subject: add blanks between methods --- actionpack/test/template/record_tag_helper_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 81a1642ed8..7d38b01c1b 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -5,14 +5,17 @@ class Post extend ActiveModel::Naming include ActiveModel::Conversion attr_writer :id, :body + def initialize @id = nil @body = nil super end + def id @id || 45 end + def body super || @body || "What a wonderful world!" end -- cgit v1.2.3 From ffe56f3b8c579b5f5dbf47ae1e5bb052a64d9783 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Mon, 5 Sep 2011 20:04:37 +0700 Subject: Make sure that result from content_tag_for with collection is html_safe Thank you @spastorino for catching the empty test in b84cee0, as I totally forgot that I still have to make it html_safe. --- actionpack/test/template/record_tag_helper_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 81a1642ed8..a892d7a326 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -80,4 +80,16 @@ class RecordTagHelperTest < ActionView::TestCase actual = div_for([post_1, post_2]) { |post| concat post.body } assert_dom_equal expected, actual end + + def test_content_tag_for_single_record_is_html_safe + result = div_for(@post, :class => "bar") { concat @post.body } + assert result.html_safe? + end + + def test_content_tag_for_collection_is_html_safe + post_1 = Post.new.tap { |post| post.id = 101; post.body = "Hello!"; post.persisted = true } + post_2 = Post.new.tap { |post| post.id = 102; post.body = "World!"; post.persisted = true } + result = content_tag_for(:li, [post_1, post_2]) { |post| concat post.body } + assert result.html_safe? + end end -- cgit v1.2.3 From c255e0eed5849ed7866d3c5999a4e04a0e625b9c Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 5 Sep 2011 06:10:12 -0700 Subject: Merge pull request #2799 from tomstuart/3-1-stable Never return stored content from content_for when a block is given --- actionpack/test/template/capture_helper_test.rb | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb index a9157e711c..13e2d5b595 100644 --- a/actionpack/test/template/capture_helper_test.rb +++ b/actionpack/test/template/capture_helper_test.rb @@ -46,6 +46,42 @@ class CaptureHelperTest < ActionView::TestCase assert_equal "bar", content_for(:bar) end + def test_content_for_with_multiple_calls + assert ! content_for?(:title) + content_for :title, 'foo' + content_for :title, 'bar' + assert_equal 'foobar', content_for(:title) + end + + def test_content_for_with_block + assert ! content_for?(:title) + content_for :title do + output_buffer << 'foo' + output_buffer << 'bar' + nil + end + assert_equal 'foobar', content_for(:title) + end + + def test_content_for_with_whitespace_block + assert ! content_for?(:title) + content_for :title, 'foo' + content_for :title do + output_buffer << " \n " + nil + end + content_for :title, 'bar' + assert_equal 'foobar', content_for(:title) + end + + def test_content_for_returns_nil_when_writing + assert ! content_for?(:title) + assert_equal nil, content_for(:title, 'foo') + assert_equal nil, content_for(:title) { output_buffer << 'bar'; nil } + assert_equal nil, content_for(:title) { output_buffer << " \n "; nil } + assert_equal 'foobar', content_for(:title) + end + def test_content_for_question_mark assert ! content_for?(:title) content_for :title, 'title' -- cgit v1.2.3 From abbd27fad8065323d0c3c5f2849499ce71e9a7d9 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Sat, 10 Sep 2011 12:22:29 +0530 Subject: No need to use here. It's already in whole_form block --- actionpack/test/template/form_helper_test.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index f898c22e1e..e36d032f6c 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -698,8 +698,7 @@ class FormHelperTest < ActionView::TestCase expected = whole_form("/posts/44", "edit_post_44" , "edit_post", :method => "put") do "" + - "" + - "" + "" end assert_dom_equal expected, output_buffer -- cgit v1.2.3 From 9279d1102c7d96810813cad0d0a666db0a549b1f Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sun, 11 Sep 2011 01:38:55 -0500 Subject: Set relative url root in assets when controller isn't available for Sprockets. Fix #2435 See https://github.com/rails/sass-rails/issues/42 for details --- actionpack/test/template/sprockets_helper_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index ae4cb1f0aa..105c641712 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -124,6 +124,13 @@ class SprocketsHelperTest < ActionView::TestCase asset_path("/images/logo.gif") end + test "asset path with relative url root when controller isn't present but relative_url_root is" do + @controller = nil + @config.action_controller.relative_url_root = "/collaboration/hieraki" + assert_equal "/collaboration/hieraki/images/logo.gif", + asset_path("/images/logo.gif") + end + test "javascript path" do assert_match %r{/assets/application-[0-9a-f]+.js}, asset_path(:application, "js") -- cgit v1.2.3 From da7f0426ec7b0aa053489633c2a8a3da6423654f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 14 Sep 2011 14:47:49 -0700 Subject: Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation. --- actionpack/test/template/sprockets_helper_test.rb | 44 ++++++++++++++--------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 105c641712..c0fb07a29b 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -41,6 +41,10 @@ class SprocketsHelperTest < ActionView::TestCase test "asset_path" do assert_match %r{/assets/logo-[0-9a-f]+.png}, asset_path("logo.png") + assert_match %r{/assets/logo-[0-9a-f]+.png}, + asset_path("logo.png", :digest => true) + assert_match %r{/assets/logo.png}, + asset_path("logo.png", :digest => false) end test "asset_path with root relative assets" do @@ -133,25 +137,29 @@ class SprocketsHelperTest < ActionView::TestCase test "javascript path" do assert_match %r{/assets/application-[0-9a-f]+.js}, - asset_path(:application, "js") + asset_path(:application, :ext => "js") assert_match %r{/assets/xmlhr-[0-9a-f]+.js}, - asset_path("xmlhr", "js") + asset_path("xmlhr", :ext => "js") assert_match %r{/assets/dir/xmlhr-[0-9a-f]+.js}, - asset_path("dir/xmlhr.js", "js") + asset_path("dir/xmlhr.js", :ext => "js") assert_equal "/dir/xmlhr.js", - asset_path("/dir/xmlhr", "js") + asset_path("/dir/xmlhr", :ext => "js") assert_equal "http://www.example.com/js/xmlhr", - asset_path("http://www.example.com/js/xmlhr", "js") + asset_path("http://www.example.com/js/xmlhr", :ext => "js") assert_equal "http://www.example.com/js/xmlhr.js", - asset_path("http://www.example.com/js/xmlhr.js", "js") + asset_path("http://www.example.com/js/xmlhr.js", :ext => "js") end test "javascript include tag" do assert_match %r{}, javascript_include_tag(:application) + assert_match %r{}, + javascript_include_tag(:application, :digest => true) + assert_match %r{}, + javascript_include_tag(:application, :digest => false) assert_match %r{}, javascript_include_tag("xmlhr") @@ -173,21 +181,25 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet path" do - assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, "css") + assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, :ext => "css") - assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", "css") - assert_match %r{/assets/dir/style-[0-9a-f]+.css}, asset_path("dir/style.css", "css") - assert_equal "/dir/style.css", asset_path("/dir/style.css", "css") + assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") + assert_match %r{/assets/dir/style-[0-9a-f]+.css}, asset_path("dir/style.css", :ext => "css") + assert_equal "/dir/style.css", asset_path("/dir/style.css", :ext => "css") assert_equal "http://www.example.com/css/style", - asset_path("http://www.example.com/css/style", "css") + asset_path("http://www.example.com/css/style", :ext => "css") assert_equal "http://www.example.com/css/style.css", - asset_path("http://www.example.com/css/style.css", "css") + asset_path("http://www.example.com/css/style.css", :ext => "css") end test "stylesheet link tag" do assert_match %r{}, stylesheet_link_tag(:application) + assert_match %r{}, + stylesheet_link_tag(:application, :digest => true) + assert_match %r{}, + stylesheet_link_tag(:application, :digest => false) assert_match %r{}, stylesheet_link_tag("style") @@ -218,14 +230,14 @@ class SprocketsHelperTest < ActionView::TestCase test "alternate asset prefix" do stubs(:asset_prefix).returns("/themes/test") - assert_match %r{/themes/test/style-[0-9a-f]+.css}, asset_path("style", "css") + assert_match %r{/themes/test/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") end test "alternate asset environment" do assets = Sprockets::Environment.new assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets")) stubs(:asset_environment).returns(assets) - assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", "css") + assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css") end test "alternate hash based on environment" do @@ -233,10 +245,10 @@ class SprocketsHelperTest < ActionView::TestCase assets.version = 'development' assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets")) stubs(:asset_environment).returns(assets) - dev_path = asset_path("style", "css") + dev_path = asset_path("style", :ext => "css") assets.version = 'production' - prod_path = asset_path("style", "css") + prod_path = asset_path("style", :ext => "css") assert_not_equal prod_path, dev_path end -- cgit v1.2.3 From cbaad674f13067c52fa8c1a24dc498e570db4eed Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Thu, 22 Sep 2011 11:54:13 +0200 Subject: it is now possible to pass details options (:formats, :details, :locales, ...) to #render, #find_template and friends. this doesn't change anything in global context. --- actionpack/test/template/render_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 8a582030f6..525ef0d726 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -32,6 +32,12 @@ module RenderTestCases assert_equal "Hello world!", @view.render(:file => "test/hello_world") end + # Test if :formats, :locale etc. options are passed correctly to the resolvers. + def test_render_file_with_format + assert_equal "

    No Comment

    ", @view.render(:file => "comments/empty", :formats => [:html]) + assert_equal "No Comment", @view.render(:file => "comments/empty", :formats => [:xml]) + end + def test_render_file_with_localization old_locale, @view.locale = @view.locale, :da assert_equal "Hey verden", @view.render(:file => "test/hello_world") -- cgit v1.2.3 From 119e9e2dafb0cdc5b85613b730333679aef534af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 22 Sep 2011 15:03:05 +0200 Subject: Get rid of update_details in favor of passing details to find_template. --- actionpack/test/template/lookup_context_test.rb | 10 ---------- actionpack/test/template/render_test.rb | 5 +++++ 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb index 47b70f05ab..bac2530e3d 100644 --- a/actionpack/test/template/lookup_context_test.rb +++ b/actionpack/test/template/lookup_context_test.rb @@ -31,16 +31,6 @@ class LookupContextTest < ActiveSupport::TestCase assert @lookup_context.formats.frozen? end - test "allows me to change some details to execute an specific block of code" do - formats = Mime::SET - @lookup_context.update_details(:locale => :pt) do - assert_equal formats, @lookup_context.formats - assert_equal :pt, @lookup_context.locale - end - assert_equal formats, @lookup_context.formats - assert_equal :en, @lookup_context.locale - end - test "provides getters and setters for formats" do @lookup_context.formats = [:html] assert_equal [:html], @lookup_context.formats diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 525ef0d726..f3dce0b7f2 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -38,6 +38,11 @@ module RenderTestCases assert_equal "No Comment", @view.render(:file => "comments/empty", :formats => [:xml]) end + def test_render_template_with_format + assert_equal "

    No Comment

    ", @view.render(:template => "comments/empty", :formats => [:html]) + assert_equal "No Comment", @view.render(:template => "comments/empty", :formats => [:xml]) + end + def test_render_file_with_localization old_locale, @view.locale = @view.locale, :da assert_equal "Hey verden", @view.render(:file => "test/hello_world") -- cgit v1.2.3 From 43d27e9105b385f64ec195f60d10ab3d64281bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 22 Sep 2011 15:37:38 +0200 Subject: Deprecate passing the template handler in the template name. For example, calling hello.erb is now deprecated. Since Rails 3.0 passing the handler had no effect whatsover. This commit simply deprecates such cases so we can clean up the code in later releases. --- .../test/template/compiled_templates_test.rb | 16 ++++----- actionpack/test/template/log_subscriber_test.rb | 2 +- actionpack/test/template/render_test.rb | 42 +++++++++++----------- actionpack/test/template/streaming_render_test.rb | 16 ++++----- 4 files changed, 39 insertions(+), 37 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index 8be0f452fb..8fc78283d8 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -10,24 +10,24 @@ class CompiledTemplatesTest < Test::Unit::TestCase end def test_template_gets_recompiled_when_using_different_keys_in_local_assigns - assert_equal "one", render(:file => "test/render_file_with_locals_and_default.erb") - assert_equal "two", render(:file => "test/render_file_with_locals_and_default.erb", :locals => { :secret => "two" }) + assert_equal "one", render(:file => "test/render_file_with_locals_and_default") + assert_equal "two", render(:file => "test/render_file_with_locals_and_default", :locals => { :secret => "two" }) end def test_template_changes_are_not_reflected_with_cached_templates - assert_equal "Hello world!", render(:file => "test/hello_world.erb") + assert_equal "Hello world!", render(:file => "test/hello_world") modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Hello world!", render(:file => "test/hello_world.erb") + assert_equal "Hello world!", render(:file => "test/hello_world") end - assert_equal "Hello world!", render(:file => "test/hello_world.erb") + assert_equal "Hello world!", render(:file => "test/hello_world") end def test_template_changes_are_reflected_with_uncached_templates - assert_equal "Hello world!", render_without_cache(:file => "test/hello_world.erb") + assert_equal "Hello world!", render_without_cache(:file => "test/hello_world") modify_template "test/hello_world.erb", "Goodbye world!" do - assert_equal "Goodbye world!", render_without_cache(:file => "test/hello_world.erb") + assert_equal "Goodbye world!", render_without_cache(:file => "test/hello_world") end - assert_equal "Hello world!", render_without_cache(:file => "test/hello_world.erb") + assert_equal "Hello world!", render_without_cache(:file => "test/hello_world") end private diff --git a/actionpack/test/template/log_subscriber_test.rb b/actionpack/test/template/log_subscriber_test.rb index 50e1cccd3b..752b0f23a8 100644 --- a/actionpack/test/template/log_subscriber_test.rb +++ b/actionpack/test/template/log_subscriber_test.rb @@ -27,7 +27,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase end def test_render_file_template - @view.render(:file => "test/hello_world.erb") + @view.render(:file => "test/hello_world") wait assert_equal 1, @logger.logged(:info).size diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index f3dce0b7f2..120f91b0e7 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -21,11 +21,11 @@ module RenderTestCases end def test_render_file - assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb") + assert_equal "Hello world!", @view.render(:file => "test/hello_world") end def test_render_file_not_using_full_path - assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb") + assert_equal "Hello world!", @view.render(:file => "test/hello_world") end def test_render_file_without_specific_extension @@ -62,17 +62,17 @@ module RenderTestCases end def test_render_file_with_full_path - template_path = File.join(File.dirname(__FILE__), '../fixtures/test/hello_world.erb') + template_path = File.join(File.dirname(__FILE__), '../fixtures/test/hello_world') assert_equal "Hello world!", @view.render(:file => template_path) end def test_render_file_with_instance_variables - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_ivar.erb") + assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_ivar") end def test_render_file_with_locals locals = { :secret => 'in the sauce' } - assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_locals.erb", :locals => locals) + assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_locals", :locals => locals) end def test_render_file_not_using_full_path_with_dot_in_path @@ -92,12 +92,12 @@ module RenderTestCases end def test_render_partial_at_top_level - # file fixtures/_top_level_partial_only.erb (not fixtures/test) + # file fixtures/_top_level_partial_only (not fixtures/test) assert_equal 'top level partial', @view.render(:partial => '/top_level_partial_only') end def test_render_partial_with_format_at_top_level - # file fixtures/_top_level_partial.html.erb (not fixtures/test, with format extension) + # file fixtures/_top_level_partial.html (not fixtures/test, with format extension) assert_equal 'top level partial html', @view.render(:partial => '/top_level_partial') end @@ -256,7 +256,7 @@ module RenderTestCases end def test_render_layout_with_block_and_other_partial_inside - render = @view.render(:layout => "test/layout_with_partial_and_yield.html.erb") { "Yield!" } + render = @view.render(:layout => "test/layout_with_partial_and_yield") { "Yield!" } assert_equal "Before\npartial html\nYield!\nAfter\n", render end @@ -293,24 +293,26 @@ module RenderTestCases end def test_render_ignores_templates_with_malformed_template_handlers - %w(malformed malformed.erb malformed.html.erb malformed.en.html.erb).each do |name| - assert_raise(ActionView::MissingTemplate) { @view.render(:file => "test/malformed/#{name}") } + ActiveSupport::Deprecation.silence do + %w(malformed malformed.erb malformed.html.erb malformed.en.html.erb).each do |name| + assert_raise(ActionView::MissingTemplate) { @view.render(:file => "test/malformed/#{name}") } + end end end def test_render_with_layout assert_equal %(\nHello world!\n), - @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield") + @view.render(:file => "test/hello_world", :layout => "layouts/yield") end def test_render_with_layout_which_has_render_inline assert_equal %(welcome\nHello world!\n), - @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_inline_inside") + @view.render(:file => "test/hello_world", :layout => "layouts/yield_with_render_inline_inside") end def test_render_with_layout_which_renders_another_partial assert_equal %(partial html\nHello world!\n), - @view.render(:file => "test/hello_world.erb", :layout => "layouts/yield_with_render_partial_inside") + @view.render(:file => "test/hello_world", :layout => "layouts/yield_with_render_partial_inside") end def test_render_layout_with_block_and_yield @@ -355,17 +357,17 @@ module RenderTestCases def test_render_with_nested_layout assert_equal %(title\n\n
    column
    \n
    content
    \n), - @view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield") + @view.render(:file => "test/nested_layout", :layout => "layouts/yield") end def test_render_with_file_in_layout assert_equal %(\ntitle\n\n), - @view.render(:file => "test/layout_render_file.erb") + @view.render(:file => "test/layout_render_file") end def test_render_layout_with_object assert_equal %(David), - @view.render(:file => "test/layout_render_object.erb") + @view.render(:file => "test/layout_render_object") end end @@ -403,7 +405,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.erb", :layouts => "layouts/yield") + result = @view.render(:file => "test/utf8_magic.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 @@ -411,7 +413,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.erb", :layouts => "layouts/yield") + result = @view.render(:file => "test/utf8.html", :layouts => "layouts/yield") assert_equal Encoding::UTF_8, result.encoding assert_equal "Русский текст\n\nUTF-8\nUTF-8\nUTF-8\n", result end @@ -420,7 +422,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.erb", :layouts => "layouts/yield") + @view.render(:file => "test/utf8.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 @@ -431,7 +433,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.erb", :layouts => "layouts/yield") + @view.render(:file => "test/utf8_magic_with_bare_partial.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 diff --git a/actionpack/test/template/streaming_render_test.rb b/actionpack/test/template/streaming_render_test.rb index 023ce723ed..4d01352b43 100644 --- a/actionpack/test/template/streaming_render_test.rb +++ b/actionpack/test/template/streaming_render_test.rb @@ -28,7 +28,7 @@ class FiberedTest < ActiveSupport::TestCase def test_streaming_works content = [] - body = render_body(:template => "test/hello_world.erb", :layout => "layouts/yield") + body = render_body(:template => "test/hello_world", :layout => "layouts/yield") body.each do |piece| content << piece @@ -42,12 +42,12 @@ class FiberedTest < ActiveSupport::TestCase end def test_render_file - assert_equal "Hello world!", buffered_render(:file => "test/hello_world.erb") + assert_equal "Hello world!", buffered_render(:file => "test/hello_world") end def test_render_file_with_locals locals = { :secret => 'in the sauce' } - assert_equal "The secret is in the sauce\n", buffered_render(:file => "test/render_file_with_locals.erb", :locals => locals) + assert_equal "The secret is in the sauce\n", buffered_render(:file => "test/render_file_with_locals", :locals => locals) end def test_render_partial @@ -64,27 +64,27 @@ class FiberedTest < ActiveSupport::TestCase def test_render_with_layout assert_equal %(\nHello world!\n), - buffered_render(:template => "test/hello_world.erb", :layout => "layouts/yield") + buffered_render(:template => "test/hello_world", :layout => "layouts/yield") end def test_render_with_layout_which_has_render_inline assert_equal %(welcome\nHello world!\n), - buffered_render(:template => "test/hello_world.erb", :layout => "layouts/yield_with_render_inline_inside") + buffered_render(:template => "test/hello_world", :layout => "layouts/yield_with_render_inline_inside") end def test_render_with_layout_which_renders_another_partial assert_equal %(partial html\nHello world!\n), - buffered_render(:template => "test/hello_world.erb", :layout => "layouts/yield_with_render_partial_inside") + buffered_render(:template => "test/hello_world", :layout => "layouts/yield_with_render_partial_inside") end def test_render_with_nested_layout assert_equal %(title\n\n
    column
    \n
    content
    \n), - buffered_render(:template => "test/nested_layout.erb", :layout => "layouts/yield") + buffered_render(:template => "test/nested_layout", :layout => "layouts/yield") end def test_render_with_file_in_layout assert_equal %(\ntitle\n\n), - buffered_render(:template => "test/layout_render_file.erb") + buffered_render(:template => "test/layout_render_file") end def test_render_with_handler_without_streaming_support -- cgit v1.2.3 From c070cc4ab41fd848fc72f19e7f99d75b1e1fd097 Mon Sep 17 00:00:00 2001 From: docunext Date: Wed, 21 Sep 2011 13:19:48 -0400 Subject: Fixes #1489 again, with updated code and numerous tests to confirm --- actionpack/test/template/sprockets_helper_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index c0fb07a29b..a44a16750f 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -47,6 +47,16 @@ class SprocketsHelperTest < ActionView::TestCase asset_path("logo.png", :digest => false) end + test "custom_asset_path" do + @config.assets.prefix = '/s' + assert_match %r{/s/logo-[0-9a-f]+.png}, + asset_path("logo.png") + assert_match %r{/s/logo-[0-9a-f]+.png}, + asset_path("logo.png", :digest => true) + assert_match %r{/s/logo.png}, + asset_path("logo.png", :digest => false) + end + test "asset_path with root relative assets" do assert_equal "/images/logo", asset_path("/images/logo") -- cgit v1.2.3 From f8e6664d8647acf11c8f98e00ec5a23326be5d19 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Thu, 22 Sep 2011 16:02:14 +0200 Subject: added tests for render :file/:template and the :formats/:handlers/:locale options. --- actionpack/test/template/render_test.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 120f91b0e7..634e1cdd9f 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -42,8 +42,24 @@ module RenderTestCases assert_equal "

    No Comment

    ", @view.render(:template => "comments/empty", :formats => [:html]) assert_equal "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]) + 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]) + end + + def test_render_template_with_handlers + assert_equal "

    No Comment

    \n", @view.render(:template => "comments/empty", :handlers => [:builder]) + end - def test_render_file_with_localization + def test_render_file_with_localization_on_context_level old_locale, @view.locale = @view.locale, :da assert_equal "Hey verden", @view.render(:file => "test/hello_world") ensure -- cgit v1.2.3 From 2e3eb2560b7686a633d6de35c4cd9131504aee38 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Thu, 22 Sep 2011 23:51:44 +0200 Subject: Allow both sym and array for details options in #render. using LC#registered_details to extract options. --- actionpack/test/template/render_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 634e1cdd9f..5637f3f42e 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -36,6 +36,7 @@ module RenderTestCases def test_render_file_with_format assert_equal "

    No Comment

    ", @view.render(:file => "comments/empty", :formats => [:html]) assert_equal "No Comment", @view.render(:file => "comments/empty", :formats => [:xml]) + assert_equal "No Comment", @view.render(:file => "comments/empty", :formats => :xml) end def test_render_template_with_format @@ -45,6 +46,7 @@ module RenderTestCases 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 @@ -53,6 +55,7 @@ module RenderTestCases 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 -- cgit v1.2.3 From 48d27363f2d6f20a7178dc9bd0d664bc4e60212d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 23 Sep 2011 00:42:20 +0200 Subject: Fix failing tests and add tests for :formats on partial. --- actionpack/test/template/render_test.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 5637f3f42e..0ef3239f83 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -34,14 +34,14 @@ module RenderTestCases # Test if :formats, :locale etc. options are passed correctly to the resolvers. def test_render_file_with_format - assert_equal "

    No Comment

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

    No Comment

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

    No Comment

    ", @view.render(:template => "comments/empty", :formats => [:html]) - assert_equal "No Comment", @view.render(:template => "comments/empty", :formats => [:xml]) + 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 @@ -110,6 +110,11 @@ module RenderTestCases assert_equal 'partial html', @view.render(:partial => 'test/partial') end + def test_render_partial_with_selected_format + assert_equal 'partial html', @view.render(:partial => 'test/partial', :formats => :html) + assert_equal 'partial js', @view.render(:partial => 'test/partial', :formats => [:js]) + end + def test_render_partial_at_top_level # file fixtures/_top_level_partial_only (not fixtures/test) assert_equal 'top level partial', @view.render(:partial => '/top_level_partial_only') -- cgit v1.2.3 From 038808ba1a6927189c4a11b7b77ba9a724dd5532 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sat, 24 Sep 2011 18:01:08 -0500 Subject: Add public API for register new js and css compressors for Sprockets --- actionpack/test/template/compressors_test.rb | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 actionpack/test/template/compressors_test.rb (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/compressors_test.rb b/actionpack/test/template/compressors_test.rb new file mode 100644 index 0000000000..583a1455ba --- /dev/null +++ b/actionpack/test/template/compressors_test.rb @@ -0,0 +1,29 @@ +require 'abstract_unit' +require 'rails/railtie' +require 'sprockets/railtie' + +class CompressorsTest < ActiveSupport::TestCase + def test_register_css_compressor + Sprockets::Compressors.register_css_compressor(:null, Sprockets::NullCompressor) + compressor = Sprockets::Compressors.registered_css_compressor(:null) + assert_kind_of Sprockets::NullCompressor, compressor + end + + def test_register_js_compressor + Sprockets::Compressors.register_js_compressor(:uglifier, 'Uglifier', :require => 'uglifier') + compressor = Sprockets::Compressors.registered_js_compressor(:uglifier) + assert_kind_of Uglifier, compressor + end + + def test_register_default_css_compressor + Sprockets::Compressors.register_css_compressor(:null, Sprockets::NullCompressor, :default => true) + compressor = Sprockets::Compressors.registered_css_compressor(:default) + assert_kind_of Sprockets::NullCompressor, compressor + end + + def test_register_default_js_compressor + Sprockets::Compressors.register_js_compressor(:null, Sprockets::NullCompressor, :default => true) + compressor = Sprockets::Compressors.registered_js_compressor(:default) + assert_kind_of Sprockets::NullCompressor, compressor + end +end -- cgit v1.2.3 From 5ffa69793fd3e1d4af41ebc719a6736163eb7433 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Sun, 25 Sep 2011 09:40:49 +0400 Subject: escape options for the stylesheet_link_tag method --- actionpack/test/template/asset_tag_helper_test.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index d93433deac..aa7304b3ed 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -366,6 +366,10 @@ class AssetTagHelperTest < ActionView::TestCase assert stylesheet_link_tag('dir/other/file', 'dir/file2').html_safe? end + def test_stylesheet_link_tag_escapes_options + assert_dom_equal %(), stylesheet_link_tag('/file', :media => '}, + javascript_include_tag('/javascripts/application') assert_match %r{\n}, javascript_include_tag(:application) end @@ -264,6 +266,9 @@ class SprocketsHelperTest < ActionView::TestCase @config.assets.compile = true @config.assets.debug = true + assert_match %r{}, + stylesheet_link_tag('/stylesheets/application') + assert_match %r{\n}, stylesheet_link_tag(:application) -- cgit v1.2.3 From 7f64e472772293a3a5bbf4a435d937dabd98ed92 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 7 Oct 2011 16:56:18 -0700 Subject: just check to see that the first item in the list is an array --- actionpack/test/template/form_options_helper_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 6aea991f7c..d3e0cc41a9 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -587,6 +587,15 @@ class FormOptionsHelperTest < ActionView::TestCase ) end + def test_empty + @post = Post.new + @post.category = "" + assert_dom_equal( + "", + select("post", "category", [], :prompt => true, :include_blank => true) + ) + end + def test_select_with_selected_value @post = Post.new @post.category = "" -- cgit v1.2.3 From 114218e4da9a2adf7b6ef4a27d2fa47e15881cf1 Mon Sep 17 00:00:00 2001 From: Liborio Cannici Date: Thu, 15 Sep 2011 00:35:53 +0200 Subject: Fixes an issue when creating a date select with too many options. Inspired by dlt https://github.com/dlt/rails/commit/9e615634745dc81598e7b880d52411338d3a7a93 Closes #239. Conflicts: actionpack/CHANGELOG --- actionpack/test/template/date_helper_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 09c53a36f0..af30ec9892 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -664,6 +664,15 @@ class DateHelperTest < ActionView::TestCase assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]") end + def test_select_date_with_too_big_range_between_start_year_and_end_year + assert_raise(ArgumentError) { select_date(Time.mktime(2003, 8, 16), :start_year => 2000, :end_year => 20000, :prefix => "date[first]", :order => [:month, :day, :year]) } + assert_raise(ArgumentError) { select_date(Time.mktime(2003, 8, 16), :start_year => Date.today.year - 100.years, :end_year => 2000, :prefix => "date[first]", :order => [:month, :day, :year]) } + end + + def test_select_date_can_have_more_then_1000_years_interval_if_forced_via_parameter + assert_nothing_raised { select_date(Time.mktime(2003, 8, 16), :start_year => 2000, :end_year => 3100, :max_years_allowed => 2000) } + end + def test_select_date_with_order expected = %(\n\n\n\n", + select("post", "category", [["Number", "number"], ["Text", "text"], ["Yes/No", "boolean"]], :prompt => true, :include_blank => true) + ) + end + def test_select_with_selected_value @post = Post.new @post.category = "" -- cgit v1.2.3 From b5f908a7ad515215f164e306f82c3e6c506182cb Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Thu, 3 Nov 2011 16:09:57 +0000 Subject: Stub find_template so that when handle_render_error is called in ActionView::Template, we get to see the actual underlying error rather than a NoMethodError. This shows an encoding bug on Ruby 1.9.3. --- actionpack/test/template/template_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index b0ca7de0b6..70ca876c67 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -8,6 +8,9 @@ class TestERBTemplate < ActiveSupport::TestCase def disable_cache yield end + + def find_template(*args) + end end class Context -- cgit v1.2.3 From 56207a3f0165650abb273594f1f54fbb92bbf177 Mon Sep 17 00:00:00 2001 From: Waseem Ahmad Date: Fri, 4 Nov 2011 15:03:02 +0530 Subject: Remove 'size' attribute from number_field form helper fixes #3454 f.number_field generates which is invalid HTML5. See: http://dev.w3.org/html5/spec/Overview.html#number-state --- actionpack/test/template/form_helper_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index e36d032f6c..bd7b322fc9 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -438,12 +438,12 @@ class FormHelperTest < ActionView::TestCase end def test_number_field - expected = %{} + expected = %{} assert_dom_equal(expected, number_field("order", "quantity", :in => 1...10)) end def test_range_input - expected = %{} + expected = %{} assert_dom_equal(expected, range_field("hifi", "volume", :in => 0..11, :step => 0.1)) end -- cgit v1.2.3 From cb06727b6cb7310808f5b9ce1bf254055806ba80 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 4 Nov 2011 16:44:59 +0530 Subject: add tests for the case where size is explicitly passed to number_field helper --- actionpack/test/template/form_helper_test.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index bd7b322fc9..6434d9645e 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -440,11 +440,15 @@ class FormHelperTest < ActionView::TestCase def test_number_field expected = %{} assert_dom_equal(expected, number_field("order", "quantity", :in => 1...10)) + expected = %{} + assert_dom_equal(expected, number_field("order", "quantity", :size => 30, :in => 1...10)) end def test_range_input expected = %{} assert_dom_equal(expected, range_field("hifi", "volume", :in => 0..11, :step => 0.1)) + expected = %{} + assert_dom_equal(expected, range_field("hifi", "volume", :size => 30, :in => 0..11, :step => 0.1)) end def test_explicit_name -- cgit v1.2.3 From 10773f94eae0dacf10e2ed0c28f6bb73805c2521 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 5 Nov 2011 16:42:53 +0000 Subject: Skip test_default_external_works on the CI for Ruby 1.9.3. This test is affected by a bug in Ruby 1.9.3p0 and trunk: http://redmine.ruby-lang.org/issues/5564 Given we cannot fix it for ourselves, it is better to skip for now so that we will easily see if further failures are introduced. Jon Leighton is monitoring the bug report and will revert this when a suitable solution is found (either a new Ruby release or a generic workaround). If you are using 1.9.3 in your app and have templates that are not in UTF-8, you should add a workaround early on in the boot process. For example, if your templates are Shift_JIS encoded, then add the following in an initializer: Encoding::Converter.new('Shift_JIS', 'UTF-8') --- actionpack/test/template/template_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 70ca876c67..f3328b5dca 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -130,6 +130,17 @@ class TestERBTemplate < ActiveSupport::TestCase # is set to something other than UTF-8, we don't # get any errors and get back a UTF-8 String. def test_default_external_works + if ENV['TRAVIS'] && RUBY_VERSION >= '1.9.3' + skip( + "There is currently a bug in Ruby trunk and in 1.9.3 which makes this test fail. " \ + "Please see http://redmine.ruby-lang.org/issues/5564. " \ + "Given there is no known generic workaround that this requires a fix in Ruby itself, " \ + "this test is skipped on the CI for now so that we don't pollute the CI with failures. " \ + "Jon Leighton is monitoring the bug report and will renable this test when a solution " \ + "becomes available." + ) + end + with_external_encoding "ISO-8859-1" do @template = new_template("hello \xFCmlat") assert_equal Encoding::UTF_8, render.encoding -- cgit v1.2.3 From 7776055e2dcd29e0f8f27154663263c0bbd1c188 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sun, 6 Nov 2011 10:15:04 +0000 Subject: Revert "Skip test_default_external_works on the CI for Ruby 1.9.3." This reverts commit 10773f94eae0dacf10e2ed0c28f6bb73805c2521. --- actionpack/test/template/template_test.rb | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index f3328b5dca..70ca876c67 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -130,17 +130,6 @@ class TestERBTemplate < ActiveSupport::TestCase # is set to something other than UTF-8, we don't # get any errors and get back a UTF-8 String. def test_default_external_works - if ENV['TRAVIS'] && RUBY_VERSION >= '1.9.3' - skip( - "There is currently a bug in Ruby trunk and in 1.9.3 which makes this test fail. " \ - "Please see http://redmine.ruby-lang.org/issues/5564. " \ - "Given there is no known generic workaround that this requires a fix in Ruby itself, " \ - "this test is skipped on the CI for now so that we don't pollute the CI with failures. " \ - "Jon Leighton is monitoring the bug report and will renable this test when a solution " \ - "becomes available." - ) - end - with_external_encoding "ISO-8859-1" do @template = new_template("hello \xFCmlat") assert_equal Encoding::UTF_8, render.encoding -- cgit v1.2.3 From b5c3987294d3860a78b1b04ee49b2b55f3cdc614 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Thu, 10 Nov 2011 11:26:42 +0400 Subject: Fix and simplify highlight regexp --- actionpack/test/template/text_helper_test.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 02f9609483..a0afb77f05 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -194,6 +194,10 @@ class TextHelperTest < ActionView::TestCase "

    This is a beautiful morning, but also a beautiful day

    ", highlight("

    This is a beautiful morning, but also a beautiful day

    ", "beautiful") ) + assert_equal( + "
    abc div
    ", + highlight("
    abc div
    ", "div", :highlighter => '\1') + ) end def test_excerpt -- cgit v1.2.3 From c2b6f63bbe2740fd63a36eeefe17d51813a17324 Mon Sep 17 00:00:00 2001 From: Alexander Uvarov Date: Thu, 17 Nov 2011 12:04:46 +0600 Subject: Fix impractical I18n lookup in nested fields_for --- actionpack/test/template/form_helper_test.rb | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 6434d9645e..34486bb151 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -27,7 +27,13 @@ class FormHelperTest < ActionView::TestCase :body => "Write entire text here", :color => { :red => "Rojo" + }, + :comments => { + :body => "Write body here" } + }, + :tag => { + :value => "Tag" } } } @@ -68,6 +74,12 @@ class FormHelperTest < ActionView::TestCase @post.secret = 1 @post.written_on = Date.new(2004, 6, 15) + @post.comments = [] + @post.comments << @comment + + @post.tags = [] + @post.tags << Tag.new + @blog_post = Blog::Post.new("And his name will be forty and four.", 44) end @@ -151,6 +163,40 @@ class FormHelperTest < ActionView::TestCase I18n.locale = old_locale end + def test_label_with_locales_and_nested_attributes + old_locale, I18n.locale = I18n.locale, :label + form_for(@post, :html => { :id => 'create-post' }) do |f| + f.fields_for(:comments) do |cf| + concat cf.label(:body) + end + end + + expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put") do + "" + end + + assert_dom_equal expected, output_buffer + ensure + I18n.locale = old_locale + end + + def test_label_with_locales_fallback_and_nested_attributes + old_locale, I18n.locale = I18n.locale, :label + form_for(@post, :html => { :id => 'create-post' }) do |f| + f.fields_for(:tags) do |cf| + concat cf.label(:value) + end + end + + expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put") do + "" + end + + assert_dom_equal expected, output_buffer + ensure + I18n.locale = old_locale + end + def test_label_with_for_attribute_as_symbol assert_dom_equal('', label(:post, :title, nil, :for => "my_for")) end -- cgit v1.2.3 From e8d57f361a9982382f75449ec0d65d6c798b9ce2 Mon Sep 17 00:00:00 2001 From: lest Date: Thu, 17 Nov 2011 18:29:55 +0300 Subject: _html translation should escape interpolated arguments --- actionpack/test/template/translation_helper_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb index cd9f54e04c..cabb29cfad 100644 --- a/actionpack/test/template/translation_helper_test.rb +++ b/actionpack/test/template/translation_helper_test.rb @@ -17,6 +17,7 @@ class TranslationHelperTest < ActiveSupport::TestCase :hello => 'Hello World', :html => 'Hello World', :hello_html => 'Hello World', + :interpolated_html => 'Hello %{word}', :array_html => %w(foo bar), :array => %w(foo bar) } @@ -83,6 +84,11 @@ class TranslationHelperTest < ActiveSupport::TestCase assert translate(:'translations.hello_html').html_safe? end + def test_translate_escapes_interpolations_in_translations_with_a_html_suffix + assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => '') + assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => stub(:to_s => "")) + end + def test_translation_returning_an_array_ignores_html_suffix assert_equal ["foo", "bar"], translate(:'translations.array_html') end -- 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') 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 603a679e87d0317957eb44ce3928d593a0c50bb5 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 19 Nov 2011 13:19:20 +0000 Subject: Don't html-escape the :count option to translate if it's a Numeric. Fixes #3685. --- actionpack/test/template/translation_helper_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb index cabb29cfad..397de9c2ce 100644 --- a/actionpack/test/template/translation_helper_test.rb +++ b/actionpack/test/template/translation_helper_test.rb @@ -19,7 +19,11 @@ class TranslationHelperTest < ActiveSupport::TestCase :hello_html => 'Hello World', :interpolated_html => 'Hello %{word}', :array_html => %w(foo bar), - :array => %w(foo bar) + :array => %w(foo bar), + :count_html => { + :one => 'One %{count}', + :other => 'Other %{count}' + } } ) @view = ::ActionView::Base.new(ActionController::Base.view_paths, {}) @@ -89,6 +93,12 @@ class TranslationHelperTest < ActiveSupport::TestCase assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => stub(:to_s => "")) end + def test_translate_with_html_count + assert_equal 'One 1', translate(:'translations.count_html', :count => 1) + assert_equal 'Other 2', translate(:'translations.count_html', :count => 2) + assert_equal 'Other <One>', translate(:'translations.count_html', :count => '') + end + def test_translation_returning_an_array_ignores_html_suffix assert_equal ["foo", "bar"], translate(:'translations.array_html') end -- cgit v1.2.3 From aa491f6a9c90641a2d4115420b14e45514962834 Mon Sep 17 00:00:00 2001 From: lest Date: Tue, 22 Nov 2011 16:39:07 +0300 Subject: javascript_include_tag should add '.js' to sources that contain '.' --- actionpack/test/template/sprockets_helper_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index db69f95130..26a504beb8 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -217,6 +217,9 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, javascript_include_tag(:application, :debug => true) + assert_match %r{}, + javascript_include_tag('jquery.plugin', :digest => false) + @config.assets.compile = true @config.assets.debug = true assert_match %r{}, -- cgit v1.2.3 From fd86a1b6b068df87164d5763bdcd4a323a1e76f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 23 Nov 2011 19:06:45 +0000 Subject: Rely on a public contract between railties instead of accessing railtie methods directly. --- actionpack/test/template/form_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 34486bb151..ccedcd7dac 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -740,7 +740,7 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end - def test_form_for_with_isolated_namespaced_model + def test_form_for_with_model_using_relative_model_naming form_for(@blog_post) do |f| concat f.text_field :title concat f.submit('Edit post') -- cgit v1.2.3 From bc81ba2451a6a6c5507ad497cf838935e9d1ece2 Mon Sep 17 00:00:00 2001 From: lest Date: Sun, 27 Nov 2011 16:59:44 +0300 Subject: fix label with block in erb --- actionpack/test/template/form_helper_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index ccedcd7dac..0758106a40 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -230,6 +230,13 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal('', label(:post, :title) { "The title, please:" }) end + def test_label_with_block_in_erb + path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) + view_paths = ActionView::PathSet.new([path]) + view = ActionView::Base.new(view_paths) + assert_equal "", view.render("test/label_with_block") + end + def test_text_field assert_dom_equal( '', text_field("post", "title") -- cgit v1.2.3 From fb8b555c490553ffe32d099303deaa37397029df Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sun, 27 Nov 2011 23:41:23 +0300 Subject: add namespace options to form_for You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generate HTML id --- actionpack/test/template/form_helper_test.rb | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 0758106a40..ad876df65d 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -935,6 +935,82 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_with_namespace + form_for(@post, :namespace => 'namespace') do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'put') do + "" + + "" + + "" + + "" + end + + assert_dom_equal expected, output_buffer + end + + def test_form_for_with_namespace_with_label + form_for(@post, :namespace => 'namespace') do |f| + concat f.label(:title) + concat f.text_field(:title) + end + + expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'put') do + "" + + "" + end + + assert_dom_equal expected, output_buffer + end + + def test_two_form_for_with_namespace + form_for(@post, :namespace => 'namespace_1') do |f| + concat f.label(:title) + concat f.text_field(:title) + end + + expected_1 = whole_form('/posts/123', 'namespace_1_edit_post_123', 'edit_post', 'put') do + "" + + "" + end + + assert_dom_equal expected_1, output_buffer + + form_for(@post, :namespace => 'namespace_2') do |f| + concat f.label(:title) + concat f.text_field(:title) + end + + expected_2 = whole_form('/posts/123', 'namespace_2_edit_post_123', 'edit_post', 'put') do + "" + + "" + end + + assert_dom_equal expected_2, output_buffer + end + + def test_fields_for_with_namespace + @comment.body = 'Hello World' + form_for(@post, :namespace => 'namespace') do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.fields_for(@comment) { |c| + concat c.text_field(:body) + } + end + + expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'put') do + "" + + "" + + "" + end + + assert_dom_equal expected, output_buffer + end + def test_submit_with_object_as_new_record_and_locale_strings old_locale, I18n.locale = I18n.locale, :submit -- cgit v1.2.3 From d3bc12b27feb96e8799e2bcdc6e52b2704360aa3 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Tue, 29 Nov 2011 01:59:36 -0500 Subject: Handle correctly optional parameters for callable asset_host. --- actionpack/test/template/sprockets_helper_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 26a504beb8..64fdd53e73 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -41,6 +41,10 @@ class SprocketsHelperTest < ActionView::TestCase @controller ? @controller.config : @config end + def compute_host(source, request, options = {}) + raise "Should never get here" + end + test "asset_path" do assert_match %r{/assets/logo-[0-9a-f]+.png}, asset_path("logo.png") @@ -125,6 +129,10 @@ class SprocketsHelperTest < ActionView::TestCase assert_raises ActionController::RoutingError do asset_path("logo.png") end + @config.asset_host = method :compute_host + assert_raises ActionController::RoutingError do + asset_path("logo.png") + end end test "image_tag" do -- cgit v1.2.3 From e975fe710a1a78d723cfd91c07014627f92e3250 Mon Sep 17 00:00:00 2001 From: lest Date: Wed, 30 Nov 2011 17:38:09 +0300 Subject: test helpers in erb using erb --- actionpack/test/template/form_helper_test.rb | 5 ++--- actionpack/test/template/form_tag_helper_test.rb | 16 +++++++++------- actionpack/test/template/record_tag_helper_test.rb | 6 ++++-- actionpack/test/template/tag_helper_test.rb | 10 +++++----- 4 files changed, 20 insertions(+), 17 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index ad876df65d..3fee366804 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -3,6 +3,8 @@ require 'controller/fake_models' require 'active_support/core_ext/object/inclusion' class FormHelperTest < ActionView::TestCase + include RenderERBUtils + tests ActionView::Helpers::FormHelper def form_for(*) @@ -231,9 +233,6 @@ class FormHelperTest < ActionView::TestCase end def test_label_with_block_in_erb - path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) - view_paths = ActionView::PathSet.new([path]) - view = ActionView::Base.new(view_paths) assert_equal "", view.render("test/label_with_block") end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 6eae9bf846..233907d07a 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -2,6 +2,8 @@ require 'abstract_unit' require 'active_support/core_ext/object/inclusion' class FormTagHelperTest < ActionView::TestCase + include RenderERBUtils + tests ActionView::Helpers::FormTagHelper def setup @@ -104,14 +106,14 @@ class FormTagHelperTest < ActionView::TestCase end def test_form_tag_with_block_in_erb - output_buffer = form_tag("http://www.example.com") { concat "Hello world!" } + output_buffer = render_erb("<%= form_tag('http://www.example.com') do %>Hello world!<% end %>") expected = whole_form { "Hello world!" } assert_dom_equal expected, output_buffer end def test_form_tag_with_block_and_method_in_erb - output_buffer = form_tag("http://www.example.com", :method => :put) { concat "Hello world!" } + output_buffer = render_erb("<%= form_tag('http://www.example.com', :method => :put) do %>Hello world!<% end %>") expected = whole_form("http://www.example.com", :method => "put") do "Hello world!" @@ -485,27 +487,27 @@ class FormTagHelperTest < ActionView::TestCase end def test_field_set_tag_in_erb - output_buffer = field_set_tag("Your details") { concat "Hello world!" } + output_buffer = render_erb("<%= field_set_tag('Your details') do %>Hello world!<% end %>") expected = %(
    Your detailsHello world!
    ) assert_dom_equal expected, output_buffer - output_buffer = field_set_tag { concat "Hello world!" } + output_buffer = render_erb("<%= field_set_tag do %>Hello world!<% end %>") expected = %(
    Hello world!
    ) assert_dom_equal expected, output_buffer - output_buffer = field_set_tag('') { concat "Hello world!" } + output_buffer = render_erb("<%= field_set_tag('') do %>Hello world!<% end %>") expected = %(
    Hello world!
    ) assert_dom_equal expected, output_buffer - output_buffer = field_set_tag('', :class => 'format') { concat "Hello world!" } + output_buffer = render_erb("<%= field_set_tag('', :class => 'format') do %>Hello world!<% end %>") expected = %(
    Hello world!
    ) assert_dom_equal expected, output_buffer end - + def test_text_area_tag_options_symbolize_keys_side_effects options = { :option => "random_option" } text_area_tag "body", "hello world", options diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 7f23629e05..ec777d15c4 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -22,6 +22,8 @@ class Post end class RecordTagHelperTest < ActionView::TestCase + include RenderERBUtils + tests ActionView::Helpers::RecordTagHelper def setup @@ -58,13 +60,13 @@ class RecordTagHelperTest < ActionView::TestCase def test_block_works_with_content_tag_for_in_erb expected = %(#{@post.body}) - actual = content_tag_for(:tr, @post) { concat @post.body } + actual = render_erb("<%= content_tag_for(:tr, @post) do %><%= @post.body %><% end %>") assert_dom_equal expected, actual end def test_div_for_in_erb expected = %(
    #{@post.body}
    ) - actual = div_for(@post, :class => "bar") { concat @post.body } + actual = render_erb("<%= div_for(@post, :class => 'bar') do %><%= @post.body %><% end %>") assert_dom_equal expected, actual end diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb index 60b466a9ff..6c325d5abb 100644 --- a/actionpack/test/template/tag_helper_test.rb +++ b/actionpack/test/template/tag_helper_test.rb @@ -1,6 +1,8 @@ require 'abstract_unit' class TagHelperTest < ActionView::TestCase + include RenderERBUtils + tests ActionView::Helpers::TagHelper def test_tag @@ -44,12 +46,12 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_block_in_erb - buffer = content_tag(:div) { concat "Hello world!" } + buffer = render_erb("<%= content_tag(:div) do %>Hello world!<% end %>") assert_dom_equal "
    Hello world!
    ", buffer end def test_content_tag_with_block_and_options_in_erb - buffer = content_tag(:div, :class => "green") { concat "Hello world!" } + buffer = render_erb("<%= content_tag(:div, :class => 'green') do %>Hello world!<% end %>") assert_dom_equal %(
    Hello world!
    ), buffer end @@ -68,10 +70,8 @@ class TagHelperTest < ActionView::TestCase output_buffer end - # TAG TODO: Move this into a real template def test_content_tag_nested_in_content_tag_in_erb - buffer = content_tag("p") { concat content_tag("b", "Hello") } - assert_equal '

    Hello

    ', buffer + assert_equal "

    \n Hello\n

    ", view.render("test/content_tag_nested_in_content_tag") end def test_content_tag_with_escaped_array_class -- cgit v1.2.3