display a users username in the final step
This commit is contained in:
parent
9f5ba1a1ea
commit
4ce337bbed
4 changed files with 31 additions and 2 deletions
10
app/helpers/users_helper.rb
Normal file
10
app/helpers/users_helper.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
module UsersHelper
|
||||
def first_name_or_username (user)
|
||||
set_name = user.person.profile.first_name
|
||||
(set_name.nil? || set_name.empty?) ? user.username : user.person.profile.first_name
|
||||
end
|
||||
end
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
%h1
|
||||
= t('.set_up', :name => current_user.person.profile.first_name || current_user.username)
|
||||
= t('.set_up', :name => first_name_or_username(current_user))
|
||||
.description
|
||||
= t('.ready_to_share')
|
||||
%ul.inline_aspect_listing
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ header
|
|||
:display block
|
||||
&:hover
|
||||
:background
|
||||
:color #009
|
||||
:color black
|
||||
|
||||
|
||||
&.active
|
||||
|
|
|
|||
19
spec/helpers/users_helper_spec.rb
Normal file
19
spec/helpers/users_helper_spec.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
require 'spec_helper'
|
||||
|
||||
describe UsersHelper do
|
||||
describe '#first_name_or_username' do
|
||||
let(:user){ make_user }
|
||||
|
||||
it 'should display the first name if it is set' do
|
||||
first_name_or_username(user).should == user.person.profile.first_name
|
||||
end
|
||||
|
||||
it 'should display the username if the first name is empty' do
|
||||
user.person.profile.first_name = ""
|
||||
first_name_or_username(user).should == user.username
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue