aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/asset_tag_helper_test.rb
diff options
context:
space:
mode:
authorSam Pohlenz <sam@sampohlenz.com>2009-09-03 14:00:40 -0500
committerJoshua Peek <josh@joshpeek.com>2009-09-03 14:01:01 -0500
commit4b6321efa9be103ca1e00c13dd9d955b076dd31e (patch)
treebd542c0821ae419ba61ea2d38d5f5e9a7aebdc27 /actionpack/test/template/asset_tag_helper_test.rb
parentf61dc0ef6511e585f0b6a8d02b00c17b2388b04a (diff)
downloadrails-4b6321efa9be103ca1e00c13dd9d955b076dd31e.tar.gz
rails-4b6321efa9be103ca1e00c13dd9d955b076dd31e.tar.bz2
rails-4b6321efa9be103ca1e00c13dd9d955b076dd31e.zip
Don't raise exceptions for missing javascript_include_tag or stylesheet_link_tag sources unless the :cache or :concat options are given. [#2738 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/test/template/asset_tag_helper_test.rb')
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb62
1 files changed, 58 insertions, 4 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 28f9d48671..83fc6a282c 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -213,11 +213,11 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_javascript_include_tag_with_missing_source
- assert_raise(Errno::ENOENT) {
+ assert_nothing_raised {
javascript_include_tag('missing_security_guard')
}
- assert_raise(Errno::ENOENT) {
+ assert_nothing_raised {
javascript_include_tag(:defaults, 'missing_security_guard')
}
@@ -276,7 +276,7 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_stylesheet_link_tag_with_missing_source
- assert_raise(Errno::ENOENT) {
+ assert_nothing_raised {
stylesheet_link_tag('missing_security_guard')
}
@@ -639,6 +639,40 @@ class AssetTagHelperTest < ActionView::TestCase
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
end
+ def test_caching_javascript_include_tag_when_caching_on_and_missing_javascript_file
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionController::Base.perform_caching = true
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => true)
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => "money")
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
+ end
+
+ def test_caching_javascript_include_tag_when_caching_off_and_missing_javascript_file
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionController::Base.perform_caching = false
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => true)
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => "money")
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
+ end
+
def test_caching_stylesheet_link_tag_when_caching_on
ENV["RAILS_ASSET_ID"] = ""
ActionController::Base.asset_host = 'http://a0.example.com'
@@ -709,7 +743,6 @@ class AssetTagHelperTest < ActionView::TestCase
def test_caching_stylesheet_link_tag_when_caching_on_and_missing_css_file
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a0.example.com'
ActionController::Base.perform_caching = true
assert_raise(Errno::ENOENT) {
@@ -729,6 +762,27 @@ class AssetTagHelperTest < ActionView::TestCase
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
end
+ def test_caching_stylesheet_link_tag_when_caching_off_and_missing_css_file
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionController::Base.perform_caching = false
+
+ assert_raise(Errno::ENOENT) {
+ stylesheet_link_tag('bank', 'robber', 'missing_security_guard', :cache => true)
+ }
+
+ assert ! File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
+
+ assert_raise(Errno::ENOENT) {
+ stylesheet_link_tag('bank', 'robber', 'missing_security_guard', :cache => "money")
+ }
+
+ assert ! File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.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'))
+ 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" }