From 046bc843cbe26a7d8b47d586416e41a9def60327 Mon Sep 17 00:00:00 2001 From: Joachim Filip Ignacy Bartosik Date: Fri, 27 May 2011 13:35:10 +0200 Subject: Make users with empty nick and openid valid Bug https://bugs.gentoo.org/show_bug.cgi?id=368617 --- app/models/user.rb | 4 ++-- spec/models/user_spec.rb | 26 ++++++++++++++++++++++++++ 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 -- cgit v1.2.3-65-gdbad