Permalink
Browse files

all routes can be stored in the Journey Routes object

  • Loading branch information...
1 parent b7ccfa9 commit a08bee784125d569f63ddd9fa875ae9c5d18b342 @tenderlove tenderlove committed Sep 12, 2011
@@ -206,16 +206,17 @@ def #{selector}(*args)
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 @@ def finalize!
def clear!
@finalized = false
- routes.clear
named_routes.clear
set.clear
formatter.clear
@@ -346,9 +346,8 @@ def empty?
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
@@ -532,7 +532,7 @@ def test_restful_routes_dont_generate_duplicates
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
@@ -5,6 +5,7 @@ module Routing
class MapperTest < ActiveSupport::TestCase
class FakeSet
attr_reader :routes
+ alias :set :routes
def initialize
@routes = []

0 comments on commit a08bee7

Please sign in to comment.