diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 24 | ||||
-rw-r--r-- | actionpack/test/controller/components_test.rb | 12 | ||||
-rw-r--r-- | actionpack/test/controller/cookie_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/deprecation/deprecated_base_methods_test.rb | 11 | ||||
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/new_render_test.rb | 26 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 65 | ||||
-rw-r--r-- | actionpack/test/controller/session_management_test.rb | 14 | ||||
-rw-r--r-- | actionpack/test/controller/view_paths_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/_hash_greeting.erb | 1 |
10 files changed, 83 insertions, 80 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 1aefbfd677..75d0e17f61 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -7,10 +7,10 @@ class ActionPackAssertionsController < ActionController::Base def nothing() head :ok end # a standard template - def hello_world() render "test/hello_world"; end + def hello_world() render :template => "test/hello_world"; end # a standard template - def hello_xml_world() render "test/hello_xml_world"; end + def hello_xml_world() render :template => "test/hello_xml_world"; end # a redirect to an internal location def redirect_internal() redirect_to "/nothing"; end @@ -38,13 +38,13 @@ class ActionPackAssertionsController < ActionController::Base # putting stuff in the flash def flash_me flash['hello'] = 'my name is inigo montoya...' - render_text "Inconceivable!" + render :text => "Inconceivable!" end # we have a flash, but nothing is in it def flash_me_naked flash.clear - render_text "wow!" + render :text => "wow!" end # assign some template instance variables @@ -54,11 +54,11 @@ class ActionPackAssertionsController < ActionController::Base end def render_based_on_parameters - render_text "Mr. #{params[:name]}" + render :text => "Mr. #{params[:name]}" end def render_url - render_text "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>" + render :text => "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>" end def render_text_with_custom_content_type @@ -68,19 +68,19 @@ class ActionPackAssertionsController < ActionController::Base # puts something in the session def session_stuffing session['xmas'] = 'turkey' - render_text "ho ho ho" + render :text => "ho ho ho" end # raises exception on get requests def raise_on_get raise "get" if request.get? - render_text "request method: #{request.env['REQUEST_METHOD']}" + render :text => "request method: #{request.env['REQUEST_METHOD']}" end # raises exception on post requests def raise_on_post raise "post" if request.post? - render_text "request method: #{request.env['REQUEST_METHOD']}" + render :text => "request method: #{request.env['REQUEST_METHOD']}" end def get_valid_record @@ -310,7 +310,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase process :nothing assert !@response.rendered_with_file? - assert_deprecated(/render/) { process :hello_world } + process :hello_world assert @response.rendered_with_file? assert 'hello_world', @response.rendered_file end @@ -461,13 +461,13 @@ class ActionPackHeaderTest < Test::Unit::TestCase end def test_rendering_xml_sets_content_type - assert_deprecated(/render/) { process :hello_xml_world } + process :hello_xml_world assert_equal('application/xml; charset=utf-8', @response.headers['type']) end def test_rendering_xml_respects_content_type @response.headers['type'] = 'application/pdf' - assert_deprecated(/render/) { process :hello_xml_world } + process :hello_xml_world assert_equal('application/pdf; charset=utf-8', @response.headers['type']) end diff --git a/actionpack/test/controller/components_test.rb b/actionpack/test/controller/components_test.rb index c45a59bdbe..c046cf045a 100644 --- a/actionpack/test/controller/components_test.rb +++ b/actionpack/test/controller/components_test.rb @@ -14,15 +14,15 @@ class CallerController < ActionController::Base end def calling_from_template - render_template "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" + render :inline => "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" end def internal_caller - render_template "Are you there? <%= render_component(:action => 'internal_callee') %>" + render :inline => "Are you there? <%= render_component(:action => 'internal_callee') %>" end def internal_callee - render_text "Yes, ma'am" + render :text => "Yes, ma'am" end def set_flash @@ -38,7 +38,7 @@ class CallerController < ActionController::Base end def calling_redirected_as_string - render_template "<%= render_component(:controller => 'callee', :action => 'redirected') %>" + render :inline => "<%= render_component(:controller => 'callee', :action => 'redirected') %>" end def rescue_action(e) raise end @@ -46,11 +46,11 @@ end class CalleeController < ActionController::Base def being_called - render_text "#{params[:name] || "Lady"} of the House, speaking" + render :text => "#{params[:name] || "Lady"} of the House, speaking" end def blowing_up - render_text "It's game over, man, just game over, man!", "500 Internal Server Error" + render :text => "It's game over, man, just game over, man!", :status => 500 end def set_flash diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb index 44023b0791..e6b6045af9 100644 --- a/actionpack/test/controller/cookie_test.rb +++ b/actionpack/test/controller/cookie_test.rb @@ -33,7 +33,7 @@ class CookieTest < Test::Unit::TestCase def delete_cookie_with_path cookies.delete("user_name", :path => '/beaten') - render_text "hello world" + render :text => "hello world" end def rescue_action(e) diff --git a/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb b/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb index 7c6afd358f..6d7157e1a5 100644 --- a/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +++ b/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb @@ -2,9 +2,6 @@ require File.dirname(__FILE__) + '/../../abstract_unit' class DeprecatedBaseMethodsTest < Test::Unit::TestCase class Target < ActionController::Base - def deprecated_render_parameters - render "fun/games/hello_world" - end def home_url(greeting) "http://example.com/#{greeting}" @@ -25,14 +22,6 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase @controller = Target.new end - def test_deprecated_render_parameters - assert_deprecated("render('fun/games/hello_world')") do - get :deprecated_render_parameters - end - - assert_equal "Living in a nested world", @response.body - end - def test_log_error_silences_deprecation_warnings get :raises_name_error rescue => e diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 8adee4c12f..56aabddd31 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -234,7 +234,7 @@ class FilterTest < Test::Unit::TestCase before_filter(AuditFilter) def show - render_text "hello" + render :text => "hello" end end @@ -271,11 +271,11 @@ class FilterTest < Test::Unit::TestCase before_filter :second, :only => :foo def foo - render_text 'foo' + render :text => 'foo' end def bar - render_text 'bar' + render :text => 'bar' end protected diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index ce254cbf0d..0ef8ce141b 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -152,7 +152,15 @@ class NewRenderTestController < ActionController::Base def partial_with_hash_object render :partial => "hash_object", :object => {:first_name => "Sam"} end - + + def partial_hash_collection + render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ] + end + + def partial_hash_collection_with_locals + render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" } + end + def partial_with_implicit_local_assignment @customer = Customer.new("Marcel") render :partial => "customer" @@ -164,7 +172,7 @@ class NewRenderTestController < ActionController::Base def hello_in_a_string @customers = [ Customer.new("david"), Customer.new("mary") ] - render :text => "How's there? #{render_to_string("test/list")}" + render :text => "How's there? " << render_to_string(:template => "test/list") end def render_to_string_with_assigns @@ -203,7 +211,7 @@ class NewRenderTestController < ActionController::Base end def render_with_explicit_template - render "test/hello_world" + render :template => "test/hello_world" end def double_render @@ -622,7 +630,7 @@ EOS end def test_render_with_explicit_template - assert_deprecated(/render/) { get :render_with_explicit_template } + get :render_with_explicit_template assert_response :success end @@ -683,6 +691,16 @@ EOS get :partial_with_hash_object assert_equal "Sam", @response.body end + + def test_hash_partial_collection + get :partial_hash_collection + assert_equal "PratikAmy", @response.body + end + + def test_partial_hash_collection_with_locals + get :partial_hash_collection_with_locals + assert_equal "Hola: PratikHola: Amy", @response.body + end def test_partial_with_implicit_local_assignment get :partial_with_implicit_local_assignment diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index b6cbe7f924..3b755eb6a6 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -16,32 +16,32 @@ class TestController < ActionController::Base end def render_hello_world - render "test/hello_world" + render :template => "test/hello_world" end def render_hello_world_from_variable @person = "david" - render_text "hello #{@person}" + render :text => "hello #{@person}" end def render_action_hello_world - render_action "hello_world" + render :action => "hello_world" end def render_action_hello_world_with_symbol - render_action :hello_world + render :action => :hello_world end def render_text_hello_world - render_text "hello world" + render :text => "hello world" end def render_json_hello_world - render_json({:hello => 'world'}.to_json) + render :json => {:hello => 'world'}.to_json end def render_json_hello_world_with_callback - render_json({:hello => 'world'}.to_json, 'alert') + render :json => {:hello => 'world'}.to_json, :callback => 'alert' end def render_symbol_json @@ -49,21 +49,20 @@ class TestController < ActionController::Base end def render_custom_code - render_text "hello world", "404 Moved" - end - - def render_text_appendix - render_text "hello world" - render_text ", goodbye!", "404 Not Found", true + render :text => "hello world", :status => 404 end def render_nothing_with_appendix - render_text "appended", nil, true + render :text => "appended" + end + + def render_invalid_args + render("test/hello") end def render_xml_hello @name = "David" - render "test/hello" + render :template => "test/hello" end def heading @@ -75,34 +74,34 @@ class TestController < ActionController::Base end def layout_test - render_action "hello_world" + render :action => "hello_world" end def builder_layout_test - render_action "hello" + render :action => "hello" end def builder_partial_test - render_action "hello_world_container" + render :action => "hello_world_container" end def partials_list @test_unchanged = 'hello' @customers = [ Customer.new("david"), Customer.new("mary") ] - render_action "list" + render :action => "list" end def partial_only - render_partial + render :partial => true end def hello_in_a_string @customers = [ Customer.new("david"), Customer.new("mary") ] - render_text "How's there? #{render_to_string("test/list")}" + render :text => "How's there? " + render_to_string(:template => "test/list") end def accessing_params_in_template - render_template "Hello: <%= params[:name] %>" + render :inline => "Hello: <%= params[:name] %>" end def accessing_local_assigns_in_inline_template @@ -184,7 +183,7 @@ class RenderTest < Test::Unit::TestCase end def test_do_with_render - assert_deprecated_render { get :render_hello_world } + get :render_hello_world assert_template "test/hello_world" end @@ -229,12 +228,7 @@ class RenderTest < Test::Unit::TestCase def test_do_with_render_custom_code get :render_custom_code assert_response 404 - end - - def test_do_with_render_text_appendix - get :render_text_appendix - assert_response 404 - assert_equal 'hello world, goodbye!', @response.body + assert_equal 'hello world', @response.body end def test_do_with_render_nothing_with_appendix @@ -242,7 +236,11 @@ class RenderTest < Test::Unit::TestCase assert_response 200 assert_equal 'appended', @response.body end - + + def test_attempt_to_render_with_invalid_arguments + assert_raises(ActionController::RenderError) { get :render_invalid_args } + end + def test_attempt_to_access_object_method assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } end @@ -252,7 +250,7 @@ class RenderTest < Test::Unit::TestCase end def test_render_xml - assert_deprecated_render { get :render_xml_hello } + get :render_xml_hello assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body end @@ -416,10 +414,7 @@ class RenderTest < Test::Unit::TestCase end protected - def assert_deprecated_render(&block) - assert_deprecated(/render/, &block) - end - + def etag_for(text) %("#{Digest::MD5.hexdigest(text)}") end diff --git a/actionpack/test/controller/session_management_test.rb b/actionpack/test/controller/session_management_test.rb index 63917565ef..44fb93104c 100644 --- a/actionpack/test/controller/session_management_test.rb +++ b/actionpack/test/controller/session_management_test.rb @@ -5,11 +5,11 @@ class SessionManagementTest < Test::Unit::TestCase session :off def show - render_text "done" + render :text => "done" end def tell - render_text "done" + render :text => "done" end end @@ -20,15 +20,15 @@ class SessionManagementTest < Test::Unit::TestCase :if => Proc.new { |r| r.parameters[:ws] } def show - render_text "done" + render :text => "done" end def tell - render_text "done" + render :text => "done" end def conditional - render_text ">>>#{params[:ws]}<<<" + render :text => ">>>#{params[:ws]}<<<" end end @@ -36,11 +36,11 @@ class SessionManagementTest < Test::Unit::TestCase session :disabled => false, :only => :something def something - render_text "done" + render :text => "done" end def another - render_text "done" + render :text => "done" end end diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb index c84ced5394..67048e76b0 100644 --- a/actionpack/test/controller/view_paths_test.rb +++ b/actionpack/test/controller/view_paths_test.rb @@ -20,7 +20,7 @@ class ViewLoadPathsTest < Test::Unit::TestCase class Test::SubController < ActionController::Base layout 'test/sub' - def hello_world; render 'test/hello_world'; end + def hello_world; render(:template => 'test/hello_world'); end end def setup diff --git a/actionpack/test/fixtures/test/_hash_greeting.erb b/actionpack/test/fixtures/test/_hash_greeting.erb new file mode 100644 index 0000000000..fc54a36f2a --- /dev/null +++ b/actionpack/test/fixtures/test/_hash_greeting.erb @@ -0,0 +1 @@ +<%= greeting %>: <%= hash_greeting[:first_name] %>
\ No newline at end of file |