koala 1.11.1 → 2.0.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +21 -2
- data/lib/koala.rb +3 -11
- data/lib/koala/api.rb +1 -3
- data/lib/koala/api/graph_api.rb +1 -15
- data/lib/koala/api/graph_batch_api.rb +2 -2
- data/lib/koala/http_service.rb +1 -118
- data/lib/koala/oauth.rb +0 -56
- data/lib/koala/realtime_updates.rb +0 -6
- data/lib/koala/test_users.rb +0 -7
- data/lib/koala/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/cases/graph_api_batch_spec.rb +15 -2
- data/spec/cases/http_service_spec.rb +0 -166
- data/spec/cases/koala_spec.rb +0 -29
- data/spec/cases/oauth_spec.rb +315 -482
- data/spec/cases/realtime_updates_spec.rb +0 -12
- data/spec/cases/test_users_spec.rb +8 -20
- data/spec/fixtures/mock_facebook_responses.yml +0 -10
- data/spec/support/graph_api_shared_examples.rb +1 -30
- data/spec/support/koala_test.rb +1 -4
- data/spec/support/rest_api_shared_examples.rb +1 -1
- metadata +3 -6
- data/lib/koala/api/legacy.rb +0 -26
- data/spec/cases/legacy_spec.rb +0 -115
@@ -61,18 +61,6 @@ describe "Koala::Facebook::RealtimeUpdates" do
|
|
61
61
|
expect(Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym)).not_to include(:api=)
|
62
62
|
end
|
63
63
|
|
64
|
-
# old graph_api accessor
|
65
|
-
it "returns the api object when graph_api is called" do
|
66
|
-
updates = Koala::Facebook::RealtimeUpdates.new(:app_id => @app_id, :secret => @secret)
|
67
|
-
expect(updates.graph_api).to eq(updates.api)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "fire a deprecation warning when graph_api is called" do
|
71
|
-
updates = Koala::Facebook::RealtimeUpdates.new(:app_id => @app_id, :secret => @secret)
|
72
|
-
expect(Koala::Utils).to receive(:deprecate)
|
73
|
-
updates.graph_api
|
74
|
-
end
|
75
|
-
|
76
64
|
# init with secret / fetching the token
|
77
65
|
it "initializes properly with an app_id and a secret" do
|
78
66
|
updates = Koala::Facebook::RealtimeUpdates.new(:app_id => @app_id, :secret => @secret)
|
@@ -72,18 +72,6 @@ describe "Koala::Facebook::TestUsers" do
|
|
72
72
|
expect(Koala::Facebook::TestUsers.instance_methods.map(&:to_sym)).to include(:api)
|
73
73
|
expect(Koala::Facebook::TestUsers.instance_methods.map(&:to_sym)).not_to include(:api=)
|
74
74
|
end
|
75
|
-
|
76
|
-
# old graph_api accessor
|
77
|
-
it "returns the api object when graph_api is called" do
|
78
|
-
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
79
|
-
expect(test_users.graph_api).to eq(test_users.api)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "fire a deprecation warning when graph_api is called" do
|
83
|
-
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
84
|
-
expect(Koala::Utils).to receive(:deprecate)
|
85
|
-
test_users.graph_api
|
86
|
-
end
|
87
75
|
end
|
88
76
|
|
89
77
|
describe "when used without network" do
|
@@ -105,12 +93,12 @@ describe "Koala::Facebook::TestUsers" do
|
|
105
93
|
end
|
106
94
|
|
107
95
|
it "accepts permissions as a string" do
|
108
|
-
expect(@test_users.
|
96
|
+
expect(@test_users.api).to receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything, anything)
|
109
97
|
result = @test_users.create(true, "read_stream,publish_stream")
|
110
98
|
end
|
111
99
|
|
112
100
|
it "accepts permissions as an array" do
|
113
|
-
expect(@test_users.
|
101
|
+
expect(@test_users.api).to receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything, anything)
|
114
102
|
result = @test_users.create(true, ["read_stream", "publish_stream"])
|
115
103
|
end
|
116
104
|
|
@@ -123,13 +111,13 @@ describe "Koala::Facebook::TestUsers" do
|
|
123
111
|
|
124
112
|
it "lets you specify other graph arguments, like uid and access token" do
|
125
113
|
args = {:uid => "some test user ID", :owner_access_token => "some owner access token"}
|
126
|
-
expect(@test_users.
|
114
|
+
expect(@test_users.api).to receive(:graph_call).with(anything, hash_including(args), anything, anything)
|
127
115
|
@test_users.create(true, nil, args)
|
128
116
|
end
|
129
117
|
|
130
118
|
it "lets you specify http options that get passed through to the graph call" do
|
131
119
|
options = {:some_http_option => true}
|
132
|
-
expect(@test_users.
|
120
|
+
expect(@test_users.api).to receive(:graph_call).with(anything, anything, anything, options)
|
133
121
|
@test_users.create(true, nil, {}, options)
|
134
122
|
end
|
135
123
|
end
|
@@ -180,7 +168,7 @@ describe "Koala::Facebook::TestUsers" do
|
|
180
168
|
options = {:some_http_option => true}
|
181
169
|
# technically this goes through delete_object, but this makes it less brittle
|
182
170
|
@stubbed = true
|
183
|
-
expect(@test_users.
|
171
|
+
expect(@test_users.api).to receive(:graph_call).with(anything, anything, anything, options)
|
184
172
|
@test_users.delete("user", options)
|
185
173
|
end
|
186
174
|
end
|
@@ -227,20 +215,20 @@ describe "Koala::Facebook::TestUsers" do
|
|
227
215
|
|
228
216
|
it "makes a POST with the test user Graph API " do
|
229
217
|
@user1 = @test_users2.create(true)
|
230
|
-
expect(@test_users2.
|
218
|
+
expect(@test_users2.api).to receive(:graph_call).with(anything, anything, "post", anything)
|
231
219
|
@test_users2.update(@user1, @updates)
|
232
220
|
end
|
233
221
|
|
234
222
|
it "makes a request to the test user with the update params " do
|
235
223
|
@user1 = @test_users2.create(true)
|
236
|
-
expect(@test_users2.
|
224
|
+
expect(@test_users2.api).to receive(:graph_call).with(@user1["id"], @updates, anything, anything)
|
237
225
|
@test_users2.update(@user1, @updates)
|
238
226
|
end
|
239
227
|
|
240
228
|
it "accepts an options hash" do
|
241
229
|
options = {:some_http_option => true}
|
242
230
|
@stubbed = true
|
243
|
-
expect(@test_users2.
|
231
|
+
expect(@test_users2.api).to receive(:graph_call).with(anything, anything, anything, options)
|
244
232
|
@test_users2.update("foo", @updates, options)
|
245
233
|
end
|
246
234
|
|
@@ -259,16 +259,6 @@ graph_api:
|
|
259
259
|
code: 500
|
260
260
|
body: '{"error": {"type": "Exception","message": "No node specified"}}'
|
261
261
|
|
262
|
-
/search:
|
263
|
-
q=facebook:
|
264
|
-
get:
|
265
|
-
with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
266
|
-
no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
267
|
-
"limit=25&q=facebook&until=<%= TEST_DATA['search_time'] %>":
|
268
|
-
get:
|
269
|
-
with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
270
|
-
no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
271
|
-
|
272
262
|
/fql:
|
273
263
|
q=select uid, first_name from user where uid = 2901279:
|
274
264
|
get:
|
@@ -51,12 +51,6 @@ shared_examples_for "Koala GraphAPI" do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
# SEARCH
|
55
|
-
it "can search" do
|
56
|
-
result = @api.search("facebook")
|
57
|
-
expect(result.length).to be_an(Integer)
|
58
|
-
end
|
59
|
-
|
60
54
|
# DATA
|
61
55
|
# access public info
|
62
56
|
|
@@ -118,12 +112,6 @@ shared_examples_for "Koala GraphAPI" do
|
|
118
112
|
expect(result["http://developers.facebook.com/blog/post/490"] && result["http://developers.facebook.com/blog/post/472"]).to be_truthy
|
119
113
|
end
|
120
114
|
|
121
|
-
# SEARCH
|
122
|
-
it "can search" do
|
123
|
-
result = @api.search("facebook")
|
124
|
-
expect(result.length).to be_an(Integer)
|
125
|
-
end
|
126
|
-
|
127
115
|
# PAGING THROUGH COLLECTIONS
|
128
116
|
# see also graph_collection_tests
|
129
117
|
it "makes a request for a page when provided a specific set of page params" do
|
@@ -522,7 +510,6 @@ shared_examples_for "Koala GraphAPI with an access token" do
|
|
522
510
|
:put_wall_post => 4,
|
523
511
|
:put_comment => 3,
|
524
512
|
:put_like => 2, :delete_like => 2,
|
525
|
-
:search => 3,
|
526
513
|
:set_app_restrictions => 4,
|
527
514
|
:get_page_access_token => 3,
|
528
515
|
:fql_query => 3, :fql_multiquery => 3,
|
@@ -571,26 +558,10 @@ shared_examples_for "Koala GraphAPI with GraphCollection" do
|
|
571
558
|
expect(@api.get_connections(KoalaTest.page, "photos")).to be_nil
|
572
559
|
end
|
573
560
|
|
574
|
-
it "gets a GraphCollection when searching" do
|
575
|
-
result = @api.search("facebook")
|
576
|
-
expect(result).to be_a(Koala::Facebook::GraphCollection)
|
577
|
-
end
|
578
|
-
|
579
|
-
it "returns nil if the search call fails with nil" do
|
580
|
-
# this happens sometimes
|
581
|
-
expect(@api).to receive(:graph_call).and_return(nil)
|
582
|
-
expect(@api.search("facebook")).to be_nil
|
583
|
-
end
|
584
|
-
|
585
|
-
it "gets a GraphCollection when paging through results" do
|
586
|
-
@results = @api.get_page(["search", {"q"=>"facebook", "limit"=>"25", "until"=> KoalaTest.search_time}])
|
587
|
-
expect(@results).to be_a(Koala::Facebook::GraphCollection)
|
588
|
-
end
|
589
|
-
|
590
561
|
it "returns nil if the page call fails with nil" do
|
591
562
|
# this happens sometimes
|
592
563
|
expect(@api).to receive(:graph_call).and_return(nil)
|
593
|
-
expect(@api.
|
564
|
+
expect(@api.get_connections(KoalaTest.page, "photos")).to be_nil
|
594
565
|
end
|
595
566
|
end
|
596
567
|
end
|
data/spec/support/koala_test.rb
CHANGED
@@ -3,7 +3,7 @@ module KoalaTest
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
attr_accessor :oauth_token, :app_id, :secret, :app_access_token, :code, :session_key
|
6
|
-
attr_accessor :oauth_test_data, :subscription_test_data
|
6
|
+
attr_accessor :oauth_test_data, :subscription_test_data
|
7
7
|
attr_accessor :test_user_api
|
8
8
|
attr_accessor :vcr_oauth_token
|
9
9
|
end
|
@@ -107,9 +107,6 @@ module KoalaTest
|
|
107
107
|
self.session_key = data["oauth_test_data"]["session_key"]
|
108
108
|
|
109
109
|
self.vcr_oauth_token = data["vcr_data"]["oauth_token"]
|
110
|
-
|
111
|
-
# fix the search time so it can be used in the mock responses
|
112
|
-
self.search_time = data["search_time"] || (Time.now - 3600).to_s
|
113
110
|
end
|
114
111
|
|
115
112
|
def self.testing_permissions
|
@@ -25,7 +25,7 @@ shared_examples_for "Koala RestAPI" do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "sets the read_only option to true if the method is listed in the read-only list" do
|
28
|
-
method = Koala::Facebook::
|
28
|
+
method = Koala::Facebook::API::READ_ONLY_METHODS.first
|
29
29
|
|
30
30
|
expect(@api).to receive(:api).with(
|
31
31
|
anything,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koala
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Koppel
|
@@ -83,7 +83,6 @@ files:
|
|
83
83
|
- lib/koala/api/graph_api.rb
|
84
84
|
- lib/koala/api/graph_batch_api.rb
|
85
85
|
- lib/koala/api/graph_collection.rb
|
86
|
-
- lib/koala/api/legacy.rb
|
87
86
|
- lib/koala/api/rest_api.rb
|
88
87
|
- lib/koala/errors.rb
|
89
88
|
- lib/koala/http_service.rb
|
@@ -104,7 +103,6 @@ files:
|
|
104
103
|
- spec/cases/http_service_spec.rb
|
105
104
|
- spec/cases/koala_spec.rb
|
106
105
|
- spec/cases/koala_test_spec.rb
|
107
|
-
- spec/cases/legacy_spec.rb
|
108
106
|
- spec/cases/multipart_request_spec.rb
|
109
107
|
- spec/cases/oauth_spec.rb
|
110
108
|
- spec/cases/realtime_updates_spec.rb
|
@@ -143,9 +141,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
141
|
version: '0'
|
144
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
143
|
requirements:
|
146
|
-
- - "
|
144
|
+
- - ">"
|
147
145
|
- !ruby/object:Gem::Version
|
148
|
-
version:
|
146
|
+
version: 1.3.1
|
149
147
|
requirements: []
|
150
148
|
rubyforge_project:
|
151
149
|
rubygems_version: 2.2.1
|
@@ -162,7 +160,6 @@ test_files:
|
|
162
160
|
- spec/cases/http_service_spec.rb
|
163
161
|
- spec/cases/koala_spec.rb
|
164
162
|
- spec/cases/koala_test_spec.rb
|
165
|
-
- spec/cases/legacy_spec.rb
|
166
163
|
- spec/cases/multipart_request_spec.rb
|
167
164
|
- spec/cases/oauth_spec.rb
|
168
165
|
- spec/cases/realtime_updates_spec.rb
|
data/lib/koala/api/legacy.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'koala/api'
|
2
|
-
module Koala
|
3
|
-
module Facebook
|
4
|
-
# Legacy support for old pre-1.2 APIs
|
5
|
-
|
6
|
-
# A wrapper for the old APIs deprecated in 1.2.0, which triggers a deprecation warning when used.
|
7
|
-
# Otherwise, this class functions identically to API.
|
8
|
-
# @see API
|
9
|
-
# @private
|
10
|
-
class OldAPI < API
|
11
|
-
def initialize(*args)
|
12
|
-
Koala::Utils.deprecate("#{self.class.name} is deprecated and will be removed in a future version; please use the API class instead.")
|
13
|
-
super
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# @private
|
18
|
-
class GraphAPI < OldAPI; end
|
19
|
-
|
20
|
-
# @private
|
21
|
-
class RestAPI < OldAPI; end
|
22
|
-
|
23
|
-
# @private
|
24
|
-
class GraphAndRestAPI < OldAPI; end
|
25
|
-
end
|
26
|
-
end
|
data/spec/cases/legacy_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# Support for legacy / deprecated interfaces
|
4
|
-
describe "legacy APIs" do
|
5
|
-
|
6
|
-
it "deprecates the REST API" do
|
7
|
-
api = Koala::Facebook::API.new
|
8
|
-
allow(api).to receive(:api)
|
9
|
-
expect(Koala::Utils).to receive(:deprecate)
|
10
|
-
api.rest_call("stuff")
|
11
|
-
end
|
12
|
-
|
13
|
-
describe Koala::Facebook::GraphAPI do
|
14
|
-
describe "class consolidation" do
|
15
|
-
before :each do
|
16
|
-
allow(Koala::Utils).to receive(:deprecate) # avoid actual messages to stderr
|
17
|
-
end
|
18
|
-
|
19
|
-
it "still allows you to instantiate a GraphAndRestAPI object" do
|
20
|
-
api = expect(Koala::Facebook::GraphAPI.new("token")).to be_a(Koala::Facebook::GraphAPI)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "ultimately creates an API object" do
|
24
|
-
api = expect(Koala::Facebook::GraphAPI.new("token")).to be_a(Koala::Facebook::API)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "fires a depreciation warning" do
|
28
|
-
expect(Koala::Utils).to receive(:deprecate)
|
29
|
-
api = Koala::Facebook::GraphAPI.new("token")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe Koala::Facebook::RestAPI do
|
35
|
-
describe "class consolidation" do
|
36
|
-
before :each do
|
37
|
-
allow(Koala::Utils).to receive(:deprecate) # avoid actual messages to stderr
|
38
|
-
end
|
39
|
-
|
40
|
-
it "still allows you to instantiate a GraphAndRestAPI object" do
|
41
|
-
api = expect(Koala::Facebook::RestAPI.new("token")).to be_a(Koala::Facebook::RestAPI)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "ultimately creates an API object" do
|
45
|
-
api = expect(Koala::Facebook::RestAPI.new("token")).to be_a(Koala::Facebook::API)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "fires a depreciation warning" do
|
49
|
-
expect(Koala::Utils).to receive(:deprecate)
|
50
|
-
api = Koala::Facebook::RestAPI.new("token")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe Koala::Facebook::GraphAndRestAPI do
|
56
|
-
describe "class consolidation" do
|
57
|
-
before :each do
|
58
|
-
allow(Koala::Utils).to receive(:deprecate) # avoid actual messages to stderr
|
59
|
-
end
|
60
|
-
|
61
|
-
it "still allows you to instantiate a GraphAndRestAPI object" do
|
62
|
-
api = expect(Koala::Facebook::GraphAndRestAPI.new("token")).to be_a(Koala::Facebook::GraphAndRestAPI)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "ultimately creates an API object" do
|
66
|
-
api = expect(Koala::Facebook::GraphAndRestAPI.new("token")).to be_a(Koala::Facebook::API)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "fires a depreciation warning" do
|
70
|
-
expect(Koala::Utils).to receive(:deprecate)
|
71
|
-
api = Koala::Facebook::GraphAndRestAPI.new("token")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
{:typhoeus => Koala::TyphoeusService, :net_http => Koala::NetHTTPService}.each_pair do |adapter, module_class|
|
77
|
-
describe module_class.to_s do
|
78
|
-
it "responds to deprecated_interface" do
|
79
|
-
expect(module_class).to respond_to(:deprecated_interface)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "issues a deprecation warning" do
|
83
|
-
expect(Koala::Utils).to receive(:deprecate)
|
84
|
-
module_class.deprecated_interface
|
85
|
-
end
|
86
|
-
|
87
|
-
it "sets the default adapter to #{adapter}" do
|
88
|
-
module_class.deprecated_interface
|
89
|
-
expect(Faraday.default_adapter).to eq(adapter)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "moved classes" do
|
95
|
-
it "allows you to access Koala::HTTPService::MultipartRequest through the Koala module" do
|
96
|
-
expect(Koala::MultipartRequest).to eq(Koala::HTTPService::MultipartRequest)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "allows you to access Koala::Response through the Koala module" do
|
100
|
-
expect(Koala::Response).to eq(Koala::HTTPService::Response)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "allows you to access Koala::Response through the Koala module" do
|
104
|
-
expect(Koala::UploadableIO).to eq(Koala::HTTPService::UploadableIO)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "allows you to access Koala::Facebook::GraphBatchAPI::BatchOperation through the Koala::Facebook module" do
|
108
|
-
expect(Koala::Facebook::BatchOperation).to eq(Koala::Facebook::GraphBatchAPI::BatchOperation)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "allows you to access Koala::Facebook::API::GraphCollection through the Koala::Facebook module" do
|
112
|
-
expect(Koala::Facebook::GraphCollection).to eq(Koala::Facebook::API::GraphCollection)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|