aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2015-10-04 22:14:04 -0700
committerJeremy Daer <jeremydaer@gmail.com>2015-10-06 11:29:30 -0700
commit565094a8b5cdfa158fef6ae75252fd98a4ba8fe4 (patch)
tree78cc5fc25b114c26e14d855370e16139dbd4b679 /actionview
parent5b69e30622de27e8010fd8cb32a97b5f0fe194e2 (diff)
downloadrails-565094a8b5cdfa158fef6ae75252fd98a4ba8fe4.tar.gz
rails-565094a8b5cdfa158fef6ae75252fd98a4ba8fe4.tar.bz2
rails-565094a8b5cdfa158fef6ae75252fd98a4ba8fe4.zip
Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compat
Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries that support multiple Rails versions would've had to feature-detect whether to use `Mime::Type[:FOO]` or `Mime::FOO`. `Mime[:foo]` has been around for ages to look up registered MIME types by symbol / extension, though, so libraries and plugins can safely switch to that without breaking backward- or forward-compatibility. Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup by type or extension, so it's not available as `Mime[:all]`. We use it internally as a wildcard for `respond_to` negotiation. If you use this internal constant, continue to reference it with `Mime::ALL`. Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb2
-rw-r--r--actionview/test/actionpack/controller/render_test.rb2
-rw-r--r--actionview/test/template/lookup_context_test.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb
index e506c782d6..fa46a22500 100644
--- a/actionview/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb
@@ -136,7 +136,7 @@ module ActionView
tag(
"link",
"rel" => tag_options[:rel] || "alternate",
- "type" => tag_options[:type] || Mime::Type.lookup_by_extension(type.to_s).to_s,
+ "type" => tag_options[:type] || Mime[type].to_s,
"title" => tag_options[:title] || type.to_s.upcase,
"href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options
)
diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb
index 9409775fef..bdb9e0397b 100644
--- a/actionview/test/actionpack/controller/render_test.rb
+++ b/actionview/test/actionpack/controller/render_test.rb
@@ -466,7 +466,7 @@ class TestController < ApplicationController
end
def render_content_type_from_body
- response.content_type = Mime::RSS
+ response.content_type = Mime[:rss]
render body: "hello world!"
end
diff --git a/actionview/test/template/lookup_context_test.rb b/actionview/test/template/lookup_context_test.rb
index 1184cf7da8..2e3a3f9bae 100644
--- a/actionview/test/template/lookup_context_test.rb
+++ b/actionview/test/template/lookup_context_test.rb
@@ -52,7 +52,7 @@ class LookupContextTest < ActiveSupport::TestCase
end
test "handles explicitly defined */* formats fallback to :js" do
- @lookup_context.formats = [:js, Mime::Type[:ALL]]
+ @lookup_context.formats = [:js, Mime::ALL]
assert_equal [:js, *Mime::SET.symbols], @lookup_context.formats
end