diff options
author | Azul <azul@leap.se> | 2012-12-12 15:41:14 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-12 15:41:14 +0100 |
commit | 60e8fc3e1309d1c972a7695e3344e63f5d633a06 (patch) | |
tree | d4bdc2d2e45702d5241c22404d77e8e4b2205378 /users/test | |
parent | d9fa19106998bc6ac484494334dcf150bb6aa5d5 (diff) |
find users by email and aliases
Diffstat (limited to 'users/test')
-rw-r--r-- | users/test/unit/email_aliases_test.rb | 9 | ||||
-rw-r--r-- | users/test/unit/user_test.rb | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/users/test/unit/email_aliases_test.rb b/users/test/unit/email_aliases_test.rb index e737773..5ded5bb 100644 --- a/users/test/unit/email_aliases_test.rb +++ b/users/test/unit/email_aliases_test.rb @@ -20,11 +20,12 @@ class EmailAliasTest < ActiveSupport::TestCase assert_equal email_alias, @user.email_aliases.first.to_s end - test "can retrieve user by email alias" do + test "find user by email alias" do email_alias = "valid_alias@domain.net" - @user.attributes = {:email_aliases => [email_alias]} - @user.save + @user.attributes = {:email_aliases_attributes => {"0" => {:email => email_alias}}} + assert @user.save + assert_equal @user, User.find_by_email_or_alias(email_alias) assert_equal @user, User.find_by_email_alias(email_alias) - assert_equal @user, User.find_by_email(email_alias) + assert_nil User.find_by_email(email_alias) end end diff --git a/users/test/unit/user_test.rb b/users/test/unit/user_test.rb index cce11c2..29f6a89 100644 --- a/users/test/unit/user_test.rb +++ b/users/test/unit/user_test.rb @@ -49,4 +49,13 @@ class UserTest < ActiveSupport::TestCase assert_equal client_rnd, srp_session.aa end + test "find user by email" do + email = "tryto@find.me" + @user.email = email + @user.save + assert_equal @user, User.find_by_email(email) + assert_equal @user, User.find_by_email_or_alias(email) + assert_nil User.find_by_email_alias(email) + end + end |