From 89c5b9aee7d7db95cec9e5a934c3761872ab107e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 11 Mar 2011 18:06:10 -0800 Subject: do not automatically add format to routes that end in a slash --- .../test/action_dispatch/routing/mapper_test.rb | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 actionpack/test/action_dispatch/routing/mapper_test.rb (limited to 'actionpack/test/action_dispatch') diff --git a/actionpack/test/action_dispatch/routing/mapper_test.rb b/actionpack/test/action_dispatch/routing/mapper_test.rb new file mode 100644 index 0000000000..9966234f1b --- /dev/null +++ b/actionpack/test/action_dispatch/routing/mapper_test.rb @@ -0,0 +1,51 @@ +require 'abstract_unit' + +module ActionDispatch + module Routing + class MapperTest < ActiveSupport::TestCase + class FakeSet + attr_reader :routes + + def initialize + @routes = [] + end + + def resources_path_names + {} + end + + def request_class + ActionDispatch::Request + end + + def add_route(*args) + routes << args + end + + def conditions + routes.map { |x| x[1] } + end + end + + def test_initialize + Mapper.new FakeSet.new + end + + def test_map_slash + fakeset = FakeSet.new + mapper = Mapper.new fakeset + mapper.match '/', :to => 'posts#index', :as => :main + assert_equal '/', fakeset.conditions.first[:path_info] + end + + def test_map_more_slashes + fakeset = FakeSet.new + mapper = Mapper.new fakeset + + # FIXME: is this a desired behavior? + mapper.match '/one/two/', :to => 'posts#index', :as => :main + assert_equal '/one/two(.:format)', fakeset.conditions.first[:path_info] + end + end + end +end -- cgit v1.2.3