Allow a route to have :format => true
When format is true, it is mandatory (as opposed to :format => false). This is currently not possible with resource routes, which automatically make format optional by default.
This commit is contained in:
parent
8e0061128e
commit
b9c9142603
@ -119,6 +119,8 @@ def normalize_path(path)
|
|||||||
path
|
path
|
||||||
elsif path.include?(":format") || path.end_with?('/')
|
elsif path.include?(":format") || path.end_with?('/')
|
||||||
path
|
path
|
||||||
|
elsif @options[:format] == true
|
||||||
|
"#{path}.:format"
|
||||||
else
|
else
|
||||||
"#{path}(.:format)"
|
"#{path}(.:format)"
|
||||||
end
|
end
|
||||||
|
@ -83,6 +83,13 @@ def test_map_wildcard_with_format_false
|
|||||||
assert_equal '/*path', fakeset.conditions.first[:path_info]
|
assert_equal '/*path', fakeset.conditions.first[:path_info]
|
||||||
assert_nil fakeset.requirements.first[:path]
|
assert_nil fakeset.requirements.first[:path]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_map_wildcard_with_format_true
|
||||||
|
fakeset = FakeSet.new
|
||||||
|
mapper = Mapper.new fakeset
|
||||||
|
mapper.match '/*path', :to => 'pages#show', :format => true
|
||||||
|
assert_equal '/*path.:format', fakeset.conditions.first[:path_info]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user