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

Changeset 4444

Show
Ignore:
Timestamp:
06/07/06 16:27:14 (3 years ago)
Author:
minam
Message:

Make sure passed routing options are not mutated by routing code. (closes #5314)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4438 r4444  
    11*SVN* 
     2 
     3* Make sure passed routing options are not mutated by routing code. #5314 [Blair Zajac] 
    24 
    35* Make sure changing the controller from foo/bar to bing/bang does not change relative to foo. [Jamis Buck] 
  • trunk/actionpack/lib/action_controller/routing.rb

    r4443 r4444  
    671671      # and requirements. 
    672672      def divide_route_options(segments, options) 
    673         requirements = options.delete(:requirements) || {} 
    674         defaults     = options.delete(:defaults)     || {} 
    675         conditions   = options.delete(:conditions)   || {} 
     673        options = options.dup 
     674        requirements = (options.delete(:requirements) || {}).dup 
     675        defaults     = (options.delete(:defaults)     || {}).dup 
     676        conditions   = (options.delete(:conditions)   || {}).dup 
    676677 
    677678        path_keys = segments.collect { |segment| segment.key if segment.respond_to?(:key) }.compact 
  • trunk/actionpack/test/controller/routing_test.rb

    r4443 r4444  
    864864 
    865865class RouteBuilderTest < Test::Unit::TestCase 
    866    
     866 
    867867  def builder 
    868     @bulider ||= ROUTING::RouteBuilder.new 
    869   end 
    870    
     868    @builder ||= ROUTING::RouteBuilder.new 
     869  end 
     870 
     871  def build(path, options) 
     872    builder.build(path, options) 
     873  end 
     874 
     875  def test_options_should_not_be_modified 
     876    requirements1 = { :id => /\w+/, :controller => /(?:[a-z](?:-?[a-z]+)*)/ } 
     877    requirements2 = requirements1.dup 
     878 
     879    assert_equal requirements1, requirements2 
     880 
     881    with_options(:controller => 'folder', 
     882                 :requirements => requirements2) do |m| 
     883      m.build 'folders/new', :action => 'new' 
     884    end 
     885 
     886    assert_equal requirements1, requirements2 
     887  end 
     888 
    871889  def test_segment_for_static 
    872890    segment, rest = builder.segment_for 'ulysses'