fb_graph 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/Gemfile.lock +11 -15
  2. data/VERSION +1 -1
  3. data/lib/fb_graph/album.rb +1 -1
  4. data/lib/fb_graph/connections/comments.rb +1 -5
  5. data/lib/fb_graph/connections/former_participants.rb +1 -5
  6. data/lib/fb_graph/connections/likes.rb +1 -5
  7. data/lib/fb_graph/connections/messages.rb +1 -5
  8. data/lib/fb_graph/connections/participants.rb +1 -5
  9. data/lib/fb_graph/connections/question_options.rb +2 -6
  10. data/lib/fb_graph/connections/senders.rb +1 -5
  11. data/lib/fb_graph/connections/tags.rb +7 -8
  12. data/lib/fb_graph/link.rb +1 -1
  13. data/lib/fb_graph/message.rb +1 -1
  14. data/lib/fb_graph/node.rb +32 -7
  15. data/lib/fb_graph/note.rb +1 -1
  16. data/lib/fb_graph/open_graph/action.rb +1 -2
  17. data/lib/fb_graph/page.rb +2 -2
  18. data/lib/fb_graph/photo.rb +1 -2
  19. data/lib/fb_graph/post.rb +1 -2
  20. data/lib/fb_graph/question.rb +2 -4
  21. data/lib/fb_graph/searchable.rb +2 -1
  22. data/lib/fb_graph/status.rb +1 -2
  23. data/lib/fb_graph/thread.rb +5 -11
  24. data/lib/fb_graph/user_achievement.rb +1 -2
  25. data/lib/fb_graph/video.rb +1 -1
  26. data/spec/fb_graph/connections/comments_spec.rb +25 -13
  27. data/spec/fb_graph/connections/former_participants_spec.rb +30 -12
  28. data/spec/fb_graph/connections/likes_spec.rb +32 -0
  29. data/spec/fb_graph/connections/messages_spec.rb +30 -12
  30. data/spec/fb_graph/connections/participants_spec.rb +30 -12
  31. data/spec/fb_graph/connections/question_options_spec.rb +3 -3
  32. data/spec/fb_graph/connections/questions_spec.rb +13 -0
  33. data/spec/fb_graph/connections/senders_spec.rb +30 -12
  34. data/spec/fb_graph/page_spec.rb +9 -6
  35. data/spec/fb_graph/question_spec.rb +26 -25
  36. data/spec/fb_graph/searchable_spec.rb +17 -5
  37. data/spec/fb_graph/thread_spec.rb +0 -30
  38. data/spec/mock_json/pages/platform_public.json +2 -1
  39. data/spec/mock_json/users/questions/sample.json +465 -0
  40. data/spec/spec_helper.rb +0 -3
  41. metadata +21 -19
@@ -1,18 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Participants, '#participants' do
4
- it 'should use cached contents as default' do
5
- lambda do
6
- FbGraph::Thread.new(12345, :access_token => 'access_token').participants
7
- end.should_not request_to '12345/participants?access_token=access_token'
8
- end
9
-
10
- it 'should not use cached contents when options are specified' do
11
- lambda do
12
- FbGraph::Thread.new(12345).participants(:no_cache => true)
13
- end.should request_to '12345/participants?no_cache=true'
14
- end
15
-
16
4
  it 'should return participants as FbGraph::User' do
17
5
  mock_graph :get, '12345/participants', 'thread/participants/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
18
6
  participants = FbGraph::Thread.new(12345, :access_token => 'access_token').participants(:no_cache => true)
@@ -21,4 +9,34 @@ describe FbGraph::Connections::Participants, '#participants' do
21
9
  end
22
10
  end
23
11
  end
12
+
13
+ describe 'cached messages' do
14
+ context 'when cached' do
15
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token', :participants => {}) }
16
+
17
+ it 'should use cache' do
18
+ lambda do
19
+ thread.participants
20
+ end.should_not request_to '12345/participants?access_token=access_token'
21
+ end
22
+
23
+ context 'when options are specified' do
24
+ it 'should not use cache' do
25
+ lambda do
26
+ thread.participants(:no_cache => true)
27
+ end.should request_to '12345/participants?access_token=access_token&no_cache=true'
28
+ end
29
+ end
30
+ end
31
+
32
+ context 'otherwise' do
33
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token') }
34
+
35
+ it 'should not use cache' do
36
+ lambda do
37
+ thread.participants
38
+ end.should request_to '12345/participants?access_token=access_token'
39
+ end
40
+ end
41
+ end
24
42
  end
