aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Medenwald <brandon@simplymadeapps.com>2016-06-09 08:36:07 -0500
committerSean Griffin <sean@seantheprogrammer.com>2016-06-09 09:36:07 -0400
commitf12c42fff2e0719a95477e40c6be24baeee3b9bd (patch)
treea486385415e22bb765fcb09162d7a32d032487f4
parent6990fd3e2a9d59fde83e9bd34697641c44cb1674 (diff)
downloadrails-f12c42fff2e0719a95477e40c6be24baeee3b9bd.tar.gz
rails-f12c42fff2e0719a95477e40c6be24baeee3b9bd.tar.bz2
rails-f12c42fff2e0719a95477e40c6be24baeee3b9bd.zip
render_to_string Regression Outside of Real Requests in Rails 5.0.0.rc1 (#25308)
* Restore the functionality of PR#14129, but do so with not nil to better indicate the purpose of the conditional * Add a test when render_to_string called on ActionController::Base.new()
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb2
-rw-r--r--actionpack/test/controller/render_test.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index a6fb0dbe1d..4ba2c26949 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -122,7 +122,7 @@ module AbstractController
def _normalize_render(*args, &block)
options = _normalize_args(*args, &block)
#TODO: remove defined? when we restore AP <=> AV dependency
- if defined?(request) && request.variant.present?
+ if defined?(request) && !request.nil? && request.variant.present?
options[:variant] = request.variant
end
_normalize_options(options)
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index f42efd35af..8d3134630d 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -564,6 +564,13 @@ class MetalRenderTest < ActionController::TestCase
end
end
+class ActionControllerBaseRenderTest < ActionController::TestCase
+ def test_direct_render_to_string
+ ac = ActionController::Base.new()
+ assert_equal "Hello world!", ac.render_to_string(template: 'test/hello_world')
+ end
+end
+
class ImplicitRenderTest < ActionController::TestCase
tests ImplicitRenderTestController