From 3b631df101d911d57ac3fe97514c60ae412e3812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 7 Jan 2010 17:17:06 +0100 Subject: Ensure that segments in default_url_options also work with format specified. --- actionpack/lib/action_dispatch/routing/route_set.rb | 4 ++-- actionpack/test/controller/base_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 7752642a7b..90893aa0e6 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -178,7 +178,7 @@ module ActionDispatch # options = (default ||= {}).merge(options) # # keys = [] - # keys -= options.keys unless keys.size == args.size + # keys -= options.keys if args.size < keys.size - 1 # # args = args.zip(keys).inject({}) do |h, (v, k)| # h[k] = v @@ -202,7 +202,7 @@ module ActionDispatch options = (default ||= {}).merge(options) keys = #{route.segment_keys.inspect} - keys -= options.keys unless keys.size == args.size + keys -= options.keys if args.size < keys.size - 1 # take format into account args = args.zip(keys).inject({}) do |h, (v, k)| h[k] = v diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 3d43688902..1510a6a7e0 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -172,8 +172,16 @@ class DefaultUrlOptionsTest < ActionController::TestCase get :from_view, :route => "description_path(1)" assert_equal '/en/descriptions/1', @response.body + assert_equal '/en/descriptions', @controller.send(:descriptions_path) + assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl") + assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl") + assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml") + assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml") assert_equal '/en/descriptions/1', @controller.send(:description_path, 1) + assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1) assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl") + assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml") + assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml") end end -- cgit v1.2.3