aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-06-15 10:23:23 -0500
committerJoshua Peek <josh@joshpeek.com>2009-06-15 10:23:23 -0500
commitc50b03b754948b676b74c334edfb277fa45c1d14 (patch)
tree0e95f46d28ee495241dea364fa88c3c7b68afe21 /actionpack/test
parentb56169c26240db1b1cff3c6f65a34b7516a9fc15 (diff)
downloadrails-c50b03b754948b676b74c334edfb277fa45c1d14.tar.gz
rails-c50b03b754948b676b74c334edfb277fa45c1d14.tar.bz2
rails-c50b03b754948b676b74c334edfb277fa45c1d14.zip
Add :concat option to asset tag helpers to force concatenation.
This is useful for working around IE's stylesheet limit. stylesheet_link_tag :all, :concat => true
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index d586afdef6..f1dad9f50e 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -568,6 +568,36 @@ class AssetTagHelperTest < ActionView::TestCase
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute'))
end
+ def test_concat_stylesheet_link_tag_when_caching_off
+ ENV["RAILS_ASSET_ID"] = ""
+
+ assert_dom_equal(
+ %(<link href="/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />),
+ stylesheet_link_tag(:all, :concat => true)
+ )
+
+ expected = Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max
+ assert_equal expected, File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
+
+ assert_dom_equal(
+ %(<link href="/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />),
+ stylesheet_link_tag(:all, :concat => "money")
+ )
+
+ assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
+
+ assert_dom_equal(
+ %(<link href="/absolute/test.css" media="screen" rel="stylesheet" type="text/css" />),
+ stylesheet_link_tag(:all, :concat => "/absolute/test")
+ )
+
+ assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute', 'test.css'))
+ ensure
+ FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
+ FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
+ FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::ASSETS_DIR, 'absolute'))
+ end
+
def test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host
ENV["RAILS_ASSET_ID"] = ""
ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" }