diff options
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 9a242c6a5a..8ec3229547 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -24,6 +24,7 @@ class AssetTagHelperTest < Test::Unit::TestCase @controller.request = @request + ActionView::Helpers::AssetTagHelper::reset_javascript_include_default end AutoDiscoveryToTag = { @@ -48,6 +49,7 @@ class AssetTagHelperTest < Test::Unit::TestCase %(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>), %(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>), %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>), + %(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>) } StylePathToTag = { @@ -85,6 +87,13 @@ class AssetTagHelperTest < Test::Unit::TestCase def test_javascript_include JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end + + def test_register_javascript_include_default + ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' + assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>), javascript_include_tag(:defaults) + ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2' + assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>), javascript_include_tag(:defaults) + end def test_style_path StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } @@ -127,7 +136,8 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase end.new @controller.request = @request - + + ActionView::Helpers::AssetTagHelper::reset_javascript_include_default end AutoDiscoveryToTag = { @@ -143,7 +153,7 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase JavascriptIncludeToTag = { %(javascript_include_tag("xmlhr")) => %(<script src="/calloboration/hieraki/javascripts/xmlhr.js" type="text/javascript"></script>), %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/calloboration/hieraki/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/calloboration/hieraki/elsewhere/cools.js" type="text/javascript"></script>), - %(javascript_include_tag(:defaults)) => %(<script src='/calloboration/hieraki/javascripts/prototype.js' type='text/javascript'></script>\n<script src='/calloboration/hieraki/javascripts/scriptaculous.js' type='text/javascript'></script>), + %(javascript_include_tag(:defaults)) => %(<script src="/calloboration/hieraki/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/effects.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/controls.js" type="text/javascript"></script>) } StylePathToTag = { @@ -177,6 +187,13 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase def test_javascript_include JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end + + def test_register_javascript_include_default + ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' + assert_dom_equal %(<script src="/calloboration/hieraki/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/effects.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/controls.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/slider.js" type="text/javascript"></script>), javascript_include_tag(:defaults) + ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2' + assert_dom_equal %(<script src="/calloboration/hieraki/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/effects.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/controls.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/slider.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/elsewhere/blub/lib2.js" type="text/javascript"></script>), javascript_include_tag(:defaults) + end def test_style_path StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } |