public
Description: El Dorado is a full-stack community web application written in Ruby/Rails.
Homepage: http://almosteffortless.com/eldorado/
Clone URL: git://github.com/trevorturk/el-dorado.git
adding test for email validation on user create
trevorturk (author)
Thu May 08 18:16:50 -0700 2008
commit  a4192e855521846688b6c5d5fab3032f2a7ed1cb
tree    f729a56f408de29054177ff6eb778330cbbcf1b7
parent  4c88596a2bcc67b35f50d956116041c5cfac66f2
...
40
41
42
 
43
44
45
46
47
48
49
50
51
...
40
41
42
43
44
45
46
 
 
 
47
48
49
0
@@ -40,12 +40,10 @@ class User < ActiveRecord::Base
0
   validates_presence_of :login, :email, :password_hash
0
   validates_uniqueness_of :login, :case_sensitive => false
0
   validates_length_of :login, :maximum => 25
0
+ validates_format_of :email, :on => :create, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
0
   validates_confirmation_of :password, :on => :create
0
   validates_confirmation_of :password, :on => :update, :allow_blank => true
0
   
0
- validates_format_of :email, :on => :create,
0
- :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
0
-
0
   before_create :set_defaults
0
   
0
   composed_of :tz, :class_name => 'TZInfo::Timezone', :mapping => %w( time_zone time_zone )
...
171
172
173
 
 
 
 
 
 
 
174
175
176
...
171
172
173
174
175
176
177
178
179
180
181
182
183
0
@@ -171,6 +171,13 @@ class UsersControllerTest < Test::Unit::TestCase
0
     assert_template "new"
0
     assert_equal num_users, User.count
0
   end
0
+
0
+ def test_should_not_create_user_without_valid_email
0
+ num_users = User.count
0
+ post :create, :user => {:login => 'test', :email => 'not_valid', :password => 'test'}
0
+ assert_template "new"
0
+ assert_equal num_users, User.count
0
+ end
0
 
0
   def test_should_not_create_user_without_password_confirmation
0
     num_users = User.count

Comments

    No one has commented yet.