1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/test/omniauth/url_helpers_test.rb

48 lines
1.6 KiB
Ruby
Raw Normal View History

2010-07-16 07:42:13 -04:00
require 'test_helper'
2010-10-14 17:46:10 -04:00
class OmniAuthRoutesTest < ActionController::TestCase
2010-07-16 07:42:13 -04:00
tests ApplicationController
2010-10-14 18:44:21 -04:00
def assert_path(action, provider, with_param=true)
2010-07-16 07:42:13 -04:00
# Resource param
assert_equal @controller.send(action, :user, provider),
@controller.send("user_#{action}", provider)
# With an object
2010-10-14 18:44:21 -04:00
assert_equal @controller.send(action, User.new, provider),
@controller.send("user_#{action}", provider)
if with_param
# Default url params
assert_equal @controller.send(action, :user, provider, :param => 123),
@controller.send("user_#{action}", provider, :param => 123)
end
2010-07-16 07:42:13 -04:00
end
2010-10-14 17:46:10 -04:00
test 'should alias omniauth_callback to mapped user auth_callback' do
2010-10-14 18:44:21 -04:00
assert_path :omniauth_callback_path, :facebook
2010-07-16 07:42:13 -04:00
end
2010-10-14 17:46:10 -04:00
test 'should alias omniauth_authorize to mapped user auth_authorize' do
2010-10-14 18:44:21 -04:00
assert_path :omniauth_authorize_path, :facebook, false
2010-07-16 07:42:13 -04:00
end
2010-10-14 18:44:21 -04:00
test 'should generate authorization path' do
assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
assert_raise ArgumentError do
@controller.omniauth_authorize_path(:user, :github)
end
2010-07-16 07:42:13 -04:00
end
2010-10-30 14:04:24 -04:00
test 'should generate authorization path with params' do
assert_match "/users/auth/open_id?openid_url=http%3A%2F%2Fyahoo.com",
2010-10-30 14:04:24 -04:00
@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
2010-07-16 07:42:13 -04:00
end