fb_graph 2.7.2 → 2.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e660328032ffbc8b0baa0033cf3099345ff336e0
4
- data.tar.gz: 167ec5d9906e89ce2ada0e468e600241fb07978b
3
+ metadata.gz: c41a5db1d62f6356aceae001c8aa779c785a6f5e
4
+ data.tar.gz: d08ed080c63f5278124d1001e52ca480abac4cd7
5
5
  SHA512:
6
- metadata.gz: 0fd73b3676e3b3b26c96ab0c1532f5bc41c9735f096991d154fe642ea365731fd942153221cfe555bb1b576673db0100a097b439e90948299d8ceb2b9bff6788
7
- data.tar.gz: ed343eab7ee5fd8e682bb90e8ef85b0dee476130f8879cfb8cec76573f684cdefbbbf7afc82d9c3785ac3cffdb47f259b5617f2c0c2c2dc1c84498250472ae3f
6
+ metadata.gz: 069da1d9cd6cae38ee5c189066c4ea17e3c3f1b02bf28b5f0012d3214046c3d271dac0234b4914b5377cda7a51ca58a5a0ad07de629368bc112d21324c83daf8
7
+ data.tar.gz: 752610f699973e87cdea79e2c6dfb78c132f72524e11eefa52b25071ed840f95c34dd41a9f5cd1b85b3fa00bfdc5948930d54e6ba44eefcbef633e08b093006f
data/README.rdoc CHANGED
@@ -116,16 +116,6 @@ of the specific objects fields in the sidebar under "Objects".
116
116
  results.klass.search(results.query, results.collection.next) # => same with results.next
117
117
  results.klass.search(results.query, results.collection.previous) # => same with results.previous
118
118
 
119
-
120
- ==== Comments
121
-
122
- # fetch comment replies
123
- FbGraph::Comment.new("10151705618661509_29545180", :access_token => ACCESS_TOKEN).comments
124
-
125
- # fetch if the comment accept replies
126
- comment = FbGraph::Comment.fetch("10151705618661509_29545180", :access_token => ACCESS_TOKEN, :fields => "can_comment")
127
- comment.can_comment
128
-
129
119
  === POST
130
120
 
131
121
  ==== Update status (wall post)
@@ -203,14 +193,6 @@ of the specific objects fields in the sidebar under "Objects".
203
193
  :message => 'Hello, where is photo?'
204
194
  )
205
195
 
206
- ==== Reply a comment
207
-
208
- comment = FbGraph::Comment.fetch("10151705618661509_29545180")
209
- comment.reply!(
210
- :message => "Hello!",
211
- :access_token => ACCESS_TOKEN
212
- )
213
-
214
196
  === DELETE
215
197
 
216
198
  ==== Delete an object
@@ -227,13 +209,6 @@ of the specific objects fields in the sidebar under "Objects".
227
209
  post.unlike!(:access_token => ACCESS_TOKEN)
228
210
  post.destroy(:access_token => ACCESS_TOKEN)
229
211
 
230
- ==== Delete a comment reply
231
-
232
- reply = comment.comment!( :access_token => ACCESS_TOKEN,
233
- :message => "Hello!"
234
- )
235
- reply.destroy(:access_token => ACCESS_TOKEN)
236
-
237
212
  === Authentication
238
213
 
239
214
  Both Facebook JavaScript SDK and normal OAuth2 flow is supported.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 2.7.3
data/fb_graph.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency "rcov", ">= 0.9"
24
24
  end
25
25
  s.add_development_dependency "rspec", ">= 2"
26
- s.add_development_dependency "fb_graph-mock", ">= 0.1.4"
26
+ s.add_development_dependency "fb_graph-mock", ">= 0.1.9"
27
27
  s.add_development_dependency "actionpack", ">= 3.0.6"
28
28
  end
@@ -23,5 +23,10 @@ module FbGraph
23
23
  @created_time = Time.parse(attributes[:created_time]).utc
24
24
  end
25
25
  end
26
+
27
+ def can_comment?
28
+ !!can_comment
29
+ end
30
+ alias_method :commentable?, :can_comment
26
31
  end
27
32
  end
@@ -1,67 +1,83 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FbGraph::Comment, '.new' do
3
+ describe FbGraph::Comment do
4
+ describe '.new' do
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :from => {
9
+ :id => '23456',
10
+ :name => 'nov matake'
11
+ },
12
+ :message => 'hello',
13
+ :created_time => '2010-01-02T15:37:40+0000'
14
+ }
15
+ comment = FbGraph::Comment.new(attributes.delete(:id), attributes)
16
+ comment.identifier.should == '12345'
17
+ comment.from.should == FbGraph::User.new('23456', :name => 'nov matake')
18
+ comment.message.should == 'hello'
19
+ comment.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
20
+ end
4
21
 
5
- it 'should setup all supported attributes' do
6
- attributes = {
7
- :id => '12345',
8
- :from => {
22
+ it 'should support page as from' do
23
+ page_comment = FbGraph::Comment.new('12345', :from => {
9
24
  :id => '23456',
10
- :name => 'nov matake'
11
- },
12
- :message => 'hello',
13
- :created_time => '2010-01-02T15:37:40+0000'
14
- }
15
- comment = FbGraph::Comment.new(attributes.delete(:id), attributes)
16
- comment.identifier.should == '12345'
17
- comment.from.should == FbGraph::User.new('23456', :name => 'nov matake')
18
- comment.message.should == 'hello'
19
- comment.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
20
- end
21
-
22
- it 'should support page as from' do
23
- page_comment = FbGraph::Comment.new('12345', :from => {
24
- :id => '23456',
25
- :name => 'Smart.fm',
26
- :category => 'Web Site'
27
- })
28
- page_comment.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
25
+ :name => 'Smart.fm',
26
+ :category => 'Web Site'
27
+ })
28
+ page_comment.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
29
+ end
29
30
  end
30
31
 
31
- end
32
+ describe '#fetch' do
33
+ context 'when access_token given' do
34
+ it 'gets the comment message, attributes, and user object' do
35
+ mock_graph :get, 'comment_id', 'comments/comment', :access_token => 'access_token' do
36
+ comment = FbGraph::Comment.fetch("comment_id", :access_token => 'access_token')
37
+ comment.identifier.should == '10151705618661509_29545180'
38
+ comment.can_comment == nil
39
+ end
40
+ end
32
41
 
33
- describe FbGraph::Comment, '#fetch' do
42
+ it "gets the list of replies for the comment" do
43
+ mock_graph :get, 'comment_id/comments', 'comments/comments/with_cursor_paging_params', :access_token => 'access_token' do
44
+ replies = FbGraph::Comment.new("comment_id", :access_token => 'access_token').comments
45
+ replies.should be_instance_of FbGraph::Connection
46
+ replies.should be_a FbGraph::Collection
47
+ replies.collection.next.should include :limit, :after
48
+ replies.collection.previous.should include :limit, :before
49
+ replies.collection.cursors.should include :before, :after
50
+ end
51
+ end
34
52
 
35
- context 'when access_token given' do
36
- it 'gets the comment message, attributes, and user object' do
37
- mock_graph :get, 'comment_id', 'comments/comment', :access_token => 'access_token' do
38
- comment = FbGraph::Comment.fetch("comment_id", :access_token => 'access_token')
39
- comment.identifier.should == '10151705618661509_29545180'
40
- comment.can_comment == nil
53
+ context 'when can_comment is passed into the fields parameter' do
54
+ it 'gets the can_comment attribute' do
55
+ mock_graph :get, 'comment_id', 'comments/with_can_comment', :access_token => 'access_token', :params => {
56
+ :fields => 'can_comment'
57
+ } do
58
+ comment = FbGraph::Comment.fetch("comment_id", :access_token => 'access_token', :fields => 'can_comment')
59
+ comment.identifier.should == '10151705618661509_29545180'
60
+ comment.can_comment.should == true
61
+ end
62
+ end
41
63
  end
42
64
  end
65
+ end
43
66
 
44
- it "gets the list of replies for the comment" do
45
- mock_graph :get, 'comment_id/comments', 'comments/comments/with_cursor_paging_params', :access_token => 'access_token' do
46
- replies = FbGraph::Comment.new("comment_id", :access_token => 'access_token').comments
47
- replies.should be_instance_of FbGraph::Connection
48
- replies.should be_a FbGraph::Collection
49
- replies.collection.next.should include :limit, :after
50
- replies.collection.previous.should include :limit, :before
51
- replies.collection.cursors.should include :before, :after
52
- end
67
+ describe '#commentable?' do
68
+ context 'when commentable' do
69
+ subject { FbGraph::Comment.new('12345', :message => 'hello', :can_comment => true) }
70
+ it { should be_commentable }
53
71
  end
