Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for url generation to accept stringified keys. #1571

Merged
merged 1 commit into from Jan 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion padrino-core/lib/padrino-core/application/routing.rb
Expand Up @@ -580,7 +580,7 @@ def url(*args)
name = names[0, 2].join(" ").to_sym # route name is concatenated with underscores
if params.is_a?(Hash)
params[:format] = params[:format].to_s unless params[:format].nil?
params = value_to_param(params)
params = value_to_param(params.symbolize_keys)
end
url =
if params_array.empty?
Expand Down
8 changes: 8 additions & 0 deletions padrino-core/test/test_routing.rb
Expand Up @@ -284,6 +284,14 @@ class FooError < RuntimeError; end
assert_equal "https://example.org/hash/1", body
end

should 'generate absolute urls from stringified keys' do
mock_app do
get(:hash, with: :id) { absolute_url(:hash, "id" => 1) }
end
get "/hash/2"
assert_equal "http://example.org/hash/1", body
end

should 'generate proper absolute urls for mounted apps' do
class Test < Padrino::Application
get :foo do
Expand Down