From 7abc0c73bdaa004948f89336b0c4dfeb1f357269 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 11 Aug 2012 17:59:18 +0200 Subject: Deprecate mime types lookup in auto_discovery_link_tag Automatically handling mime types for things other than :rss and :atom is not functionality that justifies dependency on Mime::Type from actionpack. --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 8 ++++++++ actionpack/test/template/asset_tag_helper_test.rb | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index ceb56824fa..db4da6f9c8 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -222,6 +222,14 @@ module ActionView # auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {:title => "Example RSS"}) # # => def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {}) + if !(type == :rss || type == :atom) && tag_options[:type].blank? + message = "You have passed type other than :rss or :atom to auto_discovery_link_tag and haven't supplied " + + "the :type option key. This behavior is deprecated and will be remove in Rails 4.1. You should pass " + + ":type option explicitly if you want to use other types, for example: " + + "auto_discovery_link_tag(:xml, '/feed.xml', :type => 'application/xml')" + ActiveSupport::Deprecation.warn message + end + tag( "link", "rel" => tag_options[:rel] || "alternate", diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 6a44197525..25d85c47c7 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -65,7 +65,6 @@ class AssetTagHelperTest < ActionView::TestCase %(auto_discovery_link_tag) => %(), %(auto_discovery_link_tag(:rss)) => %(), %(auto_discovery_link_tag(:atom)) => %(), - %(auto_discovery_link_tag(:xml)) => %(), %(auto_discovery_link_tag(:rss, :action => "feed")) => %(), %(auto_discovery_link_tag(:rss, "http://localhost/feed")) => %(), %(auto_discovery_link_tag(:rss, "//localhost/feed")) => %(), @@ -299,6 +298,16 @@ class AssetTagHelperTest < ActionView::TestCase %(audio_tag(["audio.mp3", "audio.ogg"], :autobuffer => true, :controls => true)) => %() } + def test_autodiscovery_link_tag_deprecated_types + result = nil + assert_deprecated do + result = auto_discovery_link_tag(:xml) + end + + expected = %() + assert_equal expected, result + end + def test_auto_discovery_link_tag AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end -- cgit v1.2.3