aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb19
-rw-r--r--actionpack/test/controller/basic_rendering_test.rb19
2 files changed, 16 insertions, 22 deletions
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index 2d58e1440c..d965cb8c16 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -6,15 +6,28 @@ module ActionController
# :api: public
def render(*args, &block)
super(*args, &block)
- text = args.first[:text]
- if text.present?
- self.response_body = text
+ opts = args.first
+ if (opts.keys & [:text, :nothing]).present?
+ self.response_body = if opts.has_key?(:text) && opts[:text].present?
+ opts[:text]
+ elsif opts.has_key?(:nothing) && opts[:nothing]
+ " "
+ end
+ else
+ raise UnsupportedOperationError
end
end
def rendered_format
Mime::TEXT
end
+
+ class UnsupportedOperationError < StandardError
+ def initialize
+ super "Unsupported render operation. BasicRendering supports only :text
+ and :nothing options. For more, you need to include ActionView."
+ end
+ end
end
module Rendering
diff --git a/actionpack/test/controller/basic_rendering_test.rb b/actionpack/test/controller/basic_rendering_test.rb
deleted file mode 100644
index 2db3cff395..0000000000
--- a/actionpack/test/controller/basic_rendering_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'abstract_unit'
-
-class BasicRenderingController < ActionController::Base
- def render_hello_world
- render text: "Hello World!"
- end
-end
-
-class BasicRenderingTest < ActionController::TestCase
- tests BasicRenderingController
-
- def test_render_hello_world
- get :render_hello_world
-
- assert_equal "Hello World!", @response.body
- assert_equal "text/plain", @response.content_type
- end
-end
- \ No newline at end of file