]> git.openstreetmap.org Git - rails.git/blobdiff - test/unit/user_test.rb
Check to see if the e-mail test works
[rails.git] / test / unit / user_test.rb
index 732b5b73a0a611d7ba837982d7628a541db8eda8..2f31da709efb913486385192a69377f3d9b4cab0 100644 (file)
@@ -36,4 +36,21 @@ class UserTest < Test::Unit::TestCase
     assert !new_user.save
     assert_equal ActiveRecord::Errors.default_error_messages[:taken], new_user.errors.on(:display_name)
   end
     assert !new_user.save
     assert_equal ActiveRecord::Errors.default_error_messages[:taken], new_user.errors.on(:display_name)
   end
+  
+  def test_email_valid
+    ok = %w{ a@s.com test@shaunmcdonald.me.uk hello_local@ping-d.ng test_local@openstreetmap.org test-local@example.com }
+    bad = %w{ hi ht@ n@ @.com help@.me.uk help"hi.me.uk }
+    
+    ok.each do |name|
+      user = users(:normal_user)
+      user.email = name
+      assert user.valid?, user.errors.full_messages
+    end
+    
+    bad.each do |name|
+      user = users(:normal_user)
+      user.email = name
+      assert !user.valid?, "#{name} is valid when it shouldn't be" 
+    end
+  end
 end
 end