Permalink
Browse files

add #initials method to user model

  • Loading branch information...
lazylester committed May 8, 2013
1 parent 7a645a2 commit 501b03112137613bcf0b330342f3d41e940b87e5
Showing with 15 additions and 0 deletions.
  1. +11 −0 app/models/user.rb
  2. +4 −0 spec/models/user_spec.rb
View
@@ -65,6 +65,17 @@ def first_last_name
firstName+' '+lastName
end
+ def initials
+ first_initial + last_initial
+ end
+
+ def first_initial
+ firstName[0].upcase
+ end
+
+ def last_initial
+ lastName[0].upcase
+ end
# Finds the user with the corresponding activation code, activates their account and returns the user.
#
View
@@ -14,3 +14,7 @@
end
end
+describe "#initials method" do
+ subject{ FactoryGirl.create(:user, :firstName => 'frank', :lastName => 'Herbert') }
+ its(:initials){ should == 'FH' }
+end

0 comments on commit 501b031

Please sign in to comment.