diff options
Diffstat (limited to 'users/test/unit/email_test.rb')
-rw-r--r-- | users/test/unit/email_test.rb | 39 |
1 files changed, 39 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..1e216d6 --- /dev/null +++ b/users/test/unit/email_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' + +class EmailTest < ActiveSupport::TestCase + + setup do + # TODO build helper for this ... make_record(User) + @attribs = User.valid_attributes_hash + User.find_by_login(@attribs[:login]).try(:destroy) + @user = User.new(@attribs) + @attribs.merge!(:login => "other_user") + User.find_by_login(@attribs[:login]).try(:destroy) + @other_user = User.create(@attribs) + end + + teardown do + @user.destroy if @user.persisted? # just in case + @other_user.destroy + end + + + test "email aliases need to be unique" do + email_alias = "valid_alias@domain.net" + @other_user.add_email_alias email_alias + @other_user.save + @user.add_email_alias email_alias + assert @user.changed? + assert !@user.save + # TODO handle errors + end + + test "email aliases may not conflict with emails" do + email_alias = "valid_alias@domain.net" + @other_user.email = email_alias + @other_user.save + @user.add_email_alias email_alias + assert @user.changed? + assert !@user.save + end +end |