Skip to content
Browse files

Properly deprecate register_javascript_include_default and reset_java…

…script_include_default
  • Loading branch information...
1 parent f85b206 commit dd7e872e85bce6df43c3c3b6becf9364eb054b42 @wycats wycats committed Aug 9, 2010
View
12 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -393,6 +393,18 @@ def self.register_stylesheet_expansion(expansions)
@@stylesheet_expansions.merge!(expansions)
end
+ def self.reset_javascript_include_default
+ ActiveSupport::Deprecation.warn "reset_javascript_include_default is deprecated. Please manipulate " \
+ "config.action_view.javascript_expansions[:defaults] directly", caller
+ self.javascript_expansions[:defaults] = ['prototype', 'effects', 'dragdrop', 'controls', 'rails']
+ end
+
+ def self.register_javascript_include_default(*args)
+ ActiveSupport::Deprecation.warn "register_javascript_include_default is deprecated. Please " \
+ "manipulate config.action_view.javascript_expansions[:defaults] directly", caller
+ self.javascript_expansions[:defaults].concat args
+ end
+
# Computes the path to a stylesheet asset in the public stylesheets directory.
# If the +source+ filename has no extension, <tt>.css</tt> will be appended (except for explicit URIs).
# Full paths from the document root will be passed through.
View
14 actionpack/test/template/asset_tag_helper_test.rb
@@ -278,6 +278,20 @@ def test_reset_javascript_expansions
assert_raise(ArgumentError) { javascript_include_tag(:defaults) }
end
+ def test_deprecated_reset_javascript_expansions
+ ENV["RAILS_ASSET_ID"] = ""
+ assert_deprecated { ActionView::Helpers::AssetTagHelper.reset_javascript_include_default }
+ assert_equal JavascriptIncludeToTag["javascript_include_tag(:defaults)"], javascript_include_tag(:defaults)
+ end
+
+ def test_deprecated_register_javascript_expansions
+ ENV["RAILS_ASSET_ID"] = ""
+ assert_deprecated { ActionView::Helpers::AssetTagHelper.reset_javascript_include_default }
+ assert_deprecated { ActionView::Helpers::AssetTagHelper.register_javascript_include_default("foo") }
+ result = %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/rails.js" type="text/javascript"></script>\n<script src="/javascripts/foo.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>)
+ assert_equal result, javascript_include_tag(:defaults)
+ end
+
def test_stylesheet_path
ENV["RAILS_ASSET_ID"] = ""
StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }

0 comments on commit dd7e872

Please sign in to comment.
Something went wrong with that request. Please try again.