Ensure that segments in default_url_options also work with format specified.
This commit is contained in:
parent
f149eb19d4
commit
3b631df101
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue