Permalink
Browse files

Merged r9379 from trunk.

git-svn-id: http://redmine.rubyforge.org/svn/branches/1.3-stable@9394 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information...
jplang
jplang committed Apr 14, 2012
1 parent d4f9cb3 commit e047e2d8abf69add9475f4f35af42118e237ee24
Showing with 38 additions and 3 deletions.
  1. +1 −3 app/controllers/admin_controller.rb
  2. +5 −0 app/models/user.rb
  3. +32 −0 test/unit/user_test.rb
@@ -73,9 +73,7 @@ def test_email
def info
@db_adapter_name = ActiveRecord::Base.connection.adapter_name
@checklist = [
- [:text_default_administrator_account_changed,
- User.find(:first,
- :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?],
+ [:text_default_administrator_account_changed, User.default_admin_account_changed?],
[:text_file_repository_writable, File.writable?(Attachment.storage_path)],
[:text_plugin_assets_writable, File.writable?(Engines.public_directory)],
[:text_rmagick_available, Object.const_defined?(:Magick)]
View
@@ -343,6 +343,11 @@ def self.find_by_mail(mail)
find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase])
end
+ # Returns true if the default admin account can no longer be used
+ def self.default_admin_account_changed?
+ !User.active.find_by_login("admin").try(:check_password?, "admin")
+ end
+
def to_s
name
end
View
@@ -574,6 +574,38 @@ def test_rss_key
end
end
+ def test_default_admin_account_changed_should_return_false_if_account_was_not_changed
+ user = User.find_by_login("admin")
+ user.password = "admin"
+ user.save!
+
+ assert_equal false, User.default_admin_account_changed?
+ end
+
+ def test_default_admin_account_changed_should_return_true_if_password_was_changed
+ user = User.find_by_login("admin")
+ user.password = "newpassword"
+ user.save!
+
+ assert_equal true, User.default_admin_account_changed?
+ end
+
+ def test_default_admin_account_changed_should_return_true_if_account_is_disabled
+ user = User.find_by_login("admin")
+ user.password = "admin"
+ user.status = User::STATUS_LOCKED
+ user.save!
+
+ assert_equal true, User.default_admin_account_changed?
+ end
+
+ def test_default_admin_account_changed_should_return_true_if_account_does_not_exist
+ user = User.find_by_login("admin")
+ user.destroy
+
+ assert_equal true, User.default_admin_account_changed?
+ end
+
def test_roles_for_project
# user with a role
roles = @jsmith.roles_for_project(Project.find(1))

0 comments on commit e047e2d

Please sign in to comment.