Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/
Date: Thu, 02 Jun 2011 17:18:54
Message-Id: 046bc843cbe26a7d8b47d586416e41a9def60327.betelgeuse@gentoo
1 commit: 046bc843cbe26a7d8b47d586416e41a9def60327
2 Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
3 AuthorDate: Fri May 27 11:35:10 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Tue May 31 10:29:39 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/recruiting-webapp.git;a=commit;h=046bc843
7
8 Make users with empty nick and openid valid
9
10 Bug
11 https://bugs.gentoo.org/show_bug.cgi?id=368617
12
13 ---
14 app/models/user.rb | 4 ++--
15 spec/models/user_spec.rb | 26 ++++++++++++++++++++++++++
16 2 files changed, 28 insertions(+), 2 deletions(-)
17
18 diff --git a/app/models/user.rb b/app/models/user.rb
19 index f49341d..64b8e7b 100644
20 --- a/app/models/user.rb
21 +++ b/app/models/user.rb
22 @@ -82,8 +82,8 @@ class User < ActiveRecord::Base
23 validate :recruit_cant_mentor
24 validate :mentors_and_recruiters_must_have_nick
25 validate :mentor_is_gentoo_dev_long_enough
26 - validates_uniqueness_of :nick, :if => :nick
27 - validates_uniqueness_of :openid, :if => :openid
28 + validates_uniqueness_of :nick, :allow_blank => true
29 + validates_uniqueness_of :openid, :allow_blank => true
30
31 never_show :project_lead
32
33
34 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
35 index 89d5beb..e6724d8 100644
36 --- a/spec/models/user_spec.rb
37 +++ b/spec/models/user_spec.rb
38 @@ -347,4 +347,30 @@ describe User do
39 Factory(:answer, :owner => recruit, :question => q2)
40 recruit.progress.should == "Answered 2 of 2 questions."
41 end
42 +
43 + it "should allow many users with empty nick and openid" do
44 + r1 = Factory(:recruit)
45 + r2 = Factory(:recruit)
46 +
47 + r1.nick.should be_nil
48 + r1.openid.should be_nil
49 + r1.should be_valid
50 +
51 + r2.nick.should be_nil
52 + r2.openid.should be_nil
53 + r2.should be_valid
54 +
55 + r1.id.equal?(r2.id).should be_false
56 +
57 + u3 = Factory(:recruit, :nick => '', :openid => '')
58 + u3.nick.should_not be_nil
59 + u3.openid.should_not be_nil
60 + u3.should be_valid
61 +
62 + u4 = User.new(:name => 'example', :email_address => 'example@×××××××.com', :nick => '', :openid => '')
63 + u4.nick.should_not be_nil
64 + u4.openid.should_not be_nil
65 + u4.should be_valid
66 + u4.save!
67 + end
68 end