Permalink
Browse files

Remove deprecated support to :text in render

  • Loading branch information...
rafaelfranca committed May 21, 2016
1 parent 57e1c99 commit 79a5ea9eadb4d43b62afacedc0706cbe88c54496
@@ -11,8 +11,8 @@ def test(html)
class AssertMultipartSelectMailer < ActionMailer::Base
def test(options)
mail subject: "Test e-mail", from: "test@test.host", to: "test <test@test.host>" do |format|
format.text { render text: options[:text] }
format.html { render text: options[:html] }
format.text { render plain: options[:text] }
format.html { render plain: options[:html] }
end
end
end
@@ -18,7 +18,7 @@ def mail_with_i18n_subject(recipient)
class TestController < ActionController::Base
def send_mail
email = I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver_now
render text: "Mail sent - Subject: #{email.subject}"
render plain: "Mail sent - Subject: #{email.subject}"
end
end
@@ -62,8 +62,8 @@ def implicit_with_locale(hash = {})
def explicit_multipart(hash = {})
attachments["invoice.pdf"] = "This is test File content" if hash.delete(:attachments)
mail(hash) do |format|
format.text { render text: "TEXT Explicit Multipart" }
format.html { render text: "HTML Explicit Multipart" }
format.text { render plain: "TEXT Explicit Multipart" }
format.html { render plain: "HTML Explicit Multipart" }
end
end
@@ -76,7 +76,7 @@ def explicit_multipart_templates(hash = {})
def explicit_multipart_with_any(hash = {})
mail(hash) do |format|
format.any(:text, :html) { render text: "Format with any!" }
format.any(:text, :html) { render plain: "Format with any!" }
end
end
View
@@ -1,3 +1,7 @@
* Remove deprecated support to `:text` in `render`.
*Rafael Mendonça França*
* Remove deprecated support to `:nothing` in `render`.
*Rafael Mendonça França*
@@ -4,7 +4,7 @@ module ActionController
module Rendering
extend ActiveSupport::Concern
RENDER_FORMATS_IN_PRIORITY = [:body, :text, :plain, :html]
RENDER_FORMATS_IN_PRIORITY = [:body, :plain, :html]
module ClassMethods
# Documentation at ActionController::Renderer#render
@@ -83,17 +83,6 @@ def _normalize_args(action=nil, options={}, &blk) #:nodoc:
def _normalize_options(options) #:nodoc:
_normalize_text(options)
if options[:text]
ActiveSupport::Deprecation.warn <<-WARNING.squish
`render :text` is deprecated because it does not actually render a
`text/plain` response. Switch to `render plain: 'plain text'` to
render as `text/plain`, `render html: '<strong>HTML</strong>'` to
render as `text/html`, or `render body: 'raw'` to match the deprecated
behavior and render with the default Content-Type, which is
`text/html`.
WARNING
end
if options[:html]
options[:html] = ERB::Util.html_escape(options[:html])
end
@@ -23,10 +23,6 @@ def two
def plain
render plain: "Hi from plain", status: 500
end
def text
render text: "Hi from text", status: 500
end
end
class RenderersApiTest < ActionController::TestCase
@@ -49,12 +45,4 @@ def test_render_plain
assert_response :internal_server_error
assert_equal("Hi from plain", @response.body)
end
def test_render_text
assert_deprecated do
get :text
end
assert_response :internal_server_error
assert_equal("Hi from text", @response.body)
end
end

This file was deleted.

Oops, something went wrong.
@@ -426,7 +426,7 @@ def _default_layout(formats, require_layout = false)
end
def _include_layout?(options)
(options.keys & [:body, :text, :plain, :html, :inline, :partial]).empty? || options.key?(:layout)
(options.keys & [:body, :plain, :html, :inline, :partial]).empty? || options.key?(:layout)
end
end
end
@@ -22,8 +22,6 @@ def determine_template(options)
if options.key?(:body)
Template::Text.new(options[:body])
elsif options.key?(:text)
Template::Text.new(options[:text], formats.first)
elsif options.key?(:plain)
Template::Text.new(options[:plain])
elsif options.key?(:html)
@@ -40,7 +38,7 @@ def determine_template(options)
find_template(options[:template], options[:prefixes], false, keys, @details)
end
else
raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file, :plain, :html, :text or :body option."
raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file, :plain, :html or :body option."
end
end
@@ -55,7 +55,7 @@ def test_render_file_template
def test_render_text_template
Rails.stub(:root, File.expand_path(FIXTURE_LOAD_PATH)) do
@view.render(text: "TEXT")
@view.render(plain: "TEXT")
wait
assert_equal 2, @logger.logged(:info).size
@@ -285,7 +285,7 @@ def render_from_helper
class AssertionsTest < ActionView::TestCase
def render_from_helper
form_tag("/foo") do
safe_concat render(text: "<ul><li>foo</li></ul>")
safe_concat render(plain: "<ul><li>foo</li></ul>")
end
end
helper_method :render_from_helper
@@ -375,7 +375,7 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
class ::OmgController < ActionController::Base
def index
flash[:cool_story] = true
render text: "ok"
render plain: "ok"
end
end
Oops, something went wrong.

0 comments on commit 79a5ea9

Please sign in to comment.