Codebase list ruby-omniauth-facebook / 7f923bc
return correct user info Mark Dodwell 12 years ago
2 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1717 }
1818
1919 uid { raw_info['id'] }
20
21 info {
22 {
23 'nickname' => raw_info['username'],
24 'email' => raw_info['email'],
25 'first_name' => raw_info['first_name'],
26 'last_name' => raw_info['last_name'],
27 'image' => "http://graph.facebook.com/#{uid}/picture"
28 }
29 }
2030
2131 def build_access_token
2232 super.tap do |token|
4444 end
4545
4646 describe '#uid' do
47 before :each do
48 subject.stub(:raw_info) { { 'id' => '123' } }
49 end
50
4751 it 'returns the id from raw_info' do
48 subject.stub(:raw_info) { { 'id' => '123' } }
4952 subject.uid.should eq('123')
5053 end
5154 end
55
56 describe '#info' do
57 before :each do
58 @raw_info ||= {}
59 subject.stub(:raw_info) { @raw_info }
60 end
61
62 it 'returns the username as nickname' do
63 @raw_info['username'] = 'fredsmith'
64 subject.info['nickname'].should eq('fredsmith')
65 end
66
67 it 'returns the email' do
68 @raw_info['email'] = 'fred@smith.com'
69 subject.info['email'].should eq('fred@smith.com')
70 end
71
72 it 'returns the first name' do
73 @raw_info['first_name'] = 'Fred'
74 subject.info['first_name'].should eq('Fred')
75 end
76
77 it 'returns the last name' do
78 @raw_info['last_name'] = 'Smith'
79 subject.info['last_name'].should eq('Smith')
80 end
81
82 it 'returns the facebook avatar url' do
83 @raw_info['id'] = '321'
84 subject.info['image'].should eq('http://graph.facebook.com/321/picture')
85 end
86 end
5287 end