From 4ce337bbedf5fe93e639a54022f4dafea8a5eda4 Mon Sep 17 00:00:00 2001
From: maxwell <maxwell@joindiaspora.com>
Date: Sat, 20 Nov 2010 15:58:26 -0800
Subject: [PATCH] display a users username in the final step

---
 app/helpers/users_helper.rb                   | 10 ++++++++++
 .../users/getting_started/_step_4.html.haml   |  2 +-
 public/stylesheets/sass/application.sass      |  2 +-
 spec/helpers/users_helper_spec.rb             | 19 +++++++++++++++++++
 4 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 app/helpers/users_helper.rb
 create mode 100644 spec/helpers/users_helper_spec.rb

diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
new file mode 100644
index 0000000000..df56462128
--- /dev/null
+++ b/app/helpers/users_helper.rb
@@ -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
diff --git a/app/views/users/getting_started/_step_4.html.haml b/app/views/users/getting_started/_step_4.html.haml
index 24d37f5cc6..99c6c55123 100644
--- a/app/views/users/getting_started/_step_4.html.haml
+++ b/app/views/users/getting_started/_step_4.html.haml
@@ -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
diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
index 242579876a..3668e7dcd9 100644
--- a/public/stylesheets/sass/application.sass
+++ b/public/stylesheets/sass/application.sass
@@ -166,7 +166,7 @@ header
         :display block
       &:hover
         :background
-          :color #009
+          :color black
 
 
     &.active
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
new file mode 100644
index 0000000000..f88a235dab
--- /dev/null
+++ b/spec/helpers/users_helper_spec.rb
@@ -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
-- 
GitLab