diff options
author | Azul <azul@leap.se> | 2012-12-10 11:00:24 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-10 11:00:24 +0100 |
commit | 28b21959f39b0e28c450bba54b8696632a0187fa (patch) | |
tree | 7f13cad03190324ca0d242d3aee74bfb4efb00fa /users/test/unit/email_test.rb | |
parent | e4c7f2fb8fa2833037508f1b88f802944855fd77 (diff) |
created generic Email class and use it with EmailAliases
Diffstat (limited to 'users/test/unit/email_test.rb')
-rw-r--r-- | users/test/unit/email_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/users/test/unit/email_test.rb b/users/test/unit/email_test.rb new file mode 100644 index 0000000..d421b77 --- /dev/null +++ b/users/test/unit/email_test.rb @@ -0,0 +1,33 @@ +require 'test_helper' + +class EmailAliasTest < ActiveSupport::TestCase + + setup do + @attribs = User.valid_attributes_hash + User.find_by_login(@attribs[:login]).try(:destroy) + @user = User.new(@attribs) + end + + test "email aliases need to be unique" do + # TODO build helper for this ... make_record(User) + email_alias = "valid_alias@domain.net" + attribs = User.valid_attributes_hash.merge(:login => "other_user") + User.find_by_login(attribs[:login]).try(:destroy) + other_user = User.new(attribs) + other_user.attributes = {:email_aliases => [email_alias]} + other_user.save + @user.attributes = {:email_aliases => [email_alias]} + assert !@user.valid? + # TODO handle errors + end + + test "email aliases may not conflict with emails" do + # TODO build helper for this ... make_record(User) + email_alias = "valid_alias@domain.net" + attribs = User.valid_attributes_hash.merge(:login => "other_user", :email => email_alias) + User.find_by_login(attribs[:login]).try(:destroy) + other_user = User.new(attribs) + @user.attributes = {:email_aliases => [email_alias]} + assert !@user.valid? + end +end |