return correct user info
Mark Dodwell
12 years ago
17 | 17 |
}
|
18 | 18 |
|
19 | 19 |
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 |
}
|
20 | 30 |
|
21 | 31 |
def build_access_token
|
22 | 32 |
super.tap do |token|
|
44 | 44 |
end
|
45 | 45 |
|
46 | 46 |
describe '#uid' do
|
|
47 |
before :each do
|
|
48 |
subject.stub(:raw_info) { { 'id' => '123' } }
|
|
49 |
end
|
|
50 |
|
47 | 51 |
it 'returns the id from raw_info' do
|
48 | |
subject.stub(:raw_info) { { 'id' => '123' } }
|
49 | 52 |
subject.uid.should eq('123')
|
50 | 53 |
end
|
51 | 54 |
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
|
52 | 87 |
end
|