aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/asset_tag_helper_test.rb
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2011-02-13 05:39:27 +0800
committerJosé Valim <jose.valim@gmail.com>2011-02-13 05:50:25 +0800
commite2b99eb1a77b1b2d8c1ede5239a2f72ef0898cd0 (patch)
tree562b82f221893809e72a6df97882adb157ef76e8 /actionpack/test/template/asset_tag_helper_test.rb
parent1363bb8f7215fadb65e9296217be2ae96e82dd7e (diff)
downloadrails-e2b99eb1a77b1b2d8c1ede5239a2f72ef0898cd0.tar.gz
rails-e2b99eb1a77b1b2d8c1ede5239a2f72ef0898cd0.tar.bz2
rails-e2b99eb1a77b1b2d8c1ede5239a2f72ef0898cd0.zip
Applied changes to stylesheet_link_tag from javascript_include_tag which corrects issues with ordering and duplicates.
Diffstat (limited to 'actionpack/test/template/asset_tag_helper_test.rb')
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 49e47a2aed..a1a6b5f1d0 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -356,6 +356,29 @@ class AssetTagHelperTest < ActionView::TestCase
assert_dom_equal %(<link href="/stylesheets/version.1.0.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/subdir/subdir.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag('version.1.0', :robbery, 'subdir/subdir')
end
+ def test_custom_stylesheet_expansions_return_unique_set
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :cities => %w(wellington amsterdam london)
+ assert_dom_equal %(<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" />\n<link href="/stylesheets/london.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag(:cities)
+ end
+
+ def test_stylesheet_link_tag_should_not_output_the_same_asset_twice
+ ENV["RAILS_ASSET_ID"] = ""
+ assert_dom_equal %(<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('wellington', 'wellington', 'amsterdam')
+ end
+
+ def test_stylesheet_link_tag_should_not_output_the_same_expansion_twice
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :cities => %w(wellington amsterdam london)
+ assert_dom_equal %(<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" />\n<link href="/stylesheets/london.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag(:cities, :cities)
+ end
+
+ def test_single_stylesheet_asset_keys_should_take_precedence_over_expansions
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :cities => %w(wellington amsterdam london)
+ 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
ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :monkey => nil
assert_raise(ArgumentError) { stylesheet_link_tag('first', :monkey, 'last') }