54
72
 
55
- context 'when can_comment is passed into the fields parameter' do
56
- it 'gets the can_comment attribute' do
57
- mock_graph :get, 'comment_id', 'comments/with_can_comment', :access_token => 'access_token', :params => { :fields => 'can_comment' } do
58
- comment = FbGraph::Comment.fetch("comment_id", :access_token => 'access_token', :fields => 'can_comment')
59
- comment.identifier.should == '10151705618661509_29545180'
60
- comment.can_comment.should == true
61
- end
62
- end
73
+ context 'when non commentable' do
74
+ subject { FbGraph::Comment.new('12345', :message => 'hello', :can_comment => false) }
75
+ it { should_not be_commentable }
63
76
  end
64
77
 
78
+ context 'when unknown' do
79
+ subject { FbGraph::Comment.new('12345', :message => 'hello') }
80
+ it { should_not be_commentable }
81
+ end
65
82
  end
66
-
67
83
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FbGraph::Connections::Comments, '#comments' do
4
- context 'when included by FbGraph::Post' do
3
+ describe FbGraph::Connections::Comments do
4
+ describe '#comments' do
5
5
  let :post do
6
6
  mock_graph :get, 'no_comments', 'posts/no_comments' do
7
7
  FbGraph::Post.new('no_comments').fetch
@@ -36,10 +36,8 @@ describe FbGraph::Connections::Comments, '#comments' do
36
36
  end
37
37
  end
38
38
  end
39
- end
40
39
 
41
- describe FbGraph::Connections::Comments, '#comment!' do
42
- context 'when included by FbGraph::Post' do
40
+ describe '#comment!' do
43
41
  context 'when no access_token given' do
44
42
  it 'should raise FbGraph::Exception' do
45
43
  mock_graph :post, '12345/comments', 'posts/comments/post_without_access_token', :status => [500, 'Internal Server Error'] do
@@ -72,10 +70,8 @@ describe FbGraph::Connections::Comments, '#comment!' do
72
70
  end
73
71
  end
74
72
  end
75
- end
76
73
 
77
- describe FbGraph::Comment, '#reply!' do
78
- context 'when included by FbGraph::Post' do
74
+ describe '#reply!' do
79
75
  context 'when no access_token given' do
80
76
  it 'should raise FbGraph::Exception' do
81
77
  mock_graph :post, '12345/comments', 'comments/comments/post_without_access_token', :status => [500, 'Internal Server Error'] do
@@ -88,7 +84,9 @@ describe FbGraph::Comment, '#reply!' do
88
84
 
89
85
  context 'when invalid access_token is given' do
90
86
  it 'should raise FbGraph::Exception' do
91
- mock_graph :post, '12345/comments', 'comments/comments/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
87
+ mock_graph :post, '12345/comments', 'comments/comments/post_with_invalid_access_token', :access_token => 'invalid', :params => {
88
+ :message => 'hello'
89
+ }, :status => [500, 'Internal Server Error'] do
92
90
  lambda do
93
91
  FbGraph::Post.new('12345', :access_token => 'invalid').reply!(:message => 'hello')
94
92
  end.should raise_exception(FbGraph::Exception)
@@ -98,7 +96,9 @@ describe FbGraph::Comment, '#reply!' do
98
96
 
99
97
  context 'when valid access_token is given' do
100
98
  it 'should return generated comment' do
101
- mock_graph :post, '12345/comments', 'comments/comments/post_with_valid_access_token' do
99
+ mock_graph :post, '12345/comments', 'comments/comments/post_with_valid_access_token', :access_token => 'valid', :params => {
100
+ :message => 'hello'
101
+ } do
102
102
  reply = FbGraph::Comment.new('12345', :access_token => 'valid').reply!(:message => 'hello')
103
103
  reply.should be_instance_of FbGraph::Comment
104
104
  reply.identifier.should == '10151705618661509_29549300'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - '>='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.1.4
117
+ version: 0.1.9
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.1.4
124
+ version: 0.1.9
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: actionpack
127
127
  requirement: !ruby/object:Gem::Requirement