1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

User#friend? another

This commit is contained in:
nov 2014-08-15 13:42:24 +09:00
parent ef1536d0e2
commit bdaef23ae2
3 changed files with 26 additions and 2 deletions

View file

@ -7,6 +7,11 @@ module FbGraph2
User.new(user[:id], user).authenticate self.access_token
end
end
def friend?(user, params = {})
users = self.edge :friends, params, edge_scope: user
users.present?
end
end
end
end

View file

@ -2,8 +2,9 @@ require 'spec_helper'
describe FbGraph2::Edge::Friends do
context 'included in User' do
let(:me) { FbGraph2::User.me('token') }
describe '#friends' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::User' do
users = mock_graph :get, 'me/friends', 'user/friends', access_token: 'token' do
me.friends
@ -15,5 +16,23 @@ describe FbGraph2::Edge::Friends do
end
end
end
describe '#friend?' do
context 'when is friend' do
it do
mock_graph :get, 'me/friends/user_id', 'user/friends', access_token: 'token' do
me.friend? 'user_id'
end.should be true
end
end
context 'otherwise' do
it do
mock_graph :get, 'me/friends/user_id', 'blank_collection', access_token: 'token' do
me.friend? 'user_id'
end.should be false
end
end
end
end
end

View file

@ -18,7 +18,7 @@ describe FbGraph2::Edge::Likes do
end
describe '#liked?' do
context 'liked' do
context 'when liked' do
it do
mock_graph :get, 'me/likes/page_id', 'user/likes', access_token: 'token' do
me.liked? 'page_id'