Revision 2445
Added by Eric Davis over 16 years ago
trunk/app/controllers/account_controller.rb | ||
---|---|---|
201 | 201 |
user = User.find_or_initialize_by_identity_url(identity_url) |
202 | 202 |
if user.new_record? |
203 | 203 |
# Create on the fly |
204 |
user.login = registration['nickname'] |
|
205 |
user.mail = registration['email'] |
|
206 |
user.firstname, user.lastname = registration['fullname'].split(' ') |
|
204 |
user.login = registration['nickname'] unless registration['nickname'].nil?
|
|
205 |
user.mail = registration['email'] unless registration['email'].nil?
|
|
206 |
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
|
|
207 | 207 |
user.random_password |
208 | 208 |
if user.save |
209 | 209 |
successful_authentication(user) |
trunk/test/functional/account_controller_test.rb | ||
---|---|---|
70 | 70 |
end |
71 | 71 |
|
72 | 72 |
def test_login_with_openid_with_new_user_created |
73 |
|
|
73 |
post :login, :openid_url => 'http://openid.example.com/good_user' |
|
74 |
assert_redirected_to 'my/page' |
|
75 |
user = User.find_by_login('cool_user') |
|
76 |
assert user |
|
77 |
assert_equal 'Cool', user.firstname |
|
78 |
assert_equal 'User', user.lastname |
|
74 | 79 |
end |
75 | 80 |
|
76 |
|
|
77 |
def test_login_with_openid_with_new_user_with_conflict |
|
81 |
def test_login_with_openid_with_new_user_with_conflict_should_register |
|
82 |
existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => '[email protected]') |
|
83 |
existing_user.login = 'cool_user' |
|
84 |
assert existing_user.save! |
|
78 | 85 |
|
86 |
post :login, :openid_url => 'http://openid.example.com/good_user' |
|
87 |
assert_response :success |
|
88 |
assert_template 'register' |
|
89 |
assert assigns(:user) |
|
90 |
assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url] |
|
79 | 91 |
end |
80 | 92 |
|
81 | 93 |
def test_autologin |
trunk/test/test_helper.rb | ||
---|---|---|
19 | 19 |
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
20 | 20 |
require 'test_help' |
21 | 21 |
require File.expand_path(File.dirname(__FILE__) + '/helper_testcase') |
22 |
load File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
|
|
22 |
require File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
|
|
23 | 23 |
|
24 | 24 |
class Test::Unit::TestCase |
25 | 25 |
# Transactional fixtures accelerate your tests by wrapping each test method |
Also available in: Unified diff
Added tests for the other OpenID authentication cases. #699