Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7403

Show
Ignore:
Timestamp:
09/03/07 00:18:30 (1 year ago)
Author:
nzkoz
Message:

Remove deprecated functionality from actionpack. Closes #8958 [lifofifo]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/examples/benchmark.rb

    r6120 r7403  
    88class BenchmarkController < ActionController::Base 
    99  def message 
    10     render_text "hello world" 
     10    render :text => "hello world" 
    1111  end 
    1212 
  • trunk/actionpack/lib/action_controller/base.rb

    r7331 r7403  
    1515  end 
    1616  class MissingTemplate < ActionControllerError #:nodoc: 
     17  end 
     18  class RenderError < ActionControllerError #:nodoc: 
    1719  end 
    1820  class RoutingError < ActionControllerError #:nodoc: 
     
    613615        self.class.view_paths 
    614616      end 
    615  
     617       
    616618    protected 
    617619      # Renders the content that will be returned to the browser as the response body. 
     
    632634      #   # but with a custom layout 
    633635      #   render :action => "long_goal", :layout => "spectacular" 
    634       # 
    635       # _Deprecation_ _notice_: This used to have the signatures <tt>render_action("action", status = 200)</tt>, 
    636       # <tt>render_without_layout("controller/action", status = 200)</tt>, and 
    637       # <tt>render_with_layout("controller/action", status = 200, layout)</tt>. 
    638636      # 
    639637      # === Rendering partials 
     
    703701      #   render :file => "some/template", :use_full_path => true 
    704702      # 
    705       # _Deprecation_ _notice_: This used to have the signature <tt>render_file(path, status = 200)</tt> 
    706       # 
    707703      # === Rendering text 
    708704      # 
     
    730726      #   render :text => proc { |response, output| output.write("Hello from code!") } 
    731727      # 
    732       # _Deprecation_ _notice_: This used to have the signature <tt>render_text("text", status = 200)</tt> 
    733       # 
    734728      # === Rendering JSON 
    735729      # 
     
    760754      #   # Renders "hello david" 
    761755      #   render :inline => "<%= 'hello ' + name %>", :locals => { :name => "david" } 
    762       # 
    763       # _Deprecation_ _notice_: This used to have the signature <tt>render_template(template, status = 200, type = :rhtml)</tt> 
    764756      # 
    765757      # === Rendering inline JavaScriptGenerator page updates 
     
    778770      # 
    779771      #   render :xml => post.to_xml, :status => :created, :location => post_url(post) 
    780       def render(options = nil, deprecated_status = nil, &block) #:doc: 
     772      def render(options = nil, &block) #:doc: 
    781773        raise DoubleRenderError, "Can only render or redirect once per action" if performed? 
    782774 
    783775        if options.nil? 
    784           return render_file(default_template_name, deprecated_status, true) 
     776          return render_for_file(default_template_name, nil, true) 
    785777        else 
    786           # Backwards compatibility 
    787           unless options.is_a?(Hash) 
    788             if options == :update 
    789               options = { :update => true } 
    790             else 
    791               ActiveSupport::Deprecation.warn( 
    792                 "You called render('#{options}'), which is a deprecated API call. Instead you use " + 
    793                 "render :file => #{options}. Calling render with just a string will be removed from Rails 2.0.", 
    794                 caller 
    795               ) 
    796  
    797               return render_file(options, deprecated_status, true) 
    798             end 
     778          if options == :update 
     779            options = { :update => true } 
     780          elsif !options.is_a?(Hash) 
     781            raise RenderError, "You called render with invalid options : #{options}" 
    799782          end 
    800783        end 
     
    809792 
    810793        if text = options[:text] 
    811           render_text(text, options[:status]) 
     794          render_for_text(text, options[:status]) 
    812795 
    813796        else 
    814797          if file = options[:file] 
    815             render_file(file, options[:status], options[:use_full_path], options[:locals] || {}) 
     798            render_for_file(file, options[:status], options[:use_full_path], options[:locals] || {}) 
    816799 
    817800          elsif template = options[:template] 
    818             render_file(template, options[:status], true) 
     801            render_for_file(template, options[:status], true) 
    819802 
    820803          elsif inline = options[:inline] 
    821             render_template(inline, options[:status], options[:type], options[:locals] || {}) 
     804            add_variables_to_assigns 
     805            render_for_text(@template.render_template(options[:type] || :erb, inline, nil, options[:locals] || {}), options[:status]) 
    822806 
    823807          elsif action_name = options[:action] 
    824             ActiveSupport::Deprecation.silence do 
    825               render_action(action_name, options[:status], options[:layout]) 
    826             end 
     808            template = default_template_name(action_name.to_s) 
     809            if options[:layout] && !template_exempt_from_layout?(template) 
     810              render_with_a_layout(:file => template, :status => options[:status], :use_full_path => true, :layout => true)               
     811            else 
     812              render_with_no_layout(:file => template, :status => options[:status], :use_full_path => true) 
     813            end             
    827814 
    828815          elsif xml = options[:xml] 
    829             render_xml(xml, options[:status]) 
     816            response.content_type = Mime::XML 
     817            render_for_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, options[:status]) 
    830818 
    831819          elsif json = options[:json] 
    832             render_json(json, options[:callback], options[:status]) 
     820            json = "#{options[:callback]}(#{json})" unless options[:callback].blank? 
     821            response.content_type = Mime::JSON 
     822            render_for_text(json, options[:status]) 
    833823 
    834824          elsif partial = options[:partial] 
    835825            partial = default_template_name if partial == true 
     826            add_variables_to_assigns 
    836827            if collection = options[:collection] 
    837               render_partial_collection(partial, collection, options[:spacer_template], options[:locals], options[:status]) 
     828              render_for_text(@template.send(:render_partial_collection, partial, collection, options[:spacer_template], options[:locals]), 
     829                              options[:status]) 
    838830            else 
    839               render_partial(partial, ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals], options[:status]) 
     831              render_for_text(@template.send(:render_partial, partial, ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals]),  
     832                              options[:status])               
    840833            end 
    841834 
     
    845838 
    846839            generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block) 
    847             render_javascript(generator.to_s) 
     840            response.content_type = Mime::JS 
     841            render_for_text(generator.to_s) 
    848842 
    849843          elsif options[:nothing] 
    850844            # Safari doesn't pass the headers of the return if the response is zero length 
    851             render_text(" ", options[:status]) 
     845            render_for_text(" ", options[:status]) 
    852846 
    853847          else 
    854             render_file(default_template_name, options[:status], true) 
    855  
     848            render_for_file(default_template_name, options[:status], true) 
    856849          end 
    857850        end 
     
    861854      # of sending it as the response body to the browser. 
    862855      def render_to_string(options = nil, &block) #:doc: 
    863         ActiveSupport::Deprecation.silence { render(options, &block) } 
     856        render(options, &block) 
    864857      ensure 
    865858        erase_render_results 
     
    867860        reset_variables_added_to_assigns 
    868861      end 
    869  
    870       def render_action(action_name, status = nil, with_layout = true) #:nodoc: 
    871         template = default_template_name(action_name.to_s) 
    872         if with_layout && !template_exempt_from_layout?(template) 
    873           render_with_layout(:file => template, :status => status, :use_full_path => true, :layout => true) 
    874         else 
    875           render_without_layout(:file => template, :status => status, :use_full_path => true) 
    876         end 
    877       end 
    878  
    879       def render_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc: 
    880         add_variables_to_assigns 
    881         assert_existence_of_template_file(template_path) if use_full_path 
    882         logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger 
    883         render_text(@template.render_file(template_path, use_full_path, locals), status) 
    884       end 
    885  
    886       def render_template(template, status = nil, type = :erb, local_assigns = {}) #:nodoc: 
    887         add_variables_to_assigns 
    888         render_text(@template.render_template(type, template, nil, local_assigns), status) 
    889       end 
    890  
    891       def render_text(text = nil, status = nil, append_response = false) #:nodoc: 
    892         @performed_render = true 
    893  
    894         response.headers['Status'] = interpret_status(status || DEFAULT_RENDER_STATUS_CODE) 
    895  
    896         if append_response 
    897           response.body ||= '' 
    898           response.body << text.to_s 
    899         else 
    900           response.body = text.is_a?(Proc) ? text : text.to_s 
    901         end 
    902       end 
    903  
    904       def render_javascript(javascript, status = nil, append_response = true) #:nodoc: 
    905         response.content_type = Mime::JS 
    906         render_text(javascript, status, append_response) 
    907       end 
    908  
    909       def render_xml(xml, status = nil) #:nodoc: 
    910         response.content_type = Mime::XML 
    911         render_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, status) 
    912       end 
    913  
    914       def render_json(json, callback = nil, status = nil) #:nodoc: 
    915         json = "#{callback}(#{json})" unless callback.blank? 
    916  
    917         response.content_type = Mime::JSON 
    918         render_text(json, status) 
    919       end 
    920  
    921       def render_nothing(status = nil) #:nodoc: 
    922         render_text(' ', status) 
    923       end 
    924  
    925       def render_partial(partial_path = default_template_name, object = nil, local_assigns = nil, status = nil) #:nodoc: 
    926         add_variables_to_assigns 
    927         render_text(@template.send(:render_partial, partial_path, object, local_assigns), status) 
    928       end 
    929  
    930       def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = nil, status = nil) #:nodoc: 
    931         add_variables_to_assigns 
    932         render_text(@template.send(:render_partial_collection, partial_name, collection, partial_spacer_template, local_assigns), status) 
    933       end 
    934  
    935       def render_with_layout(template_name = default_template_name, status = nil, layout = nil) #:nodoc: 
    936         render_with_a_layout(template_name, status, layout) 
    937       end 
    938  
    939       def render_without_layout(template_name = default_template_name, status = nil) #:nodoc: 
    940         render_with_no_layout(template_name, status) 
    941       end 
    942  
    943862 
    944863      # Return a response that has no content (merely headers). The options 
     
    11021021 
    11031022    private 
     1023 
     1024      def render_for_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc: 
     1025        add_variables_to_assigns 
     1026        assert_existence_of_template_file(template_path) if use_full_path 
     1027        logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger 
     1028        render_for_text(@template.render_file(template_path, use_full_path, locals), status) 
     1029      end 
     1030 
     1031      def render_for_text(text = nil, status = nil, append_response = false) #:nodoc: 
     1032        @performed_render = true 
     1033 
     1034        response.headers['Status'] = interpret_status(status || DEFAULT_RENDER_STATUS_CODE) 
     1035 
     1036        if append_response 
     1037          response.body ||= '' 
     1038          response.body << text.to_s 
     1039        else 
     1040          response.body = text.is_a?(Proc) ? text : text.to_s 
     1041        end 
     1042      end 
     1043       
    11041044      def initialize_template_class(response) 
    11051045        raise "You must assign a template class through ActionController.template_class= before processing a request" unless @@template_class 
  • trunk/actionpack/lib/action_controller/benchmarking.rb

    r6396 r7403  
    4444      def render_with_benchmark(options = nil, deprecated_status = nil, &block) 
    4545        unless logger 
    46           render_without_benchmark(options, deprecated_status, &block) 
     46          render_without_benchmark(options, &block) 
    4747        else 
    4848          db_runtime = ActiveRecord::Base.connection.reset_runtime if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 
    4949 
    5050          render_output = nil 
    51           @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, deprecated_status, &block) }.real 
     51          @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, &block) }.real 
    5252 
    5353          if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 
  • trunk/actionpack/lib/action_controller/caching.rb

    r7346 r7403  
    233233            controller.rendered_action_cache = true 
    234234            set_content_type!(controller, cache_path.extension) 
    235             controller.send(:render_text, cache) 
     235            controller.send(:render_for_text, cache) 
    236236            false 
    237237          else 
  • trunk/actionpack/lib/action_controller/components.rb

    r6403 r7403  
    7979        def render_component(options) #:doc: 
    8080          component_logging(options) do 
    81             render_text(component_response(options, true).body, response.headers["Status"]) 
     81            render_for_text(component_response(options, true).body, response.headers["Status"]) 
    8282          end 
    8383        end 
  • trunk/actionpack/lib/action_controller/layout.rb

    r7321 r7403  
    234234 
    235235    protected 
    236       def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layout = nil, &block) #:nodoc: 
     236      def render_with_a_layout(options = nil, &block) #:nodoc: 
    237237        template_with_options = options.is_a?(Hash) 
    238238 
    239         if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options, deprecated_layout)) 
     239        if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options)) 
    240240          assert_existence_of_template_file(layout) 
    241241 
     
    243243          logger.info("Rendering template within #{layout}") if logger 
    244244 
    245           if template_with_options 
    246             content_for_layout = render_with_no_layout(options, &block) 
    247             deprecated_status = options[:status] || deprecated_status 
    248           else 
    249             content_for_layout = render_with_no_layout(options, deprecated_status, &block) 
    250           end 
    251  
     245          content_for_layout = render_with_no_layout(options, &block) 
    252246          erase_render_results 
    253247          add_variables_to_assigns 
    254248          @template.instance_variable_set("@content_for_layout", content_for_layout) 
    255249          response.layout = layout 
    256           render_text(@template.render_file(layout, true), deprecated_status
     250          render_for_text(@template.render_file(layout, true)
    257251        else 
    258           render_with_no_layout(options, deprecated_status, &block) 
     252          render_with_no_layout(options, &block) 
    259253        end 
    260254      end 
     
    273267      end 
    274268 
    275       def pick_layout(template_with_options, options, deprecated_layout) 
    276         if deprecated_layout 
    277           deprecated_layout 
    278         elsif template_with_options 
     269      def pick_layout(template_with_options, options) 
     270        if template_with_options 
    279271          case layout = options[:layout] 
    280272            when FalseClass 
  • trunk/actionpack/lib/action_controller/rescue.rb

    r6862 r7403  
    126126 
    127127        response.content_type = Mime::HTML 
    128         render_file(rescues_path("layout"), response_code_for_rescue(exception)) 
     128        render_for_file(rescues_path("layout"), response_code_for_rescue(exception)) 
    129129      end 
    130130 
  • trunk/actionpack/lib/action_view/partials.rb

    r7261 r7403  
    104104  module Partials 
    105105    private 
    106       # Deprecated, use render :partial 
    107       def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc: 
     106      def render_partial(partial_path, object_assigns = nil, local_assigns = nil) #:nodoc: 
    108107        case partial_path 
    109108        when String, Symbol, NilClass 
    110109          path, partial_name = partial_pieces(partial_path) 
    111           object = extracting_object(partial_name, local_assigns, deprecated_local_assigns) 
    112           local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns) 
     110          object = extracting_object(partial_name, object_assigns) 
    113111          local_assigns = local_assigns ? local_assigns.clone : {} 
    114112          add_counter_to_local_assigns!(partial_name, local_assigns) 
     
    126124            path       = ActionController::RecordIdentifier.partial_path(partial_path.first) 
    127125            collection = partial_path 
    128             render_partial_collection(path, collection, nil, local_assigns.value) 
     126            render_partial_collection(path, collection, nil, object_assigns.value) 
    129127          else 
    130128            "" 
     
    133131          render_partial( 
    134132            ActionController::RecordIdentifier.partial_path(partial_path), 
    135             local_assigns, deprecated_local_assigns) 
     133            object_assigns, local_assigns) 
    136134        end 
    137135      end 
    138136 
    139       # Deprecated, use render :partial, :collection 
    140137      def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = nil) #:nodoc: 
    141138        collection_of_partials = Array.new 
     
    175172      end 
    176173 
    177       def extracting_object(partial_name, local_assigns, deprecated_local_assigns) 
     174      def extracting_object(partial_name, object_assigns) 
    178175        variable_name = partial_variable_name(partial_name) 
    179         if local_assigns.is_a?(Hash) || local_assigns.nil? 
     176        if object_assigns.nil? 
    180177          controller.instance_variable_get("@#{variable_name}") 
    181178        else 
    182           # deprecated form where object could be passed in as second parameter 
    183           local_assigns 
     179          object_assigns 
    184180        end 
    185       end 
    186  
    187       def extract_local_assigns(local_assigns, deprecated_local_assigns) 
    188         local_assigns.is_a?(Hash) ? local_assigns : deprecated_local_assigns 
    189181      end 
    190182 
  • trunk/actionpack/test/controller/action_pack_assertions_test.rb

    r6722 r7403  
    88 
    99  # a standard template 
    10   def hello_world() render "test/hello_world"; end 
     10  def hello_world() render :template => "test/hello_world"; end 
    1111 
    1212  # a standard template 
    13   def hello_xml_world() render "test/hello_xml_world"; end 
     13  def hello_xml_world() render :template => "test/hello_xml_world"; end 
    1414 
    1515  # a redirect to an internal location 
     
    3939  def flash_me 
    4040    flash['hello'] = 'my name is inigo montoya...' 
    41     render_text "Inconceivable!" 
     41    render :text => "Inconceivable!" 
    4242  end 
    4343 
     
    4545  def flash_me_naked 
    4646    flash.clear 
    47     render_text "wow!" 
     47    render :text => "wow!" 
    4848  end 
    4949 
     
    5555 
    5656  def render_based_on_parameters 
    57     render_text "Mr. #{params[:name]}" 
     57    render :text => "Mr. #{params[:name]}" 
    5858  end 
    5959 
    6060  def render_url 
    61     render_text "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>" 
     61    render :text => "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>" 
    6262  end 
    6363 
     
    6969  def session_stuffing 
    7070    session['xmas'] = 'turkey' 
    71     render_text "ho ho ho" 
     71    render :text => "ho ho ho" 
    7272  end 
    7373 
     
    7575  def raise_on_get 
    7676    raise "get" if request.get? 
    77     render_text "request method: #{request.env['REQUEST_METHOD']}" 
     77    render :text => "request method: #{request.env['REQUEST_METHOD']}" 
    7878  end 
    7979 
     
    8181  def raise_on_post 
    8282    raise "post" if request.post? 
    83     render_text "request method: #{request.env['REQUEST_METHOD']}" 
     83    render :text => "request method: #{request.env['REQUEST_METHOD']}" 
    8484  end 
    8585 
     
    311311    assert !@response.rendered_with_file? 
    312312 
    313     assert_deprecated(/render/) { process :hello_world } 
     313    process :hello_world 
    314314    assert @response.rendered_with_file? 
    315315    assert 'hello_world', @response.rendered_file 
     
    462462 
    463463  def test_rendering_xml_sets_content_type 
    464     assert_deprecated(/render/) { process :hello_xml_world } 
     464    process :hello_xml_world 
    465465    assert_equal('application/xml; charset=utf-8', @response.headers['type']) 
    466466  end 
     
    468468  def test_rendering_xml_respects_content_type 
    469469    @response.headers['type'] = 'application/pdf' 
    470     assert_deprecated(/render/) { process :hello_xml_world } 
     470    process :hello_xml_world 
    471471    assert_equal('application/pdf; charset=utf-8', @response.headers['type']) 
    472472  end 
  • trunk/actionpack/test/controller/components_test.rb

    r6875 r7403  
    1515 
    1616  def calling_from_template 
    17     render_template "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" 
     17    render :inline => "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>" 
    1818  end 
    1919 
    2020  def internal_caller 
    21     render_template "Are you there? <%= render_component(:action => 'internal_callee') %>" 
     21    render :inline => "Are you there? <%= render_component(:action => 'internal_callee') %>" 
    2222  end 
    2323 
    2424  def internal_callee 
    25     render_text "Yes, ma'am" 
     25    render :text => "Yes, ma'am" 
    2626  end 
    2727 
     
    3939 
    4040  def calling_redirected_as_string 
    41     render_template "<%= render_component(:controller => 'callee', :action => 'redirected') %>" 
     41    render :inline => "<%= render_component(:controller => 'callee', :action => 'redirected') %>" 
    4242  end 
    4343 
     
    4747class CalleeController < ActionController::Base 
    4848  def being_called 
    49     render_text "#{params[:name] || "Lady"} of the House, speaking" 
     49    render :text => "#{params[:name] || "Lady"} of the House, speaking" 
    5050  end 
    5151 
    5252  def blowing_up 
    53     render_text "It's game over, man, just game over, man!", "500 Internal Server Error" 
     53    render :text => "It's game over, man, just game over, man!", :status => 500 
    5454  end 
    5555 
  • trunk/actionpack/test/controller/cookie_test.rb

    r7160 r7403  
    3434    def delete_cookie_with_path 
    3535      cookies.delete("user_name", :path => '/beaten') 
    36       render_text "hello world" 
     36      render :text => "hello world" 
    3737    end 
    3838 
  • trunk/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb

    r6412 r7403  
    33class DeprecatedBaseMethodsTest < Test::Unit::TestCase 
    44  class Target < ActionController::Base 
    5     def deprecated_render_parameters 
    6       render "fun/games/hello_world" 
    7     end 
    85     
    96    def home_url(greeting) 
     
    2623  end 
    2724 
    28   def test_deprecated_render_parameters 
    29     assert_deprecated("render('fun/games/hello_world')") do 
    30       get :deprecated_render_parameters 
    31     end 
    32  
    33     assert_equal "Living in a nested world", @response.body 
    34   end 
    35  
    3625  def test_log_error_silences_deprecation_warnings 
    3726    get :raises_name_error 
  • trunk/actionpack/test/controller/filters_test.rb

    r7177 r7403  
    235235 
    236236    def show 
    237       render_text "hello" 
     237      render :text => "hello" 
    238238    end 
    239239  end 
     
    272272 
    273273    def foo 
    274       render_text 'foo' 
     274      render :text => 'foo' 
    275275    end 
    276276 
    277277    def bar 
    278       render_text 'bar' 
     278      render :text => 'bar' 
    279279    end 
    280280 
  • trunk/actionpack/test/controller/new_render_test.rb

    r7261 r7403  
    153153    render :partial => "hash_object", :object => {:first_name => "Sam"} 
    154154  end 
    155  
     155   
     156  def partial_hash_collection 
     157    render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ] 
     158  end 
     159   
     160  def partial_hash_collection_with_locals 
     161    render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" } 
     162  end 
     163   
    156164  def partial_with_implicit_local_assignment 
    157165    @customer = Customer.new("Marcel") 
     
    165173  def hello_in_a_string 
    166174    @customers = [ Customer.new("david"), Customer.new("mary") ] 
    167     render :text =>  "How's there? #{render_to_string("test/list")}" 
     175    render :text =>  "How's there? " << render_to_string(:template => "test/list") 
    168176  end 
    169177   
     
    204212 
    205213  def render_with_explicit_template 
    206     render "test/hello_world" 
     214    render :template => "test/hello_world" 
    207215  end 
    208216 
     
    623631 
    624632  def test_render_with_explicit_template 
    625     assert_deprecated(/render/) { get :render_with_explicit_template } 
     633    get :render_with_explicit_template 
    626634    assert_response :success 
    627635  end 
     
    683691    get :partial_with_hash_object 
    684692    assert_equal "Sam", @response.body 
     693  end 
     694   
     695  def test_hash_partial_collection 
     696    get :partial_hash_collection 
     697    assert_equal "PratikAmy", @response.body 
     698  end 
     699   
     700  def test_partial_hash_collection_with_locals 
     701    get :partial_hash_collection_with_locals 
     702    assert_equal "Hola: PratikHola: Amy", @response.body 
    685703  end 
    686704 
  • trunk/actionpack/test/controller/render_test.rb

    r7309 r7403  
    1717 
    1818  def render_hello_world 
    19     render "test/hello_world" 
     19    render :template => "test/hello_world" 
    2020  end 
    2121 
    2222  def render_hello_world_from_variable 
    2323    @person = "david" 
    24     render_text "hello #{@person}" 
     24    render :text => "hello #{@person}" 
    2525  end 
    2626 
    2727  def render_action_hello_world 
    28     render_action "hello_world" 
     28    render :action => "hello_world" 
    2929  end 
    3030 
    3131  def render_action_hello_world_with_symbol 
    32     render_action :hello_world 
     32    render :action => :hello_world 
    3333  end 
    3434 
    3535  def render_text_hello_world 
    36     render_text "hello world" 
     36    render :text => "hello world" 
    3737  end 
    3838 
    3939  def render_json_hello_world 
    40     render_json({:hello => 'world'}.to_json) 
     40    render :json => {:hello => 'world'}.to_json 
    4141  end 
    4242 
    4343  def render_json_hello_world_with_callback 
    44     render_json({:hello => 'world'}.to_json, 'alert') 
     44    render :json => {:hello => 'world'}.to_json, :callback => 'alert' 
    4545  end 
    4646 
     
    5050 
    5151  def render_custom_code 
    52     render_text "hello world", "404 Moved" 
    53   end 
    54  
    55   def render_text_appendix 
    56     render_text "hello world" 
    57     render_text ", goodbye!", "404 Not Found", true 
     52    render :text => "hello world", :status => 404 
    5853  end 
    5954 
    6055  def render_nothing_with_appendix 
    61     render_text "appended", nil, true 
     56    render :text => "appended" 
     57  end 
     58   
     59  def render_invalid_args 
     60    render("test/hello") 
    6261  end 
    6362 
    6463  def render_xml_hello 
    6564    @name = "David" 
    66     render "test/hello" 
     65    render :template => "test/hello" 
    6766  end 
    6867 
     
    7675 
    7776  def layout_test 
    78     render_action "hello_world" 
     77    render :action => "hello_world" 
    7978  end 
    8079 
    8180  def builder_layout_test 
    82     render_action "hello" 
     81    render :action => "hello" 
    8382  end 
    8483 
    8584  def builder_partial_test 
    86     render_action "hello_world_container" 
     85    render :action => "hello_world_container" 
    8786  end 
    8887 
     
    9089    @test_unchanged = 'hello' 
    9190    @customers = [ Customer.new("david"), Customer.new("mary") ] 
    92     render_action "list" 
     91    render :action => "list" 
    9392  end 
    9493 
    9594  def partial_only 
    96     render_partial 
     95    render :partial => true 
    9796  end 
    9897 
    9998  def hello_in_a_string 
    10099    @customers = [ Customer.new("david"), Customer.new("mary") ] 
    101     render_text "How's there? #{render_to_string("test/list")}" 
     100    render :text => "How's there? " + render_to_string(:template => "test/list") 
    102101  end 
    103102 
    104103  def accessing_params_in_template 
    105     render_template "Hello: <%= params[:name] %>" 
     104    render :inline => "Hello: <%= params[:name] %>" 
    106105  end 
    107106 
     
    185184 
    186185  def test_do_with_render 
    187     assert_deprecated_render { get :render_hello_world } 
     186    get :render_hello_world 
    188187    assert_template "test/hello_world" 
    189188  end 
     
    230229    get :render_custom_code 
    231230    assert_response 404 
    232   end 
    233  
    234   def test_do_with_render_text_appendix 
    235     get :render_text_appendix 
    236     assert_response 404 
    237     assert_equal 'hello world, goodbye!', @response.body 
     231    assert_equal 'hello world', @response.body 
    238232  end 
    239233 
     
    243237    assert_equal 'appended', @response.body 
    244238  end 
    245  
     239   
     240  def test_attempt_to_render_with_invalid_arguments 
     241    assert_raises(ActionController::RenderError) { get :render_invalid_args } 
     242  end 
     243   
    246244  def test_attempt_to_access_object_method 
    247245    assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone } 
     
    253251 
    254252  def test_render_xml 
    255     assert_deprecated_render { get :render_xml_hello } 
     253    get :render_xml_hello 
    256254    assert_equal "<html>\n  <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body 
    257255  end 
     
    417415 
    418416  protected 
    419     def assert_deprecated_render(&block) 
    420       assert_deprecated(/render/, &block) 
    421     end 
    422  
     417   
    423418    def etag_for(text) 
    424419      %("#{Digest::MD5.hexdigest(text)}") 
  • trunk/actionpack/test/controller/session_management_test.rb

    r6253 r7403  
    66 
    77    def show 
    8       render_text "done" 
     8      render :text => "done" 
    99    end 
    1010 
    1111    def tell 
    12       render_text "done" 
     12      render :text => "done" 
    1313    end 
    1414  end 
     
    2121 
    2222    def show 
    23       render_text "done" 
     23      render :text => "done" 
    2424    end 
    2525 
    2626    def tell 
    27       render_text "done" 
     27      render :text => "done" 
    2828    end 
    2929 
    3030    def conditional 
    31       render_text ">>>#{params[:ws]}<<<" 
     31      render :text => ">>>#{params[:ws]}<<<" 
    3232    end 
    3333  end 
     
    3737 
    3838    def something 
    39       render_text "done" 
     39      render :text => "done" 
    4040    end 
    4141 
    4242    def another 
    43       render_text "done" 
     43      render :text => "done" 
    4444    end 
    4545  end 
  • trunk/actionpack/test/controller/view_paths_test.rb

    r7321 r7403  
    2121  class Test::SubController < ActionController::Base 
    2222    layout 'test/sub' 
    23     def hello_world; render 'test/hello_world'; end 
     23    def hello_world; render(:template => 'test/hello_world'); end 
    2424  end 
    2525