Skip to content

Commit

Permalink
Remove deprecated support to :text in render
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Oct 10, 2016
1 parent 57e1c99 commit 79a5ea9
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 293 deletions.
4 changes: 2 additions & 2 deletions actionmailer/test/assert_select_email_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/test/i18n_with_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions actionmailer/test/mailers/base_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
13 changes: 1 addition & 12 deletions actionpack/lib/action_controller/metal/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions actionpack/test/controller/api/renderers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
188 changes: 0 additions & 188 deletions actionpack/test/controller/new_base/render_text_test.rb

This file was deleted.

2 changes: 1 addition & 1 deletion actionview/lib/action_view/layouts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions actionview/lib/action_view/renderer/template_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/log_subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/test_case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion railties/test/application/assets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 79a5ea9

Please sign in to comment.