Skip to content

Commit 79a5ea9

Browse files
committed
Remove deprecated support to :text in render
1 parent 57e1c99 commit 79a5ea9

File tree

21 files changed

+84
-293
lines changed

21 files changed

+84
-293
lines changed

actionmailer/test/assert_select_email_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def test(html)
1111
class AssertMultipartSelectMailer < ActionMailer::Base
1212
def test(options)
1313
mail subject: "Test e-mail", from: "test@test.host", to: "test <test@test.host>" do |format|
14-
format.text { render text: options[:text] }
15-
format.html { render text: options[:html] }
14+
format.text { render plain: options[:text] }
15+
format.html { render plain: options[:html] }
1616
end
1717
end
1818
end

actionmailer/test/i18n_with_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def mail_with_i18n_subject(recipient)
1818
class TestController < ActionController::Base
1919
def send_mail
2020
email = I18nTestMailer.mail_with_i18n_subject("test@localhost").deliver_now
21-
render text: "Mail sent - Subject: #{email.subject}"
21+
render plain: "Mail sent - Subject: #{email.subject}"
2222
end
2323
end
2424

actionmailer/test/mailers/base_mailer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def implicit_with_locale(hash = {})
6262
def explicit_multipart(hash = {})
6363
attachments["invoice.pdf"] = "This is test File content" if hash.delete(:attachments)
6464
mail(hash) do |format|
65-
format.text { render text: "TEXT Explicit Multipart" }
66-
format.html { render text: "HTML Explicit Multipart" }
65+
format.text { render plain: "TEXT Explicit Multipart" }
66+
format.html { render plain: "HTML Explicit Multipart" }
6767
end
6868
end
6969

@@ -76,7 +76,7 @@ def explicit_multipart_templates(hash = {})
7676

7777
def explicit_multipart_with_any(hash = {})
7878
mail(hash) do |format|
79-
format.any(:text, :html) { render text: "Format with any!" }
79+
format.any(:text, :html) { render plain: "Format with any!" }
8080
end
8181
end
8282

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated support to `:text` in `render`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated support to `:nothing` in `render`.
26

37
*Rafael Mendonça França*

actionpack/lib/action_controller/metal/rendering.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ActionController
44
module Rendering
55
extend ActiveSupport::Concern
66

7-
RENDER_FORMATS_IN_PRIORITY = [:body, :text, :plain, :html]
7+
RENDER_FORMATS_IN_PRIORITY = [:body, :plain, :html]
88

99
module ClassMethods
1010
# Documentation at ActionController::Renderer#render
@@ -83,17 +83,6 @@ def _normalize_args(action=nil, options={}, &blk) #:nodoc:
8383
def _normalize_options(options) #:nodoc:
8484
_normalize_text(options)
8585

86-
if options[:text]
87-
ActiveSupport::Deprecation.warn <<-WARNING.squish
88-
`render :text` is deprecated because it does not actually render a
89-
`text/plain` response. Switch to `render plain: 'plain text'` to
90-
render as `text/plain`, `render html: '<strong>HTML</strong>'` to
91-
render as `text/html`, or `render body: 'raw'` to match the deprecated
92-
behavior and render with the default Content-Type, which is
93-
`text/html`.
94-
WARNING
95-
end
96-
9786
if options[:html]
9887
options[:html] = ERB::Util.html_escape(options[:html])
9988
end

actionpack/test/controller/api/renderers_test.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ def two
2323
def plain
2424
render plain: "Hi from plain", status: 500
2525
end
26-
27-
def text
28-
render text: "Hi from text", status: 500
29-
end
3026
end
3127

3228
class RenderersApiTest < ActionController::TestCase
@@ -49,12 +45,4 @@ def test_render_plain
4945
assert_response :internal_server_error
5046
assert_equal("Hi from plain", @response.body)
5147
end
52-
53-
def test_render_text
54-
assert_deprecated do
55-
get :text
56-
end
57-
assert_response :internal_server_error
58-
assert_equal("Hi from text", @response.body)
59-
end
6048
end

actionpack/test/controller/new_base/render_text_test.rb

Lines changed: 0 additions & 188 deletions
This file was deleted.

actionview/lib/action_view/layouts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def _default_layout(formats, require_layout = false)
426426
end
427427

428428
def _include_layout?(options)
429-
(options.keys & [:body, :text, :plain, :html, :inline, :partial]).empty? || options.key?(:layout)
429+
(options.keys & [:body, :plain, :html, :inline, :partial]).empty? || options.key?(:layout)
430430
end
431431
end
432432
end

actionview/lib/action_view/renderer/template_renderer.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def determine_template(options)
2222

2323
if options.key?(:body)
2424
Template::Text.new(options[:body])
25-
elsif options.key?(:text)
26-
Template::Text.new(options[:text], formats.first)
2725
elsif options.key?(:plain)
2826
Template::Text.new(options[:plain])
2927
elsif options.key?(:html)
@@ -40,7 +38,7 @@ def determine_template(options)
4038
find_template(options[:template], options[:prefixes], false, keys, @details)
4139
end
4240
else
43-
raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file, :plain, :html, :text or :body option."
41+
raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file, :plain, :html or :body option."
4442
end
4543
end
4644

actionview/test/template/log_subscriber_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_render_file_template
5555

5656
def test_render_text_template
5757
Rails.stub(:root, File.expand_path(FIXTURE_LOAD_PATH)) do
58-
@view.render(text: "TEXT")
58+
@view.render(plain: "TEXT")
5959
wait
6060

6161
assert_equal 2, @logger.logged(:info).size

0 commit comments

Comments
 (0)