Created
May 14, 2011 02:18
-
-
Save AquaGeek/971668 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #4554
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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