Sfoglia il codice sorgente

Makes User.find_by_mail case-insensitive (password reminder #2322, repo users mapping).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2122 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/0.9.0
Jean-Philippe Lang 15 anni fa
parent
commit
72d0843c1f
3 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 5
    0
      app/models/user.rb
  2. 1
    1
      test/integration/account_test.rb
  3. 6
    0
      test/unit/user_test.rb

+ 5
- 0
app/models/user.rb Vedi File

@@ -178,6 +178,11 @@ class User < ActiveRecord::Base
token = Token.find_by_action_and_value('autologin', key)
token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil
end
# Makes find_by_mail case-insensitive
def self.find_by_mail(mail)
find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase])
end

# Sort users by their display names
def <=>(user)

+ 1
- 1
test/integration/account_test.rb Vedi File

@@ -44,7 +44,7 @@ class AccountTest < ActionController::IntegrationTest
assert_response :success
assert_template "account/lost_password"
post "account/lost_password", :mail => 'jsmith@somenet.foo'
post "account/lost_password", :mail => 'jSmith@somenet.foo'
assert_redirected_to "account/login"
token = Token.find(:first)

+ 6
- 0
test/unit/user_test.rb Vedi File

@@ -158,4 +158,10 @@ class UserTest < Test::Unit::TestCase
@jsmith.pref.comments_sorting = 'desc'
assert @jsmith.wants_comments_in_reverse_order?
end
def test_find_by_mail_should_be_case_insensitive
u = User.find_by_mail('JSmith@somenet.foo')
assert_not_nil u
assert_equal 'jsmith@somenet.foo', u.mail
end
end

Loading…
Annulla
Salva