Commit 141aa503ee3d7a4e0652c934e2502927cdf352e8
1 parent
5ac2e9b7
Exists in
master
and in
29 other branches
ActionItem411: fallback to login if name is blank
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1894 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
7 additions
and
1 deletions
Show diff stats
app/models/person.rb
@@ -100,7 +100,7 @@ class Person < Profile | @@ -100,7 +100,7 @@ class Person < Profile | ||
100 | hacked_after_create :insert_default_homepage_and_feed | 100 | hacked_after_create :insert_default_homepage_and_feed |
101 | 101 | ||
102 | def name | 102 | def name |
103 | - if !self[:name].nil? | 103 | + if !self[:name].blank? |
104 | self[:name] | 104 | self[:name] |
105 | else | 105 | else |
106 | self.user ? self.user.login : nil | 106 | self.user ? self.user.login : nil |
test/unit/person_test.rb
@@ -219,6 +219,12 @@ class PersonTest < Test::Unit::TestCase | @@ -219,6 +219,12 @@ class PersonTest < Test::Unit::TestCase | ||
219 | assert_equal 'randomhacker', p.name | 219 | assert_equal 'randomhacker', p.name |
220 | end | 220 | end |
221 | 221 | ||
222 | + should 'fallback to login when name is blank' do | ||
223 | + p = create_user('randomhacker').person | ||
224 | + p.name = '' | ||
225 | + assert_equal 'randomhacker', p.name | ||
226 | + end | ||
227 | + | ||
222 | should 'have favorite enterprises' do | 228 | should 'have favorite enterprises' do |
223 | p = create_user('test_person').person | 229 | p = create_user('test_person').person |
224 | e = Enterprise.create!(:name => 'test_ent', :identifier => 'test_ent') | 230 | e = Enterprise.create!(:name => 'test_ent', :identifier => 'test_ent') |