aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/journey
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-14 18:04:49 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-14 18:06:48 -0700
commita293812bffbc6e634e1a6e6794e9dec537d522a3 (patch)
tree9fe55f6939904b9244599e625de58c77b62f1dbb /actionpack/test/journey
parent09d846e7b81cb9e5ff891c91874b4108ce3156ec (diff)
downloadrails-a293812bffbc6e634e1a6e6794e9dec537d522a3.tar.gz
rails-a293812bffbc6e634e1a6e6794e9dec537d522a3.tar.bz2
rails-a293812bffbc6e634e1a6e6794e9dec537d522a3.zip
only keep one hash of named routes
The outer router object already keeps a hash of named routes, so we should just use that.
Diffstat (limited to 'actionpack/test/journey')
-rw-r--r--actionpack/test/journey/router_test.rb11
-rw-r--r--actionpack/test/journey/routes_test.rb16
2 files changed, 14 insertions, 13 deletions
diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb
index bddfbe7ef0..8a1414de8e 100644
--- a/actionpack/test/journey/router_test.rb
+++ b/actionpack/test/journey/router_test.rb
@@ -8,9 +8,10 @@ module ActionDispatch
def setup
@app = Routing::RouteSet::Dispatcher.new({})
- @routes = Routes.new
- @router = Router.new(@routes)
- @formatter = Formatter.new(@routes)
+ @route_set = ActionDispatch::Routing::RouteSet.new
+ @routes = @route_set.router.routes
+ @router = @route_set.router
+ @formatter = @route_set.formatter
end
class FakeRequestFeeler < ActionDispatch::Request
@@ -184,8 +185,8 @@ module ActionDispatch
def test_knows_what_parts_are_missing_from_named_route
route_name = "gorby_thunderhorse"
- path = Path::Pattern.build("/foo/:id", { :id => /\d+/ }, ['/', '.', '?'], false)
- add_route nil, path, {}, [], {}, route_name
+ mapper = ActionDispatch::Routing::Mapper.new @route_set
+ mapper.get "/foo/:id", :as => route_name, :id => /\d+/, :to => "foo#bar"
error = assert_raises(ActionController::UrlGenerationError) do
@formatter.generate(route_name, { }, { })
diff --git a/actionpack/test/journey/routes_test.rb b/actionpack/test/journey/routes_test.rb
index 01566f0148..bbe3228bf2 100644
--- a/actionpack/test/journey/routes_test.rb
+++ b/actionpack/test/journey/routes_test.rb
@@ -6,7 +6,9 @@ module ActionDispatch
attr_reader :routes
def setup
- @routes = Routes.new
+ @route_set = ActionDispatch::Routing::RouteSet.new
+ @routes = @route_set.router.routes
+ @router = @route_set.router
super
end
@@ -64,13 +66,11 @@ module ActionDispatch
end
def test_first_name_wins
- one = Path::Pattern.from_string '/hello'
- two = Path::Pattern.from_string '/aaron'
-
- add_route nil, one, {}, [], {}, 'aaron'
- add_route nil, two, {}, [], {}, 'aaron'
-
- assert_equal '/hello', routes.named_routes['aaron'].path.spec.to_s
+ mapper = ActionDispatch::Routing::Mapper.new @route_set
+ mapper.get "/hello", to: "foo#bar", as: 'aaron'
+ assert_raise(ArgumentError) do
+ mapper.get "/aaron", to: "foo#bar", as: 'aaron'
+ end
end
end
end