@@ -4,9 +4,9 @@ describe FbGraph::Connections::QuestionOptions, '#options' do
4
4
  context 'when included by FbGraph::Question' do
5
5
  it 'should return options as FbGraph::QuestionOption' do
6
6
  mock_graph :get, '12345/question_options', 'questions/options/matake_private', :access_token => 'access_token' do
7
- options = FbGraph::Question.new('12345', :access_token => 'access_token').options
8
- options.each do |option|
9
- option.should be_instance_of(FbGraph::QuestionOption)
7
+ question_options = FbGraph::Question.new('12345', :access_token => 'access_token').question_options
8
+ question_options.each do |question_option|
9
+ question_option.should be_instance_of(FbGraph::QuestionOption)
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph::Connections::Questions do
4
+ it 'should return an Array of Questions' do
5
+ mock_graph :get, 'me/questions', 'users/questions/sample', :access_token => 'access_token' do
6
+ questions = FbGraph::User.me('access_token').questions
7
+ questions.class.should == FbGraph::Connection
8
+ questions.each do |question|
9
+ question.should be_instance_of(FbGraph::Question)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,18 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Senders, '#senders' do
4
- it 'should use cached contents as default' do
5
- lambda do
6
- FbGraph::Thread.new(12345, :access_token => 'access_token').senders
7
- end.should_not request_to '12345/senders?access_token=access_token'
8
- end
9
-
10
- it 'should not use cached contents when options are specified' do
11
- lambda do
12
- FbGraph::Thread.new(12345).senders(:no_cache => true)
13
- end.should request_to '12345/senders?no_cache=true'
14
- end
15
-
16
4
  it 'should return senders as FbGraph::User' do
17
5
  mock_graph :get, '12345/senders', 'thread/senders/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
18
6
  senders = FbGraph::Thread.new(12345, :access_token => 'access_token').senders(:no_cache => true)
@@ -21,4 +9,34 @@ describe FbGraph::Connections::Senders, '#senders' do
21
9
  end
22
10
  end
23
11
  end
12
+
13
+ describe 'cached messages' do
14
+ context 'when cached' do
15
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token', :senders => {}) }
16
+
17
+ it 'should use cache' do
18
+ lambda do
19
+ thread.senders
20
+ end.should_not request_to '12345/senders?access_token=access_token'
21
+ end
22
+
23
+ context 'when options are specified' do
24
+ it 'should not use cache' do
25
+ lambda do
26
+ thread.senders(:no_cache => true)
27
+ end.should request_to '12345/senders?access_token=access_token&no_cache=true'
28
+ end
29
+ end
30
+ end
31
+
32
+ context 'otherwise' do
33
+ let(:thread) { FbGraph::Thread.new(12345, :access_token => 'access_token') }
34
+
35
+ it 'should not use cache' do
36
+ lambda do
37
+ thread.senders
38
+ end.should request_to '12345/senders?access_token=access_token'
39
+ end
40
+ end
41
+ end
24
42
  end
@@ -7,18 +7,20 @@ describe FbGraph::Page do
7
7
  :category => 'Technology',
8
8
  :likes => 578246,
9
9
  :name => 'Facebook Platform',
10
- :username => 'platform'
10
+ :username => 'platform',
11
+ :talking_about_count => 3232
11
12
  }
12
13
  end
13
14
  subject do
14
15
  FbGraph::Page.new(attributes[:id], attributes)
15
16
  end
16
17
 
17
- its(:identifier) { should == attributes[:id] }
18
- its(:category) { should == attributes[:category] }
19
- its(:like_count) { should == attributes[:likes] }
20
- its(:name) { should == attributes[:name] }
21
- its(:username) { should == attributes[:username] }
18
+ its(:identifier) { should == attributes[:id] }
19
+ its(:category) { should == attributes[:category] }
20
+ its(:like_count) { should == attributes[:likes] }
21
+ its(:name) { should == attributes[:name] }
22
+ its(:username) { should == attributes[:username] }
23
+ its(:talking_about_count) { should == attributes[:talking_about_count] }
22
24
 
23
25
  describe '.fetch' do
24
26
  subject do
@@ -30,6 +32,7 @@ describe FbGraph::Page do
30
32
  its(:name) { should == 'Facebook Platform' }
31
33
  its(:category) { should == 'Technology' }
32
34
  its(:like_count) { should == 578214 }
35
+ its(:talking_about_count) { should == 40945 }
33
36
 
34
37
  context 'when access_token field fetched' do
35
38
  subject do
@@ -39,31 +39,32 @@ describe FbGraph::Question do
39
39
  }
40
40
  }
