--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<loadpath>\r
+ <pathentry path="" type="src"/>\r
+ <pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>\r
+</loadpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>trunk_fixes</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.rubypeople.rdt.core.rubybuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.rubypeople.rdt.core.rubynature</nature>\r
+ <nature>org.radrails.rails.core.railsnature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Sun Nov 09 21:42:24 CET 2008\r
+eclipse.preferences.version=1\r
+encoding//app/helpers/ifpdf_helper.rb=UTF-8\r
+encoding//test/fixtures/mail_handler=UTF-8\r
+encoding/lang=UTF-8\r
# update hashed_password if password was set
self.hashed_password = User.hash_password(self.password) if self.password
end
+
+ def reload(*args)
+ @name = nil
+ super
+ end
def self.active
with_scope :find => { :conditions => [ "status = ?", STATUS_ACTIVE ] } do
# Return user's full name for display
def name(formatter = nil)
- f = USER_FORMATS[formatter || Setting.user_format] || USER_FORMATS[:firstname_lastname]
- eval '"' + f + '"'
+ @name ||= eval('"' + (USER_FORMATS[formatter || Setting.user_format] || USER_FORMATS[:firstname_lastname]) + '"')
end
def active?
token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil
end
+ # Sort users by their display names
def <=>(user)
- if user.nil?
- -1
- elsif lastname.to_s.downcase == user.lastname.to_s.downcase
- firstname.to_s.downcase <=> user.firstname.to_s.downcase
- else
- lastname.to_s.downcase <=> user.lastname.to_s.downcase
- end
+ self.to_s.downcase <=> user.to_s.downcase
end
def to_s
def test_name_format
assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname)
Setting.user_format = :firstname_lastname
- assert_equal 'John Smith', @jsmith.name
+ assert_equal 'John Smith', @jsmith.reload.name
Setting.user_format = :username
- assert_equal 'jsmith', @jsmith.name
+ assert_equal 'jsmith', @jsmith.reload.name
end
def test_lock