From 49834e088bf8d02a4f75793a42868f2aea8749a4 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 29 Apr 2009 17:32:39 -0700 Subject: Support implicit render and blank render --- .../test/new_base/render_implicit_action_test.rb | 32 +++++++++++----------- actionpack/test/new_base/render_test.rb | 18 ++++++++++++ actionpack/test/new_base/test_helper.rb | 20 ++++++++++++++ 3 files changed, 54 insertions(+), 16 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/new_base/render_implicit_action_test.rb b/actionpack/test/new_base/render_implicit_action_test.rb index 3afa444e3e..58f5cec181 100644 --- a/actionpack/test/new_base/render_implicit_action_test.rb +++ b/actionpack/test/new_base/render_implicit_action_test.rb @@ -4,25 +4,25 @@ module RenderImplicitAction class SimpleController < ::ApplicationController self.view_paths = [ActionView::Template::FixturePath.new( "render_implicit_action/simple/hello_world.html.erb" => "Hello world!", - "render_implicit_action/simple/hyphen-ated.html.erb" => "Hello hyphen-ated" + "render_implicit_action/simple/hyphen-ated.html.erb" => "Hello hyphen-ated!" )] def hello_world() end end - # class TestImplicitRender < SimpleRouteCase - # describe "render a simple action with new explicit call to render" - # - # get "/render_implicit_action/simple/hello_world" - # assert_body "Hello world!" - # assert_status 200 - # end - # - # class TestImplicitWithSpecialCharactersRender < SimpleRouteCase - # describe "render an action with a missing method and has special characters" - # - # get "/render_implicit_action/simple/hyphen-ated" - # assert_body "Hello hyphen-ated!" - # assert_status 200 - # end + class TestImplicitRender < SimpleRouteCase + describe "render a simple action with new explicit call to render" + + get "/render_implicit_action/simple/hello_world" + assert_body "Hello world!" + assert_status 200 + end + + class TestImplicitWithSpecialCharactersRender < SimpleRouteCase + describe "render an action with a missing method and has special characters" + + get "/render_implicit_action/simple/hyphen-ated" + assert_body "Hello hyphen-ated!" + assert_status 200 + end end \ No newline at end of file diff --git a/actionpack/test/new_base/render_test.rb b/actionpack/test/new_base/render_test.rb index 9ad79124b8..93bc8d854c 100644 --- a/actionpack/test/new_base/render_test.rb +++ b/actionpack/test/new_base/render_test.rb @@ -1,6 +1,24 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module Render + class BlankRenderController < ActionController::Base2 + self.view_paths = [ActionView::Template::FixturePath.new( + "render/blank_render/index.html.erb" => "Hello world!" + )] + + def index + render + end + end + + class TestBlankRender < SimpleRouteCase + describe "Render with blank" + + get "/render/blank_render" + assert_body "Hello world!" + assert_status 200 + end + class DoubleRenderController < ActionController::Base2 def index render :text => "hello" diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb index b40cbb163f..03af5a66a6 100644 --- a/actionpack/test/new_base/test_helper.rb +++ b/actionpack/test/new_base/test_helper.rb @@ -58,11 +58,31 @@ module ActionController end end + def render(action = action_name, options = {}) + if action.is_a?(Hash) + options, action = action, nil + else + options.merge! :action => action + end + + super(options) + end + def render_to_body(options = {}) options = {:template => options} if options.is_a?(String) super end + def process_action + ret = super + render if response_body.nil? + ret + end + + def respond_to_action?(action_name) + super || view_paths.find_by_parts(action_name, {:formats => formats, :locales => [I18n.locale]}, controller_path) + end + # append_view_path File.join(File.dirname(__FILE__), '..', 'fixtures') CORE_METHODS = self.public_instance_methods -- cgit v1.2.3