]> source.dussan.org Git - redmine.git/commitdiff
Added tests for the other OpenID authentication cases. #699
authorEric Davis <edavis@littlestreamsoftware.com>
Wed, 11 Feb 2009 19:07:23 +0000 (19:07 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Wed, 11 Feb 2009 19:07:23 +0000 (19:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2445 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/account_controller.rb
test/functional/account_controller_test.rb
test/test_helper.rb

index cdbca5927bb268f318b82e6af862fbea0468cd98..09c11927cc4630dd2b1753fdc98e474978fe66f4 100644 (file)
@@ -201,9 +201,9 @@ private
         user = User.find_or_initialize_by_identity_url(identity_url)
         if user.new_record?
           # Create on the fly
-          user.login = registration['nickname']
-          user.mail = registration['email']
-          user.firstname, user.lastname = registration['fullname'].split(' ')
+          user.login = registration['nickname'] unless registration['nickname'].nil?
+          user.mail = registration['email'] unless registration['email'].nil?
+          user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
           user.random_password
           if user.save
             successful_authentication(user)
index 8de6f64b51b4c6d1a21a41ff8ba40c137b1b9586..e262b3716758555e6417c7838512426707e69749 100644 (file)
@@ -70,12 +70,24 @@ class AccountControllerTest < Test::Unit::TestCase
   end
 
   def test_login_with_openid_with_new_user_created
-
+    post :login, :openid_url => 'http://openid.example.com/good_user'
+    assert_redirected_to 'my/page'
+    user = User.find_by_login('cool_user')
+    assert user
+    assert_equal 'Cool', user.firstname
+    assert_equal 'User', user.lastname
   end
   
-  
-  def test_login_with_openid_with_new_user_with_conflict
+  def test_login_with_openid_with_new_user_with_conflict_should_register
+    existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com')
+    existing_user.login = 'cool_user'
+    assert existing_user.save!
     
+    post :login, :openid_url => 'http://openid.example.com/good_user'
+    assert_response :success
+    assert_template 'register'
+    assert assigns(:user)
+    assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url]
   end
   
   def test_autologin
index 57866d49e59021b51fe4533494166736fb857e27..ebc9bae46f3e7365eb59c637c68136e1abf4a13e 100644 (file)
@@ -19,7 +19,7 @@ ENV["RAILS_ENV"] ||= "test"
 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
 require 'test_help'
 require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
-load File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
+require File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
 
 class Test::Unit::TestCase
   # Transactional fixtures accelerate your tests by wrapping each test method