aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-12-16 23:50:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-12-16 23:50:02 +0000
commit56e646296af1929f07f0e2981deddba95cdbf5d0 (patch)
tree1b95c2fe403cba5be1e7a6872cff32adcc55d426 /actionpack/test/template
parentd7e6df43a9d41f1380d79b93881ef0abacb8973b (diff)
downloadrails-56e646296af1929f07f0e2981deddba95cdbf5d0.tar.gz
rails-56e646296af1929f07f0e2981deddba95cdbf5d0.tar.bz2
rails-56e646296af1929f07f0e2981deddba95cdbf5d0.zip
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
Diffstat (limited to 'actionpack/test/template')
-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