Permalink
Browse files

Add tests for register expansion methods with key = []

  • Loading branch information...
1 parent a00bed0 commit 801e314006ca755b94eccc6e7f80b1655168a250 @spastorino spastorino committed Feb 28, 2011
Showing with 12 additions and 2 deletions.
  1. +12 −2 actionpack/test/template/asset_tag_helper_test.rb
View
14 actionpack/test/template/asset_tag_helper_test.rb
@@ -302,11 +302,16 @@ def test_registering_javascript_expansions_merges_with_existing_expansions
assert_dom_equal %(<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>), javascript_include_tag(:can_merge)
end
- def test_custom_javascript_expansions_with_undefined_symbol
+ def test_custom_javascript_expansions_with_nil_value
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => nil
assert_raise(ArgumentError) { javascript_include_tag('first', :monkey, 'last') }
end
+ def test_custom_javascript_expansions_with_empty_array_value
+ ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => []
+ assert_dom_equal %(<script src="/javascripts/first.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_and_stylesheet_expansion_with_same_name
ENV["RAILS_ASSET_ID"] = ""
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :robbery => ["bank", "robber"]
@@ -379,11 +384,16 @@ def test_single_stylesheet_asset_keys_should_take_precedence_over_expansions
assert_dom_equal %(<link href="/stylesheets/london.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/wellington.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/amsterdam.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag('london', :cities)
end
- def test_custom_stylesheet_expansions_with_undefined_symbol
+ def test_custom_stylesheet_expansions_with_nil_value
ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => nil
assert_raise(ArgumentError) { stylesheet_link_tag('first', :monkey, 'last') }
end
+ def test_custom_stylesheet_expansions_with_empty_array_value
+ ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => []
+ assert_dom_equal %(<link href="/stylesheets/first.css" rel="stylesheet" type="text/css" media="screen" />\n<link href="/stylesheets/last.css" rel="stylesheet" type="text/css" media="screen" />), stylesheet_link_tag('first', :monkey, 'last')
+ end
+
def test_registering_stylesheet_expansions_merges_with_existing_expansions
ENV["RAILS_ASSET_ID"] = ""
ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['bank']

0 comments on commit 801e314

Please sign in to comment.