diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-08-26 03:07:30 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2013-08-26 03:07:30 -0700 |
commit | c19958015fac7b50f8dedbdf17991c00d6b8bbd4 (patch) | |
tree | 42431a33fd65c954b1242b8ff6116163c9969924 /actionview/test/actionpack/abstract/render_test.rb | |
parent | 27dc4fa28ee098d70a11829ad5fa4af0c54e880b (diff) | |
parent | 0d43df7ebf7587f032e3b16c153bf35746878c46 (diff) | |
download | rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.tar.gz rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.tar.bz2 rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.zip |
Merge pull request #11396 from strzalek/extract_renderers
Remove dependency on Action View from Action Pack
This set of changes removes the need of using Action View with Action Pack.
Now you may use controllers without Action View, by rendering `:text` response
or alternatively you can plug in your own rendering logic. This is especially
handy when you're just dealing with APIs and don't need to include entire
Action View just to render simple JSON responses.
Diffstat (limited to 'actionview/test/actionpack/abstract/render_test.rb')
-rw-r--r-- | actionview/test/actionpack/abstract/render_test.rb | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/actionview/test/actionpack/abstract/render_test.rb b/actionview/test/actionpack/abstract/render_test.rb new file mode 100644 index 0000000000..f9d8c916d9 --- /dev/null +++ b/actionview/test/actionpack/abstract/render_test.rb @@ -0,0 +1,103 @@ +require 'abstract_unit' + +module AbstractController + module Testing + + class ControllerRenderer < AbstractController::Base + include AbstractController::Rendering + include ActionView::Rendering + + def _prefixes + %w[renderer] + end + + self.view_paths = [ActionView::FixtureResolver.new( + "template.erb" => "With Template", + "renderer/default.erb" => "With Default", + "renderer/string.erb" => "With String", + "renderer/symbol.erb" => "With Symbol", + "string/with_path.erb" => "With String With Path", + "some/file.erb" => "With File" + )] + + def template + render :template => "template" + end + + def file + render :file => "some/file" + end + + def inline + render :inline => "With <%= :Inline %>" + end + + def text + render :text => "With Text" + end + + def default + render + end + + def string + render "string" + end + + def string_with_path + render "string/with_path" + end + + def symbol + render :symbol + end + end + + class TestRenderer < ActiveSupport::TestCase + + def setup + @controller = ControllerRenderer.new + end + + def test_render_template + @controller.process(:template) + assert_equal "With Template", @controller.response_body + end + + def test_render_file + @controller.process(:file) + assert_equal "With File", @controller.response_body + end + + def test_render_inline + @controller.process(:inline) + assert_equal "With Inline", @controller.response_body + end + + def test_render_text + @controller.process(:text) + assert_equal "With Text", @controller.response_body + end + + def test_render_default + @controller.process(:default) + assert_equal "With Default", @controller.response_body + end + + def test_render_string + @controller.process(:string) + assert_equal "With String", @controller.response_body + end + + def test_render_symbol + @controller.process(:symbol) + assert_equal "With Symbol", @controller.response_body + end + + def test_render_string_with_path + @controller.process(:string_with_path) + assert_equal "With String With Path", @controller.response_body + end + end + end +end |