1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Deprecate Template#mime_type

This commit is contained in:
Piotr Sarnacki 2012-08-25 01:20:51 +02:00
parent 3fb10fd479
commit 582a7f4599
2 changed files with 13 additions and 0 deletions

View file

@ -1,5 +1,6 @@
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/deprecation'
require 'thread'
module ActionView
@ -147,6 +148,11 @@ module ActionView
handle_render_error(view, e)
end
def mime_type
ActiveSupport::Deprecation.warn 'Template#mime_type is deprecated and will be removed in Rails 4.1. Please use type method instead.'
@mime_type ||= Mime::Type.lookup_by_extension(@formats.first.to_s) if @formats.first
end
def type
@type ||= Types[@formats.first] if @formats.first
end

View file

@ -59,6 +59,13 @@ class TestERBTemplate < ActiveSupport::TestCase
@context = Context.new
end
def test_mime_type_is_deprecated
template = new_template
assert_deprecated 'Template#mime_type is deprecated and will be removed' do
template.mime_type
end
end
def test_basic_template
@template = new_template
assert_equal "Hello", render