Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Rails Lighthouse ticket #4554

View deprecate_render_text_with_proc.diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
From 973908db21410d2f7099a2efe275224028ecc3cc Mon Sep 17 00:00:00 2001
From: Trotter Cashion <cashion@gmail.com>
Date: Mon, 13 Sep 2010 20:01:05 -0400
Subject: [PATCH] We deprecated render :text => lambda { ... } [#4554 state:resolved]
 
---
actionpack/lib/action_view/render/rendering.rb | 3 +++
actionpack/test/abstract/render_test.rb | 8 ++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
 
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb
index 5320245..bde3d53 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/render/rendering.rb
@@ -38,6 +38,9 @@ module ActionView
handler = Template.handler_class_for_extension(options[:type] || "erb")
Template.new(options[:inline], "inline template", handler, {})
elsif options.key?(:text)
+ if options[:text].is_a?(Proc)
+ ActiveSupport::Deprecation.warn "render :text => lambda { ... } is deprecated. Use self.response_body = ... instead"
+ end
Template::Text.new(options[:text], formats.try(:first))
elsif options.key?(:file)
with_fallbacks { find_template(options[:file], options[:prefix]) }
diff --git a/actionpack/test/abstract/render_test.rb b/actionpack/test/abstract/render_test.rb
index 25dc8bd..82c2a4a 100644
--- a/actionpack/test/abstract/render_test.rb
+++ b/actionpack/test/abstract/render_test.rb
@@ -35,6 +35,10 @@ module AbstractController
render :text => "With Text"
end
+ def text_with_proc
+ render :text => lambda { "In a proc!" }
+ end
+
def default
render
end
@@ -78,6 +82,10 @@ module AbstractController
assert_equal "With Text", @controller.response_body
end
+ def test_render_text_with_proc
+ assert_deprecated { @controller.process(:text_with_proc) }
+ end
+
def test_render_default
@controller.process(:default)
assert_equal "With Default", @controller.response_body
--
1.7.2
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.