From bfe7d518a78714d70d3d50a2ddf5621057f5b6a0 Mon Sep 17 00:00:00 2001 From: moro Date: Sun, 15 Feb 2009 19:35:08 +0900 Subject: fix test data, should specify encoding to use multibyte chars on Ruby 1.9 Signed-off-by: Jeremy Kemper --- actionpack/test/controller/routing_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/test/controller/routing_test.rb') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index d6fc6fddb2..1caed33c59 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1134,6 +1134,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase assert_equal({:controller => "content", :action => 'show_page', :id => 'foo'}, rs.recognize_path("/page/foo")) token = "\321\202\320\265\320\272\321\201\321\202" # 'text' in russian + token.force_encoding("UTF-8") if token.respond_to?(:force_encoding) escaped_token = CGI::escape(token) assert_equal '/page/' + escaped_token, rs.generate(:controller => 'content', :action => 'show_page', :id => token) -- cgit v1.2.3 From f7a0a394f48a0f21e686f891546d17ce33c7840e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sat, 7 Feb 2009 14:44:50 +0000 Subject: Remove hardcoded number_of_capturesin ControllerSegment to allow regexp requirements with capturing parentheses Signed-off-by: Michael Koziarski [#1887 state:committed] --- actionpack/test/controller/routing_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/controller/routing_test.rb') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 1caed33c59..d3fe62e28e 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -852,6 +852,15 @@ class LegacyRouteSetTests < Test::Unit::TestCase assert_equal '/content/foo', rs.generate(:controller => "content", :action => "foo") end + def test_route_with_regexp_and_captures_for_controller + rs.draw do |map| + map.connect ':controller/:action/:id', :controller => /admin\/(accounts|users)/ + end + assert_equal({:controller => "admin/accounts", :action => "index"}, rs.recognize_path("/admin/accounts")) + assert_equal({:controller => "admin/users", :action => "index"}, rs.recognize_path("/admin/users")) + assert_raises(ActionController::RoutingError) { rs.recognize_path("/admin/products") } + end + def test_route_with_regexp_and_dot rs.draw do |map| map.connect ':controller/:action/:file', -- cgit v1.2.3 From 3248553d3299cbb723f1b4103c16bad7ecdd24a6 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 16 Jan 2009 09:16:18 +0000 Subject: Fix requirements regexp for path segments Signed-off-by: Michael Koziarski [#1772 state:committed] --- actionpack/test/controller/routing_test.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'actionpack/test/controller/routing_test.rb') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index d3fe62e28e..13ba0c30dd 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -340,6 +340,30 @@ class ControllerSegmentTest < Test::Unit::TestCase end end +class PathSegmentTest < Test::Unit::TestCase + def segment(options = {}) + unless @segment + @segment = ROUTING::PathSegment.new(:path, options) + end + @segment + end + + def test_regexp_chunk_should_return_string + segment = segment(:regexp => /[a-z]+/) + assert_kind_of String, segment.regexp_chunk + end + + def test_regexp_chunk_should_be_wrapped_with_parenthesis + segment = segment(:regexp => /[a-z]+/) + assert_equal "([a-z]+)", segment.regexp_chunk + end + + def test_regexp_chunk_should_respect_options + segment = segment(:regexp => /[a-z]+/i) + assert_equal "((?i-mx:[a-z]+))", segment.regexp_chunk + end +end + class RouteBuilderTest < Test::Unit::TestCase def builder @builder ||= ROUTING::RouteBuilder.new -- cgit v1.2.3