41
41
  question = FbGraph::Question.new(attributes.delete(:id), attributes)
42
- question.identifier.should == '12345'
43
- question.from.should == FbGraph::User.new('23456', :name => 'Mahmoud Khaled')
44
- question.question.should == 'question 1'
45
- question.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
46
- question.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
47
- question.options.should == [FbGraph::QuestionOption.new(
48
- '34567',
49
- :from => {
50
- :id => '23456',
51
- :name => 'Mahmoud Khaled',
52
- },
53
- :name => "option 1",
54
- :votes => 2,
55
- :created_time => "2011-11-07T19:49:51+0000"
56
- ),
57
- FbGraph::QuestionOption.new(
58
- '34568',
59
- :from => {
60
- :id => '23457',
61
- :name => 'Mustafa Badawy',
62
- },
63
- :name => "option 2",
64
- :votes => 0,
65
- :created_time => "2011-11-07T19:49:48+0000"
66
- )
42
+ question.identifier.should == '12345'
43
+ question.from.should == FbGraph::User.new('23456', :name => 'Mahmoud Khaled')
44
+ question.question.should == 'question 1'
45
+ question.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
46
+ question.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
47
+ question.question_options.should == [
48
+ FbGraph::QuestionOption.new(
49
+ '34567',
50
+ :from => {
51
+ :id => '23456',
52
+ :name => 'Mahmoud Khaled',
53
+ },
54
+ :name => "option 1",
55
+ :votes => 2,
56
+ :created_time => "2011-11-07T19:49:51+0000"
57
+ ),
58
+ FbGraph::QuestionOption.new(
59
+ '34568',
60
+ :from => {
61
+ :id => '23457',
62
+ :name => 'Mustafa Badawy',
63
+ },
64
+ :name => "option 2",
65
+ :votes => 0,
66
+ :created_time => "2011-11-07T19:49:48+0000"
67
+ )
67
68
  ]
68
69
  end
69
70
 
@@ -1,11 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Searchable do
4
- context 'when included by FbGraph::Page' do
5
- it 'should with type=page' do
6
- lambda do
7
- FbGraph::Page.search('FbGraph')
8
- end.should request_to('search?q=FbGraph&type=page')
4
+ describe '.search' do
5
+ context 'when included by FbGraph::Page' do
6
+ it 'should with type=page' do
7
+ lambda do
8
+ FbGraph::Searchable.search('FbGraph')
9
+ end.should request_to('search?q=FbGraph')
10
+ end
11
+ end
12
+ end
13
+
14
+ describe '#search' do
15
+ context 'when included by FbGraph::Page' do
16
+ it 'should with type=page' do
17
+ lambda do
18
+ FbGraph::Page.search('FbGraph')
19
+ end.should request_to('search?q=FbGraph&type=page')
20
+ end
9
21
  end
10
22
  end
11
23
  end
@@ -83,34 +83,4 @@ describe FbGraph::Thread, '.new' do
83
83
  FbGraph::User.new('1575327134', :name => 'Nov Matake', :email => 'abc@facebook.com')
84
84
  ]
85
85
  end
86
-
87
-
88
- describe FbGraph::Thread::BeforeTransition do
89
- describe '#messages' do
90
- it 'should use cached contents as default' do
91
- lambda do
92
- FbGraph::Thread::BeforeTransition.new(12345, :access_token => 'access_token').messages
93
- end.should_not request_to '12345/comments?access_token=access_token'
94
- end
95
-
96
- it 'should not use cached contents when options are specified' do
97
- lambda do
98
- FbGraph::Thread::BeforeTransition.new(12345).messages(:no_cache => true)
99
- end.should request_to '12345/comments?no_cache=true'
100
- end
101
-
102
- it 'should return threads as FbGraph::Message' do
103
- mock_graph :get, '12345/comments', 'thread/messages/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
104
- messages = FbGraph::Thread::BeforeTransition.new(12345, :access_token => 'access_token').messages(:no_cache => true)
105
- messages.each do |message|
106
- message.should be_instance_of(FbGraph::Message)
107
- end
108
- lambda do
109
- messages.next
110
- end.should request_to '12345/comments'
111
- end
112
- end
113
- end
114
- end
115
-
116
86
  end
@@ -9,5 +9,6 @@
9
9
  "company_overview": "Facebook Platform enables anyone to build social applications on Facebook and the web.",
10
10
  "mission": "To make the web more open and social.",
11
11
  "products": "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n",
12
- "likes": 578214
12
+ "likes": 578214,
13
+ "talking_about_count": 40945
13
14
  }