omniauth route should not add a ? if no param is given

This commit is contained in:
David A. Cuadrado
2010-10-31 02:44:44 +08:00
committed by José Valim
parent bf19b15914
commit 09a46695f2
2 changed files with 7 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ module Devise
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def #{mapping.name}_omniauth_authorize_path(provider, params = {})
if Devise.omniauth_configs[provider.to_sym]
"/#{mapping.path}/auth/\#{provider}?\#{params.to_param}"
"/#{mapping.path}/auth/\#{provider}\#{'?'+params.to_param if params.present?}"
else
raise ArgumentError, "Could not find omniauth provider \#{provider.inspect}"
end

View File

@@ -36,7 +36,12 @@ class OmniAuthRoutesTest < ActionController::TestCase
end
test 'should generate authorization path with params' do
assert_match "/users/auth/open_id?openid_url=http%3A%2F%2Fyahoo.com",
assert_match "/users/auth/open_id?openid_url=http%3A%2F%2Fyahoo.com",
@controller.omniauth_authorize_path(:user, :open_id, :openid_url => "http://yahoo.com")
end
test 'should not add a "?" if no param was sent' do
assert_equal "/users/auth/open_id",
@controller.omniauth_authorize_path(:user, :open_id)
end
end