diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-07 17:17:06 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-07 17:17:06 +0100 |
commit | 3b631df101d911d57ac3fe97514c60ae412e3812 (patch) | |
tree | f7ed5301d70e3113422374f1d0237584a6b6f30b | |
parent | f149eb19d4675becee164fee2881a562cdaa0551 (diff) | |
download | rails-3b631df101d911d57ac3fe97514c60ae412e3812.tar.gz rails-3b631df101d911d57ac3fe97514c60ae412e3812.tar.bz2 rails-3b631df101d911d57ac3fe97514c60ae412e3812.zip |
Ensure that segments in default_url_options also work with format specified.
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/base_test.rb | 8 |
2 files changed, 10 insertions, 2 deletions
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 |