From 56e646296af1929f07f0e2981deddba95cdbf5d0 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 16 Dec 2007 23:50:02 +0000 Subject: Added option to pass proc to ActionController::Base.asset_host for maximum configurability (closes #10521) [chuyeow] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8421 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/template/asset_tag_helper_test.rb | 39 +++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 502c54e57f..ac21bc2a33 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -223,7 +223,6 @@ class AssetTagHelperTest < Test::Unit::TestCase assert_equal copy, source end - def test_caching_javascript_include_tag_when_caching_on ENV["RAILS_ASSET_ID"] = "" ActionController::Base.asset_host = 'http://a%d.example.com' @@ -247,7 +246,24 @@ class AssetTagHelperTest < Test::Unit::TestCase File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) end - + + def test_caching_javascript_include_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" } + ActionController::Base.perform_caching = true + + assert_equal '/javascripts/scripts.js'.length, 23 + assert_dom_equal( + %(), + javascript_include_tag(:all, :cache => 'scripts') + ) + + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'scripts.js')) + + ensure + File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'scripts.js')) + end + def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory ENV["RAILS_ASSET_ID"] = "" ActionController::Base.asset_host = 'http://a%d.example.com' @@ -304,7 +320,24 @@ class AssetTagHelperTest < Test::Unit::TestCase File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) 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" } + ActionController::Base.perform_caching = true + + assert_equal '/stylesheets/styles.css'.length, 23 + assert_dom_equal( + %(), + stylesheet_link_tag(:all, :cache => 'styles') + ) + + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'styles.css')) + + ensure + File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'styles.css')) + end + def test_caching_stylesheet_include_tag_when_caching_off ENV["RAILS_ASSET_ID"] = "" ActionController::Base.perform_caching = false -- cgit v1.2.3