diff --git a/app/models/profile.rb b/app/models/profile.rb index d6baecce33232389920a565e7abe113dfd53ead1..7764a4f28435751579d75670ca24584b2f723caf 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -81,16 +81,9 @@ class Profile < ActiveRecord::Base def from_omniauth_hash(omniauth_user_hash) mappings = {"description" => "bio", 'image' => 'image_url', - 'first_name' => 'first_name', - 'last_name' => 'last_name', + 'name' => 'first_name', 'location' => 'location', - 'name' => 'full_name' } - if(omniauth_user_hash['first_name'].blank? || omniauth_user_hash['last_name'].blank?) && omniauth_user_hash['name'].present? - first, last = omniauth_user_hash['name'].split - omniauth_user_hash['first_name'] ||= first - omniauth_user_hash['last_name'] ||= last - end update_hash = Hash[omniauth_user_hash.map {|k, v| [mappings[k], v] }] diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 9200fbef27298c7d5e5600a93c6cbec8ae72b5f2..c93984dcbe841fb17a154a94426781676cc65ff5 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -36,13 +36,20 @@ describe Profile do it 'outputs a hash that can update a diaspora profile' do profile = Profile.new - profile.from_omniauth_hash(@from_omniauth)['first_name'].should == 'bob' + profile.from_omniauth_hash(@from_omniauth)['bio'].should == 'this is my bio' end it 'does not overwrite any exsisting profile fields' do profile = Profile.new(:first_name => 'maxwell') profile.from_omniauth_hash(@from_omniauth)['first_name'].should == 'maxwell' end + + it 'sets full name to first name' do + @from_omniauth = {'name' => 'bob jones', 'description' => 'this is my bio', 'location' => 'sf', 'image' => 'http://cats.com/gif.gif'} + + profile = Profile.new + profile.from_omniauth_hash(@from_omniauth)['first_name'].should == 'bob jones' + end end describe '#contruct_full_name' do