aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb39
1 files changed, 36 insertions, 3 deletions
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(
+ %(<script src="http://a23.example.com/javascripts/scripts.js" type="text/javascript"></script>),
+ 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(
+ %(<link href="http://a23.example.com/stylesheets/styles.css" media="screen" rel="stylesheet" type="text/css" />),
+ 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