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

Changeset 617

Show
Ignore:
Timestamp:
02/15/05 01:45:35 (4 years ago)
Author:
david
Message:

A hopefully more successful attempt at the Routing branch merge

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller

    • Property svn:externals changed from
      support http://dev.rubyonrails.org/svn/rails/trunk/activesupport/lib
      to
      support http://dev.rubyonrails.org/svn/rails/branches/routing/activesupport/lib
  • trunk/actionpack/lib/action_controller/assertions/action_pack_assertions.rb

    r616 r617  
    142142        end 
    143143      end 
    144  
     144       
    145145      # ensure our redirection url is an exact match 
    146146      def assert_redirect_url(url=nil, message=nil) 
     
    157157        msg = build_message(message, "<?> was not found in the location: <?>", pattern, response.redirect_url) 
    158158        assert_block(msg) { response.redirect_url_match?(pattern) } 
     159      end 
     160 
     161      # -- routing assertions -------------------------------------------------- 
     162 
     163      # Asserts that the routing of the given path is handled correctly and that the parsed options match. 
     164      # Also verifies that the provided options can be used to generate the provided path. 
     165      def assert_routing(path, options, defaults={}, extras={}, message=nil) 
     166        defaults[:controller] ||= options[:controller] # Assume given controller, 
     167        request = ActionController::TestRequest.new({}, {}, nil) 
     168        request.path_parameters = defaults.clone 
     169         
     170        ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty? # Load routes.rb if it hasn't been loaded. 
     171         
     172        generated_path, found_extras = ActionController::Routing::Routes.generate(options, request) 
     173        generated_path = generated_path.join('/') 
     174        msg = build_message(message, "found extras <?>, not <?>", found_extras, extras) 
     175        assert_block(msg) { found_extras == extras } 
     176         
     177        msg = build_message(message, "The generated path <?> did not match <?>", generated_path, path) 
     178        assert_block(msg) { path == generated_path } 
     179         
     180        request = ActionController::TestRequest.new({}, {}, nil) 
     181        request.path = path 
     182        ActionController::Routing::Routes.recognize!(request) 
     183         
     184        expected_options = options.clone 
     185        extras.each {|k,v| expected_options.delete k} 
     186         
     187        msg = build_message(message, "The recognized options <?> did not match <?>", request.path_parameters, expected_options) 
     188        assert_block(msg) { request.path_parameters == expected_options } 
    159189      end 
    160190 
  • trunk/actionpack/lib/action_controller/base.rb

    r616 r617  
    11require 'action_controller/request' 
    22require 'action_controller/response' 
     3require 'action_controller/routing' 
    34require 'action_controller/url_rewriter' 
    45require 'action_controller/support/class_attribute_accessors' 
     
    1314  end 
    1415  class MissingTemplate < ActionControllerError #:nodoc: 
     16  end 
     17  class RoutingError < ActionControllerError 
     18    attr_reader :failures 
     19    def initialize(message, failures=[]) 
     20      super(message) 
     21      @failures = failures 
     22    end 
     23  end 
     24  class UnknownController < ActionControllerError #:nodoc: 
    1525  end 
    1626  class UnknownAction < ActionControllerError #:nodoc: 
     
    206216    @@consider_all_requests_local = true 
    207217    cattr_accessor :consider_all_requests_local 
     218     
     219    # Enable or disable the collection of failure information for RoutingErrors. 
     220    # This information can be extremely useful when tweaking custom routes, but is 
     221    # pointless once routes have been tested and verified. 
     222    @@debug_routes = true 
     223    cattr_accessor :debug_routes 
    208224 
    209225    # Template root determines the base from which template references will be made. So a call to render("test/template") 
     
    261277      def controller_name 
    262278        Inflector.underscore(controller_class_name.sub(/Controller/, "")) 
     279      end 
     280       
     281      # Convert the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat". 
     282      def controller_path 
     283        components = self.name.to_s.split('::').collect { |name| name.underscore } 
     284        components[-1] = $1 if /^(.*)_controller$/ =~ components[-1] 
     285        components.shift if components.first == 'controllers' # Transitional conditional to accomodate root Controllers module 
     286        components.join('/') 
    263287      end 
    264288    end 
     
    336360          when Hash   then @url.rewrite(rewrite_options(options)) 
    337361        end 
    338       end 
    339  
    340       def module_name 
    341         @params["module"] 
    342362      end 
    343363 
     
    595615       
    596616      def initialize_current_url 
    597         @url = UrlRewriter.new(@request, controller_name, action_name
     617        @url = UrlRewriter.new(@request, @params.clone()
    598618      end 
    599619 
     
    692712 
    693713      def default_template_name(default_action_name = action_name) 
    694         module_name ? "#{module_name}/#{controller_name}/#{default_action_name}" : "#{controller_name}/#{default_action_name}" 
     714        "#{self.class.controller_path}/#{default_action_name}" 
    695715      end 
    696716  end 
  • trunk/actionpack/lib/action_controller/cgi_process.rb

    r616 r617  
    4747    end 
    4848 
     49    def query_string 
     50      return @cgi.query_string unless @cgi.query_string.nil? || @cgi.query_string.empty? 
     51      parts = env['REQUEST_URI'].split('?') 
     52      parts.shift 
     53      return parts.join('?') 
     54    end 
     55 
    4956    def query_parameters 
    50       @cgi.query_string ? CGIMethods.parse_query_parameters(@cgi.query_string) : {} 
     57      qs = self.query_string 
     58      qs.empty? ? {} : CGIMethods.parse_query_parameters(query_string) 
    5159    end 
    5260 
  • trunk/actionpack/lib/action_controller/helpers.rb

    r616 r617  
    4949        args.flatten.each do |arg| 
    5050          case arg 
    51           when Module 
    52             add_template_helper(arg) 
    53           when String, Symbol 
    54             file_name  = Inflector.underscore(arg.to_s.downcase) + '_helper' 
    55             class_name = Inflector.camelize(file_name) 
    56             begin 
    57               require_dependency(file_name) 
    58             rescue LoadError => load_error 
    59               requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] 
    60               if requiree == file_name 
    61                 raise LoadError, "Missing helper file helpers/#{file_name}.rb" 
    62               else 
    63                 raise LoadError, "Can't load file: #{requiree}" 
     51            when Module 
     52              add_template_helper(arg) 
     53            when String, Symbol 
     54              file_name  = arg.to_s.underscore + '_helper' 
     55              class_name = file_name.camelize 
     56 
     57              begin 
     58                require_dependency(file_name) 
     59              rescue LoadError => load_error 
     60                requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] 
     61                raise LoadError, requiree == file_name ? "Missing helper file helpers/#{file_name}.rb" : "Can't load file: #{requiree}" 
    6462              end 
    65             end 
    66             raise ArgumentError, "Missing #{class_name} module in helpers/#{file_name}.rb" unless Object.const_defined?(class_name) 
    67             add_template_helper(Object.const_get(class_name)) 
    68           else 
    69             raise ArgumentError, 'helper expects String, Symbol, or Module argument' 
     63 
     64              add_template_helper(class_name.constantize) 
     65            else 
     66              raise ArgumentError, 'helper expects String, Symbol, or Module argument' 
    7067          end 
    7168        end 
     
    9693          inherited_without_helper(child) 
    9794          begin 
    98             child.helper(child.controller_name
     95            child.helper(child.controller_path
    9996          rescue ArgumentError, LoadError 
    10097            # No default helper available for this controller 
  • trunk/actionpack/lib/action_controller/request.rb

    r616 r617  
    44    # Returns both GET and POST parameters in a single hash. 
    55    def parameters 
    6       @parameters ||= request_parameters.update(query_parameters) 
     6      # puts "#{request_parameters.inspect} | #{query_parameters.inspect} | #{path_parameters.inspect}" 
     7      @parameters ||= request_parameters.merge(query_parameters).merge(path_parameters).with_indifferent_access 
    78    end 
    89 
     
    7475     
    7576    def request_uri 
    76       env['REQUEST_URI'] 
     77      (%r{^\w+\://[^/]+(/.*|$)$} =~ env['REQUEST_URI']) ? $1 : env['REQUEST_URI'] # Remove domain, which webrick puts into the request_uri. 
    7778    end 
    7879 
     
    8687 
    8788    def path 
    88       request_uri ? request_uri.split('?').first : '' 
     89      path = request_uri ? request_uri.split('?').first : '' 
    8990    end 
    9091 
     
    101102      env['HTTP_HOST'] || host + port_string 
    102103    end 
     104   
     105    def path_parameters=(parameters) 
     106      @path_parameters = parameters 
     107      @parameters = nil 
     108    end 
    103109 
     110    def path_parameters 
     111      @path_parameters ||= {} 
     112    end 
     113     
    104114    #-- 
    105115    # Must be implemented in the concrete request 
  • trunk/actionpack/lib/action_controller/rescue.rb

    r616 r617  
    4949      # Overwrite to implement public exception handling (for requests answering false to <tt>local_request?</tt>). 
    5050      def rescue_action_in_public(exception) #:doc: 
    51         render_text "<html><body><h1>Application error (Rails)</h1></body></html>" 
     51        case exception 
     52          when RoutingError, UnknownAction then 
     53            render_text(IO.read(File.join(RAILS_ROOT, 'public', '404.html')), "404 Not Found") 
     54          else render_text "<html><body><h1>Application error (Rails)</h1></body></html>" 
     55        end 
    5256      end 
    5357 
     
    6771     
    6872        @headers["Content-Type"] = "text/html" 
    69         render_file(rescues_path("layout"), "500 Internal Error"
     73        render_file(rescues_path("layout"), response_code_for_rescue(exception)
    7074      end 
    7175     
     
    111115          case exception 
    112116            when MissingTemplate then "missing_template" 
     117            when RoutingError then "routing_error" 
    113118            when UnknownAction   then "unknown_action" 
    114119            when ActionView::TemplateError then "template_error" 
    115             else "diagnostics" 
     120            else raise ;"diagnostics" 
    116121          end 
    117122        ) 
     123      end 
     124       
     125      def response_code_for_rescue(exception) 
     126        case exception 
     127          when UnknownAction, RoutingError then "404 Page Not Found" 
     128          else "500 Internal Error" 
     129        end 
    118130      end 
    119131       
  • trunk/actionpack/lib/action_controller/scaffolding.rb

    r616 r617  
    150150          private 
    151151            def render#{suffix}_scaffold(action = caller_method_name(caller)) 
    152               if template_exists?("\#{controller_name}/\#{action}") 
     152              if template_exists?("\#{self.class.controller_path}/\#{action}") 
    153153                render_action(action) 
    154154              else 
  • trunk/actionpack/lib/action_controller/test_process.rb

    r616 r617  
    3232  class TestRequest < AbstractRequest #:nodoc: 
    3333    attr_accessor :cookies 
    34     attr_accessor :query_parameters, :request_parameters, :session, :env 
    35     attr_accessor :host, :path, :request_uri, :remote_addr 
     34    attr_accessor :query_parameters, :request_parameters, :path, :session, :env 
     35    attr_accessor :host, :remote_addr 
    3636 
    3737    def initialize(query_parameters = nil, request_parameters = nil, session = nil) 
     
    5959    end 
    6060     
     61    # Used to check AbstractRequest's request_uri functionality. 
     62    # Disables the use of @path and @request_uri so superclass can handle those. 
     63    def set_REQUEST_URI(value) 
     64      @env["REQUEST_URI"] = value 
     65      @request_uri = nil 
     66      @path = nil 
     67    end 
     68 
    6169    def request_uri=(uri) 
    6270      @request_uri = uri 
    6371      @path = uri.split("?").first 
    6472    end 
     73 
     74    def request_uri 
     75      @request_uri || super() 
     76    end 
     77 
     78    def path 
     79      @path || super() 
     80    end 
     81     
    6582 
    6683    private 
     
    238255          @request.env['REQUEST_METHOD'] ||= "GET" 
    239256          @request.action = action.to_s 
     257          @request.path_parameters = { :controller => @controller.class.controller_path } 
    240258          @request.parameters.update(parameters) unless parameters.nil? 
    241259          @request.session = ActionController::TestSession.new(session) unless session.nil? 
  • trunk/actionpack/lib/action_controller/url_rewriter.rb

    r616 r617  
    11module ActionController 
    22  # Rewrites URLs for Base.redirect_to and Base.url_for in the controller. 
     3 
    34  class UrlRewriter #:nodoc: 
    4     VALID_OPTIONS = [:action, :action_prefix, :action_suffix, :application_prefix, :module, :controller, :controller_prefix, :anchor, :params, :path_params, :id, :only_path, :overwrite_params, :host, :protocol ] 
    5    
    6     def initialize(request, controller, action) 
    7       @request, @controller, @action = request, controller, action 
     5    RESERVED_OPTIONS = [:anchor, :params, :path_params, :only_path, :host, :protocol] 
     6    def initialize(request, parameters) 
     7      @request, @parameters = request, parameters 
    88      @rewritten_path = @request.path ? @request.path.dup : "" 
    99    end 
    1010     
    1111    def rewrite(options = {}) 
    12       validate_options(VALID_OPTIONS, options.keys) 
    13  
    14       rewrite_url( 
    15         rewrite_path(@rewritten_path, resolve_aliases(options)),  
    16         options 
    17       ) 
    18     end 
    19  
    20     def to_s 
    21       to_str 
     12      rewrite_url(rewrite_path(options), options) 
    2213    end 
    2314 
    2415    def to_str 
    25       "#{@request.protocol}, #{@request.host_with_port}, #{@request.path}, #{@controller}, #{@action}, #{@request.parameters.inspect}" 
     16               "#{@request.protocol}, #{@request.host_with_port}, #{@request.path}, #{@parameters[:controller]}, #{@parameters[:action]}, #{@request.parameters.inspect}" 
    2617    end 
     18 
     19    alias_method :to_s, :to_str 
    2720 
    2821    private 
     
    3124        raise(ActionController::ActionControllerError, "Unknown options: #{unknown_option_keys}") unless unknown_option_keys.empty? 
    3225      end 
    33    
    34       def resolve_aliases(options) 
    35         options[:controller_prefix] = options[:module] unless options[:module].nil? 
    36         options 
    37       end 
    38  
     26           
    3927      def rewrite_url(path, options)         
    4028        rewritten_url = "" 
     
    4634        rewritten_url << build_query_string(new_parameters(options)) if options[:params] || options[:overwrite_params] 
    4735        rewritten_url << "##{options[:anchor]}" if options[:anchor] 
     36 
    4837        return rewritten_url 
    4938      end 
    5039 
    51       def rewrite_path(path, options) 
    52         include_id_in_path_params(options) 
    53  
    54         path = rewrite_action(path, options)      if options[:action] || options[:action_prefix] 
    55         path = rewrite_path_params(path, options) if options[:path_params] 
    56         path = rewrite_controller(path, options)  if options[:controller] || options[:controller_prefix] 
     40      def rewrite_path(options) 
     41        options = options.symbolize_keys 
     42        RESERVED_OPTIONS.each {|k| options.delete k} 
     43         
     44        path, extras = Routing::Routes.generate(options, @request) 
     45        path = "/#{path.join('/')}" 
     46        path += build_query_string(extras) 
     47         
    5748        return path 
    5849      end 
     
    7566          end 
    7667        end 
    77       end 
    78  
    79       def rewrite_action(path, options) 
    80         # This regex assumes that "index" actions won't be included in the URL 
    81         all, controller_prefix, action_prefix, action_suffix = 
    82           /^\/(.*)#{@controller}\/(.*)#{@action == "index" ? "" : @action}(.*)/.match(path).to_a 
    83  
    84         if @action == "index"  
    85           if action_prefix == "index"  
    86             # we broke the parsing assumption that this would be excluded, so 
    87             # don't tell action_name about our little boo-boo 
    88             path = path.sub(action_prefix, action_name(options, nil)) 
    89           elsif action_prefix && !action_prefix.empty? 
    90             path = path.sub(%r(/#{action_prefix}/?), "/" + action_name(options, action_prefix)) 
    91           else 
    92             path = path.sub(%r(#{@controller}/?$), @controller + "/" + action_name(options)) # " ruby-mode 
    93           end 
    94         else 
    95           path = path.sub( 
    96             @controller + "/" + (action_prefix || "") + @action + (action_suffix || ""),  
    97             @controller + "/" + action_name(options, action_prefix) 
    98           ) 
    99         end 
    100  
    101         if options[:controller_prefix] && !options[:controller] 
    102           ensure_slash_suffix(options, :controller_prefix) 
    103           if controller_prefix 
    104             path = path.sub(controller_prefix, options[:controller_prefix]) 
    105           else 
    106             path = options[:controller_prefix] + path 
    107           end 
    108         end 
    109          
    110         return path 
    111       end 
    112  
    113       def rewrite_controller(path, options) 
    114         all, controller_prefix = /^\/(.*?)#{@controller}/.match(path).to_a 
    115         path = "/" 
    116         path << controller_name(options, controller_prefix) 
    117         path << action_name(options) if options[:action] 
    118         path << path_params_in_list(options) if options[:path_params] 
    119         return path 
    12068      end 
    12169 
     
    175123        elements = [] 
    176124        query_string = "" 
    177  
     125         
    178126        hash.each do |key, value| 
     127          key = key.to_s 
    179128          key = CGI.escape key 
    180129          key += '[]' if value.class == Array 
    181130          value = [ value ] unless value.class == Array 
    182131          value.each { |val| elements << "#{key}=#{CGI.escape(val.to_s)}" } 
    183         end 
    184  
    185         unless elements.empty? then query_string << ("?" + elements.join("&")) end 
     132        end 
    186133         
     134        query_string << ("?" + elements.join("&")) unless elements.empty? 
    187135        return query_string 
    188136      end 
  • trunk/actionpack/lib/action_view/partials.rb

    r616 r617  
    6161          return File.dirname(partial_path), File.basename(partial_path) 
    6262        else 
    63           return controller.send(:controller_name), partial_path 
     63          return controller.class.controller_path, partial_path 
    6464        end 
    6565      end 
  • trunk/actionpack/test/controller/cookie_test.rb

    r616 r617  
    2727      cookies["login"]     = "XJ-122" 
    2828      render_text "hello world" 
    29     end 
    30  
    31     def access_frozen_cookies 
    32       @cookies["wont"] = "work" 
    3329    end 
    3430 
     
    6864  end 
    6965 
    70   def test_setting_cookie_on_frozen_instance_variable 
    71     @request.action = "access_frozen_cookies" 
    72     assert_raises(TypeError) { process_request } 
    73   end 
    74  
    7566  private 
    7667    def process_request 
  • trunk/actionpack/test/controller/helper_test.rb

    r616 r617  
    11require File.dirname(__FILE__) + '/../abstract_unit' 
     2$:.unshift(File.dirname(__FILE__) + '/../fixtures/helpers') 
     3 
     4class TestController < ActionController::Base 
     5  attr_accessor :delegate_attr 
     6  def delegate_method() end 
     7  def rescue_action(e) raise end 
     8end 
     9 
     10module Fun 
     11  class GamesController < ActionController::Base 
     12    def render_hello_world 
     13      render_template "hello: <%= stratego %>" 
     14    end 
     15 
     16    def rescue_action(e) raise end 
     17  end 
     18end 
     19 
     20module LocalAbcHelper 
     21  def a() end 
     22  def b() end 
     23  def c() end 
     24end 
    225 
    326class HelperTest < Test::Unit::TestCase 
    427  HELPER_PATHS = %w(/../fixtures/helpers) 
    5  
    6   class TestController < ActionController::Base 
    7     attr_accessor :delegate_attr 
    8     def delegate_method() end 
    9     def rescue_action(e) raise end 
    10   end 
    11  
    12   module LocalAbcHelper 
    13     def a() end 
    14     def b() end 
    15     def c() end 
    16   end 
    17  
    1828 
    1929  def setup 
     
    103113  end 
    104114 
     115  def test_helper_for_nested_controller 
     116    @request    = ActionController::TestRequest.new 
     117    @response   = ActionController::TestResponse.new 
     118    @request.action = "render_hello_world" 
     119     
     120    assert_equal "hello: Iz guuut!", Fun::GamesController.process(@request, @response).body 
     121  end 
    105122 
    106123  private 
  • trunk/actionpack/test/controller/render_test.rb

    r616 r617  
    33Customer = Struct.new("Customer", :name) 
    44 
    5 class RenderTest < Test::Unit::TestCase 
    6   class TestController < ActionController::Base 
    7     layout :determine_layout 
    8  
     5module Fun 
     6  class GamesController < ActionController::Base 
    97    def hello_world 
    108    end 
     9  end 
     10end 
    1111 
    12     def render_hello_world 
    13       render "test/hello_world" 
    14     end 
    1512 
    16     def render_hello_world_from_variable 
    17       @person = "david" 
    18       render_text "hello #{@person}" 
    19     end 
     13class TestController < ActionController::Base 
     14  layout :determine_layout 
    2015 
    21     def render_action_hello_world 
    22       render_action "hello_world" 
    23     end 
    24      
    25     def render_text_hello_world 
    26       render_text "hello world" 
    27     end 
    28  
    29     def render_custom_code 
    30       render_text "hello world", "404 Moved" 
    31     end 
    32      
    33     def render_xml_hello 
    34       @name = "David" 
    35       render "test/hello" 
    36     end 
    37  
    38     def greeting 
    39       # let's just rely on the template 
    40     end 
    41  
    42     def layout_test 
    43       render_action "hello_world" 
    44     end 
    45      
    46     def builder_layout_test 
    47       render_action "hello" 
    48     end 
    49  
    50     def partials_list 
    51       @customers = [ Customer.new("david"), Customer.new("mary") ] 
    52       render_action "list" 
    53     end 
    54  
    55     def modgreet 
    56     end 
    57  
    58     def rescue_action(e) raise end 
    59        
    60     private 
    61       def determine_layout 
    62         case action_name  
    63           when "layout_test":         "layouts/standard" 
    64           when "builder_layout_test": "layouts/builder" 
    65         end 
    66       end 
     16  def hello_world 
    6717  end 
    6818 
    69   TestController.template_root = File.dirname(__FILE__) + "/../fixtures/" 
    70    
    71   class TestLayoutController < ActionController::Base 
    72     layout "layouts/standard" 
    73      
    74     def hello_world 
    75     end 
    76      
    77     def hello_world_outside_layout 
    78     end 
    79  
    80     def rescue_action(e) 
    81       raise unless ActionController::MissingTemplate === e 
    82     end 
     19  def render_hello_world 
     20    render "test/hello_world" 
    8321  end 
    8422 
     23  def render_hello_world_from_variable 
     24    @person = "david" 
     25    render_text "hello #{@person}" 
     26  end 
     27 
     28  def render_action_hello_world 
     29    render_action "hello_world" 
     30  end 
     31   
     32  def render_text_hello_world 
     33    render_text "hello world" 
     34  end 
     35 
     36  def render_custom_code 
     37    render_text "hello world", "404 Moved" 
     38  end 
     39   
     40  def render_xml_hello 
     41    @name = "David" 
     42    render "test/hello" 
     43  end 
     44 
     45  def greeting 
     46    # let's just rely on the template 
     47  end 
     48 
     49  def layout_test 
     50    render_action "hello_world" 
     51  end 
     52   
     53  def builder_layout_test 
     54    render_action "hello" 
     55  end 
     56 
     57  def partials_list 
     58    @customers = [ Customer.new("david"), Customer.new("mary") ] 
     59    render_action "list" 
     60  end 
     61 
     62  def rescue_action(e) raise end 
     63     
     64  private 
     65    def determine_layout 
     66      case action_name  
     67        when "layout_test":         "layouts/standard" 
     68        when "builder_layout_test": "layouts/builder" 
     69      end 
     70    end 
     71end 
     72 
     73TestController.template_root = File.dirname(__FILE__) + "/../fixtures/" 
     74 
     75class TestLayoutController < ActionController::Base 
     76  layout "layouts/standard" 
     77   
     78  def hello_world 
     79  end 
     80   
     81  def hello_world_outside_layout 
     82  end 
     83 
     84  def rescue_action(e) 
     85    raise unless ActionController::MissingTemplate === e 
     86  end 
     87end 
     88 
     89class RenderTest < Test::Unit::TestCase 
    8590  def setup 
    8691    @request    = ActionController::TestRequest.new 
     
    171176  end 
    172177 
    173   def test_module_rendering 
    174     @request.action = "modgreet" 
    175     @request.parameters["module"] = "scope" 
    176     assert_equal "<p>Beautiful modules!</p>", process_request.body 
     178  def test_nested_rendering 
     179    @request.action = "hello_world" 
     180    assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body 
    177181  end 
    178182 
  • trunk/actionpack/test/controller/request_test.rb

    r616 r617  
    3232    assert_equal ":8080", @request.port_string 
    3333  end 
     34   
     35  def test_request_uri 
     36    @request.set_REQUEST_URI "http://www.rubyonrails.org/path/of/some/uri?mapped=1" 
     37    assert_equal "/path/of/some/uri?mapped=1", @request.request_uri 
     38    assert_equal "/path/of/some/uri", @request.path 
     39     
     40    @request.set_REQUEST_URI "http://www.rubyonrails.org/path/of/some/uri" 
     41    assert_equal "/path/of/some/uri", @request.request_uri 
     42    assert_equal "/path/of/some/uri", @request.path 
     43 
     44    @request.set_REQUEST_URI "/path/of/some/uri" 
     45    assert_equal "/path/of/some/uri", @request.request_uri 
     46    assert_equal "/path/of/some/uri", @request.path 
     47 
     48    @request.set_REQUEST_URI "/" 
     49    assert_equal "/", @request.request_uri 
     50    assert_equal "/", @request.path 
     51 
     52    @request.set_REQUEST_URI "/?m=b" 
     53    assert_equal "/?m=b", @request.request_uri 
     54    assert_equal "/", @request.path 
     55  end 
    3456 
    3557  def test_host_with_port 
  • trunk/activerecord/lib/active_record

    • Property svn:externals changed from
      support http://dev.rubyonrails.org/svn/rails/trunk/activesupport/lib
      to
      support http://dev.rubyonrails.org/svn/rails/branches/routing/activesupport/lib
  • trunk/activesupport/CHANGELOG

    r616 r617  
    22 
    33* Added IndifferentAccess as a way to wrap a hash by a symbol-based store that also can be accessed by string keys 
     4 
     5* Added Inflector.constantize to turn "Admin::User" into a reference for the constant Admin::User 
     6 
     7* Added that Inflector.camelize and Inflector.underscore can deal with modules like turning "Admin::User" into "admin/user" and back 
    48 
    59* Added Inflector.humanize to turn attribute names like employee_salary into "Employee salary". Used by automated error reporting in AR. 
  • trunk/activesupport/lib/core_ext/hash/indifferent_access.rb

    r616 r617  
    99  end 
    1010   
    11   alias_method :regular_read, :[] 
     11  alias_method :regular_reader, :[] unless method_defined?(:regular_reader) 
    1212   
    1313  def [](key) 
    1414    case key 
    15       when Symbol: regular_read(key) || regular_read(key.to_s) 
    16       when String: regular_read(key) || regular_read(key.to_sym) 
    17       else regular_read(key) 
     15      when Symbol: regular_reader(key) || regular_reader(key.to_s) 
     16      when String: regular_reader(key) || regular_reader(key.to_sym) 
     17      else regular_reader(key) 
    1818    end 
    1919  end 
    2020 
    21&nb