GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Ensure routing optimizations are cleared when new routes are added [#981 
state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
al2o3cr (author)
Sun Sep 07 08:21:34 -0700 2008
josh (committer)
Sun Sep 07 08:21:34 -0700 2008
commit  7e6cda15f8dae517f9605f73aa1c966a29d4930a
tree    822f74af40156d11fdcbd3031b0534bc8126e1f3
parent  41efd73887c00ffd228b05d9346ec47a1f3759b9
...
147
148
149
 
 
 
 
 
 
 
 
 
150
151
152
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
0
@@ -147,6 +147,15 @@ module ActionController
0
             end
0
           }, __FILE__, __LINE__
0
         end
0
+
0
+ def clear_recognize_optimized!
0
+ instance_eval %{
0
+ def recognize_optimized(path, environment)
0
+ write_recognize_optimized!
0
+ recognize_optimized(path, environment)
0
+ end
0
+ }, __FILE__, __LINE__
0
+ end
0
     end
0
   end
0
 end
...
195
196
197
198
 
199
200
201
...
217
218
219
220
 
221
222
223
...
195
196
197
 
198
199
200
201
...
217
218
219
 
220
221
222
223
0
@@ -195,7 +195,7 @@ module ActionController
0
         self.routes = []
0
         self.named_routes = NamedRouteCollection.new
0
 
0
- write_recognize_optimized!
0
+ clear_recognize_optimized!
0
       end
0
 
0
       # Subclasses and plugins may override this method to specify a different
0
@@ -217,7 +217,7 @@ module ActionController
0
         @routes_by_controller = nil
0
         # This will force routing/recognition_optimization.rb
0
         # to refresh optimisations.
0
- @compiled_recognize_optimized = nil
0
+ clear_recognize_optimized!
0
       end
0
 
0
       def install_helpers(destinations = [ActionController::Base, ActionView::Base], regenerate_code = false)
...
1375
1376
1377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1378
1379
1380
...
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
0
@@ -1375,6 +1375,36 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do
0
         x.send(:foo_with_requirement_url, "I am Against the requirements")
0
       end
0
     end
0
+
0
+ def test_routes_changed_correctly_after_clear
0
+ ActionController::Base.optimise_named_routes = true
0
+ rs = ::ActionController::Routing::RouteSet.new
0
+ rs.draw do |r|
0
+ r.connect 'ca', :controller => 'ca', :action => "aa"
0
+ r.connect 'cb', :controller => 'cb', :action => "ab"
0
+ r.connect 'cc', :controller => 'cc', :action => "ac"
0
+ r.connect ':controller/:action/:id'
0
+ r.connect ':controller/:action/:id.:format'
0
+ end
0
+
0
+ hash = rs.recognize_path "/cc"
0
+
0
+ assert_not_nil hash
0
+ assert_equal %w(cc ac), [hash[:controller], hash[:action]]
0
+
0
+ rs.draw do |r|
0
+ r.connect 'cb', :controller => 'cb', :action => "ab"
0
+ r.connect 'cc', :controller => 'cc', :action => "ac"
0
+ r.connect ':controller/:action/:id'
0
+ r.connect ':controller/:action/:id.:format'
0
+ end
0
+
0
+ hash = rs.recognize_path "/cc"
0
+
0
+ assert_not_nil hash
0
+ assert_equal %w(cc ac), [hash[:controller], hash[:action]]
0
+
0
+ end
0
   end
0
 
0
   class RouteTest < Test::Unit::TestCase

Comments

    No one has commented yet.