diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-13 02:31:45 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-13 02:31:45 +0000 |
commit | e915379a102b5cecf0a9ffb26236dff3738d4dd7 (patch) | |
tree | 658a8226ea89f246b8e84620baa39d422727abf2 /actionpack/test/template | |
parent | 9d4fa7c4a70fd3a9e07cb5fbfa58fe391da3ddfc (diff) | |
download | rails-e915379a102b5cecf0a9ffb26236dff3738d4dd7.tar.gz rails-e915379a102b5cecf0a9ffb26236dff3738d4dd7.tar.bz2 rails-e915379a102b5cecf0a9ffb26236dff3738d4dd7.zip |
Added ActionView::Helpers::register_javascript/stylesheet_expansion to make it easier for plugin developers to inject multiple assets (closes #10350) [lotswholetime]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9016 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index ffd1d955e1..6ac6e59a4e 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -175,6 +175,22 @@ class AssetTagHelperTest < Test::Unit::TestCase 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>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults) end + def test_custom_javascript_expansions + ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => ["head", "body", "tail"] + assert_dom_equal %(<script src="/javascripts/first.js" type="text/javascript"></script>\n<script src="/javascripts/head.js" type="text/javascript"></script>\n<script src="/javascripts/body.js" type="text/javascript"></script>\n<script src="/javascripts/tail.js" type="text/javascript"></script>\n<script src="/javascripts/last.js" type="text/javascript"></script>), javascript_include_tag('first', :monkey, 'last') + end + + def test_custom_javascript_expansions_and_defaults_puts_application_js_at_the_end + ENV["RAILS_ASSET_ID"] = "" + ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => ["head", "body", "tail"] + assert_dom_equal %(<script src="/javascripts/first.js" type="text/javascript"></script>\n<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/head.js" type="text/javascript"></script>\n<script src="/javascripts/body.js" type="text/javascript"></script>\n<script src="/javascripts/tail.js" type="text/javascript"></script>\n<script src="/javascripts/last.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag('first', :defaults, :monkey, 'last') + end + + def test_custom_javascript_expansions_with_undefined_symbol + ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => nil + assert_raise(ArgumentError) { javascript_include_tag('first', :monkey, 'last') } + end + def test_stylesheet_path StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end @@ -188,6 +204,16 @@ class AssetTagHelperTest < Test::Unit::TestCase StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end + def test_custom_stylesheet_expansions + ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => ["head", "body", "tail"] + assert_dom_equal %(<link href="/stylesheets/first.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/head.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/body.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/tail.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/last.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag('first', :monkey, 'last') + end + + def test_custom_stylesheet_expansions_with_undefined_symbol + ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => nil + assert_raise(ArgumentError) { stylesheet_link_tag('first', :monkey, 'last') } + end + def test_image_path ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end |