aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-05-27 13:35:10 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-05-31 12:29:39 +0200
commit046bc843cbe26a7d8b47d586416e41a9def60327 (patch)
treed32fe80f3c566a0da2e2645f1918157bef348fe6
parentAdd developer role (diff)
downloadrecruiting-webapp-046bc843cbe26a7d8b47d586416e41a9def60327.tar.gz
recruiting-webapp-046bc843cbe26a7d8b47d586416e41a9def60327.tar.bz2
recruiting-webapp-046bc843cbe26a7d8b47d586416e41a9def60327.zip
Make users with empty nick and openid valid
Bug https://bugs.gentoo.org/show_bug.cgi?id=368617
-rw-r--r--app/models/user.rb4
-rw-r--r--spec/models/user_spec.rb26
2 files changed, 28 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index f49341d..64b8e7b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -82,8 +82,8 @@ class User < ActiveRecord::Base
validate :recruit_cant_mentor
validate :mentors_and_recruiters_must_have_nick
validate :mentor_is_gentoo_dev_long_enough
- validates_uniqueness_of :nick, :if => :nick
- validates_uniqueness_of :openid, :if => :openid
+ validates_uniqueness_of :nick, :allow_blank => true
+ validates_uniqueness_of :openid, :allow_blank => true
never_show :project_lead
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 89d5beb..e6724d8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -347,4 +347,30 @@ describe User do
Factory(:answer, :owner => recruit, :question => q2)
recruit.progress.should == "Answered 2 of 2 questions."
end
+
+ it "should allow many users with empty nick and openid" do
+ r1 = Factory(:recruit)
+ r2 = Factory(:recruit)
+
+ r1.nick.should be_nil
+ r1.openid.should be_nil
+ r1.should be_valid
+
+ r2.nick.should be_nil
+ r2.openid.should be_nil
+ r2.should be_valid
+
+ r1.id.equal?(r2.id).should be_false
+
+ u3 = Factory(:recruit, :nick => '', :openid => '')
+ u3.nick.should_not be_nil
+ u3.openid.should_not be_nil
+ u3.should be_valid
+
+ u4 = User.new(:name => 'example', :email_address => 'example@example.com', :nick => '', :openid => '')
+ u4.nick.should_not be_nil
+ u4.openid.should_not be_nil
+ u4.should be_valid
+ u4.save!
+ end
end