public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/
@ 2011-06-02 17:18 Petteri Räty
  0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-06-02 17:18 UTC (permalink / raw
  To: gentoo-commits

commit:     046bc843cbe26a7d8b47d586416e41a9def60327
Author:     Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Fri May 27 11:35:10 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue May 31 10:29:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/recruiting-webapp.git;a=commit;h=046bc843

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-02 17:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-02 17:18 [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/ Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox