From a08bee784125d569f63ddd9fa875ae9c5d18b342 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 11 Sep 2011 17:14:29 -0700 Subject: all routes can be stored in the Journey Routes object --- actionpack/lib/action_dispatch/routing/route_set.rb | 9 ++++----- actionpack/test/controller/resources_test.rb | 2 +- actionpack/test/dispatch/mapper_test.rb | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 000b2a252f..2947eb3f09 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -206,16 +206,17 @@ module ActionDispatch end end - attr_accessor :formatter, :set, :routes, :named_routes, :default_scope, :router + attr_accessor :formatter, :set, :named_routes, :default_scope, :router attr_accessor :disable_clear_and_finalize, :resources_path_names attr_accessor :default_url_options, :request_class, :valid_conditions + alias :routes :set + def self.default_resources_path_names { :new => 'new', :edit => 'edit' } end def initialize(request_class = ActionDispatch::Request) - self.routes = [] self.named_routes = NamedRouteCollection.new self.resources_path_names = self.class.default_resources_path_names.dup self.default_url_options = {} @@ -274,7 +275,6 @@ module ActionDispatch def clear! @finalized = false - routes.clear named_routes.clear set.clear formatter.clear @@ -346,9 +346,8 @@ module ActionDispatch def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i) route = Route.new(self, app, conditions, requirements, defaults, name, anchor) - @set.add_route(app, route.conditions, defaults, name) + route = @set.add_route(app, route.conditions, defaults, name) named_routes[name] = route if name - routes << route route end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index b9cd15708b..6b8a8f6161 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -532,7 +532,7 @@ class ResourcesTest < ActionController::TestCase routes.each do |route| routes.each do |r| next if route === r # skip the comparison instance - assert_not_equal route.conditions, r.conditions + assert_not_equal [route.conditions, route.path.spec.to_s], [r.conditions, r.path.spec.to_s] end end end diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index 3316dd03aa..d3465589c1 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -5,6 +5,7 @@ module ActionDispatch class MapperTest < ActiveSupport::TestCase class FakeSet attr_reader :routes + alias :set :routes def initialize @routes = [] -- cgit v1.2.3