ruby-satisfaction 0.7.0 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/README.markdown +7 -0
- data/lib/satisfaction/loader.rb +2 -0
- data/lib/satisfaction/version.rb +2 -2
- data/lib/satisfaction.rb +1 -0
- data/ruby-satisfaction.gemspec +2 -2
- data/spec/integration_spec.rb +45 -0
- data/spec/satisfaction/loader_spec.rb +112 -75
- metadata +9 -7
data/Gemfile.lock
CHANGED
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
open_gem (1.4.2)
|
29
29
|
launchy (~> 0.3.5)
|
30
30
|
rake (0.8.7)
|
31
|
-
rr (1.0.
|
31
|
+
rr (1.0.4)
|
32
32
|
rspec (2.2.0)
|
33
33
|
rspec-core (~> 2.2)
|
34
34
|
rspec-expectations (~> 2.2)
|
@@ -56,7 +56,7 @@ DEPENDENCIES
|
|
56
56
|
nokogiri (>= 1.4.2)
|
57
57
|
oauth (>= 0.3.5)
|
58
58
|
open_gem (>= 1.4)
|
59
|
-
rr (= 1.0.
|
59
|
+
rr (= 1.0.4)
|
60
60
|
rspec (~> 2.2)
|
61
61
|
ruby-debug (>= 0.10.4)
|
62
62
|
ruby-satisfaction!
|
data/README.markdown
CHANGED
@@ -11,6 +11,13 @@ For questions, please visit the [Get Satisfaction API community][3]
|
|
11
11
|
|
12
12
|
Changelog
|
13
13
|
=========
|
14
|
+
0.7.1
|
15
|
+
|
16
|
+
* Integration smoke tests to validate proper ssl
|
17
|
+
request.
|
18
|
+
* Test loader code on the SSL context also
|
19
|
+
* Suppress the 'warning: peer certificate won't be verified in this SSL session'
|
20
|
+
|
14
21
|
0.7.0
|
15
22
|
|
16
23
|
* Revised Sfn::Resource so that it supports calls to API endpoints for nested resources
|
data/lib/satisfaction/loader.rb
CHANGED
@@ -34,6 +34,7 @@ class Sfn::Loader
|
|
34
34
|
end
|
35
35
|
|
36
36
|
http = Net::HTTP.new(uri.host, uri.port)
|
37
|
+
http.use_ssl = true if uri.scheme.try(:downcase) == 'https'
|
37
38
|
add_authentication(request, http, options)
|
38
39
|
response = execute(http, request)
|
39
40
|
|
@@ -86,6 +87,7 @@ class Sfn::Loader
|
|
86
87
|
request.set_form_data(form)
|
87
88
|
|
88
89
|
http = Net::HTTP.new(uri.host, uri.port)
|
90
|
+
http.use_ssl = true if uri.scheme.try(:downcase) == 'https'
|
89
91
|
add_authentication(request, http, options)
|
90
92
|
response = execute(http, request)
|
91
93
|
|
data/lib/satisfaction/version.rb
CHANGED
data/lib/satisfaction.rb
CHANGED
data/ruby-satisfaction.gemspec
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path("../lib/satisfaction/version", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ruby-satisfaction"
|
6
|
-
s.version =
|
6
|
+
s.version = GemSatisfaction::VERSION::STRING
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.author = 'Get Satisfaction'
|
9
9
|
s.email = ["nerds+rubygems@getsatisfaction.com"]
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency "fakeweb", "~> 1.3"
|
27
27
|
s.add_development_dependency "open_gem", ">= 1.4"
|
28
28
|
s.add_development_dependency "ruby-debug", ">= 0.10.4"
|
29
|
-
s.add_development_dependency "rr", '1.0.
|
29
|
+
s.add_development_dependency "rr", '1.0.4'
|
30
30
|
|
31
31
|
s.extra_rdoc_files = [ "README.markdown" ]
|
32
32
|
s.files = `git ls-files`.split("\n") - ['.rvmrc', '.gitignore']
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Smoke test SSL conections' do
|
4
|
+
before do
|
5
|
+
@app_host = 'getsatisfaction.com'
|
6
|
+
@api_host = 'api.getsatisfaction.com'
|
7
|
+
FakeWeb.clean_registry
|
8
|
+
FakeWeb.allow_net_connect = true
|
9
|
+
end
|
10
|
+
|
11
|
+
shared_examples_for 'get' do
|
12
|
+
it 'should get the first page of getsat topics' do
|
13
|
+
results = @sfn.companies['getsatisfaction'].topics.page(1, :limit => 10)
|
14
|
+
results.items.size.should == 10
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'over ssl' do
|
19
|
+
before do
|
20
|
+
@sfn = Satisfaction.new(
|
21
|
+
:root => "https://#{@api_host}",
|
22
|
+
:autoload => false,
|
23
|
+
:request_token_url => "https://#{@app_host}/api/request_token",
|
24
|
+
:access_token_url => "https://#{@app_host}/api/access_token",
|
25
|
+
:authorize_url => "https://#{@app_host}/api/authorize"
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'get'
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'not over ssl' do
|
33
|
+
before do
|
34
|
+
@sfn = Satisfaction.new(
|
35
|
+
:root => "http://#{@api_host}",
|
36
|
+
:autoload => false,
|
37
|
+
:request_token_url => "http://#{@app_host}/api/request_token",
|
38
|
+
:access_token_url => "http://#{@app_host}/api/access_token",
|
39
|
+
:authorize_url => "http://#{@app_host}/api/authorize"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
it_should_behave_like 'get'
|
44
|
+
end
|
45
|
+
end
|
@@ -3,8 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe Sfn::Loader do
|
4
4
|
|
5
5
|
# ==== GET ==========================================================================================================
|
6
|
-
|
7
|
-
describe "#get" do
|
6
|
+
shared_examples_for "#get" do
|
8
7
|
before(:each) do
|
9
8
|
@response = nil
|
10
9
|
@status_code = '200'
|
@@ -12,12 +11,12 @@ describe Sfn::Loader do
|
|
12
11
|
@get = lambda do
|
13
12
|
FakeWeb.register_uri(
|
14
13
|
:get,
|
15
|
-
|
14
|
+
"http://#{@api_host}:#{@api_port}",
|
16
15
|
:body => @response_body,
|
17
16
|
:status => [@status_code]
|
18
17
|
)
|
19
18
|
stub(@loader).add_authentication {}
|
20
|
-
@response = @loader.get(
|
19
|
+
@response = @loader.get(@api_url)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
@@ -48,44 +47,6 @@ describe Sfn::Loader do
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
describe "when we are in a redirect loop" do
|
52
|
-
attr_reader :loader
|
53
|
-
|
54
|
-
before(:each) do
|
55
|
-
@url = 'http://loop/'
|
56
|
-
@loader = Sfn::Loader.new
|
57
|
-
stub(loader).add_authentication {}
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "and the status is 301" do
|
61
|
-
before(:each) do
|
62
|
-
@get = lambda {
|
63
|
-
FakeWeb.register_uri(:get, @url, :status => 301, :location => @url)
|
64
|
-
@response = loader.get(@url)
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should raise a TooManyRedirects exception with an appropriate message" do
|
69
|
-
@get.should raise_error(Sfn::TooManyRedirects, "Too many redirects")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "and the status is 302" do
|
74
|
-
before(:each) do
|
75
|
-
@get = lambda {
|
76
|
-
FakeWeb.register_uri(:get, @url, :status => 302, :location => @url)
|
77
|
-
@response = loader.get(@url)
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should raise a TooManyRedirects exception with an appropriate message" do
|
82
|
-
@get.should raise_error(Sfn::TooManyRedirects, "Too many redirects")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
50
|
describe "when the status is 400 (Bad Request)" do
|
90
51
|
before(:each) do
|
91
52
|
@status_code = '400'
|
@@ -193,20 +154,20 @@ describe Sfn::Loader do
|
|
193
154
|
end
|
194
155
|
|
195
156
|
# ==== POST ==================================================================================================
|
196
|
-
|
157
|
+
shared_examples_for "#post" do
|
197
158
|
before(:each) do
|
198
159
|
@response = nil
|
199
160
|
@status_code = '200'
|
200
161
|
@post = lambda do
|
201
162
|
FakeWeb.register_uri(
|
202
163
|
:post,
|
203
|
-
|
164
|
+
"http://#{@api_host}:#{@api_port}",
|
204
165
|
:body => @response_body,
|
205
166
|
:status => [@status_code]
|
206
167
|
)
|
207
168
|
loader = Sfn::Loader.new
|
208
169
|
stub(loader).add_authentication {}
|
209
|
-
@response = loader.post(
|
170
|
+
@response = loader.post(@api_url, "a=b")
|
210
171
|
end
|
211
172
|
end
|
212
173
|
|
@@ -265,13 +226,113 @@ describe Sfn::Loader do
|
|
265
226
|
end
|
266
227
|
end
|
267
228
|
|
229
|
+
# ---- GATEWAY -----------------------------------------------------------------------------------------------
|
230
|
+
describe "when the status is 502 (Bad Gateway, returned when a Unicorn worker is killed)" do
|
231
|
+
before(:each) do
|
232
|
+
@status_code = '502'
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should raise an Sfn::BadGateway error" do
|
236
|
+
@post.should raise_error(Sfn::BadGateway, "Bad Gateway")
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe "when the status is 504 (GatewayTimeOut)" do
|
241
|
+
before(:each) do
|
242
|
+
@status_code = '504'
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should raise an Sfn::GatewayTimeOut error" do
|
246
|
+
@post.should raise_error(Sfn::GatewayTimeOut, "Gateway TimeOut")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
context 'over ssl' do
|
252
|
+
before do
|
253
|
+
@api_host = 'test'
|
254
|
+
@api_url = "https://#{@api_host}"
|
255
|
+
@api_port = "443"
|
256
|
+
any_instance_of(Net::HTTP) do |n|
|
257
|
+
mock(n).use_ssl=(true)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
it_should_behave_like '#get'
|
262
|
+
it_should_behave_like '#post'
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'not over ssl' do
|
266
|
+
before do
|
267
|
+
@api_host = 'test'
|
268
|
+
@api_url = "http://#{@api_host}"
|
269
|
+
@api_port = ""
|
270
|
+
end
|
271
|
+
|
272
|
+
it_should_behave_like '#get'
|
273
|
+
it_should_behave_like '#post'
|
274
|
+
|
275
|
+
|
276
|
+
describe "when we are in a redirect loop" do
|
277
|
+
attr_reader :loader
|
278
|
+
|
279
|
+
before(:each) do
|
280
|
+
@url = @api_url
|
281
|
+
@loader = Sfn::Loader.new
|
282
|
+
stub(loader).add_authentication {}
|
283
|
+
end
|
284
|
+
|
285
|
+
describe "and the status is 301" do
|
286
|
+
before(:each) do
|
287
|
+
@get = lambda {
|
288
|
+
FakeWeb.register_uri(:get, "http://#{@api_host}:#{@api_port}", :status => 301, :location => @url)
|
289
|
+
@response = loader.get(@url)
|
290
|
+
}
|
291
|
+
end
|
292
|
+
|
293
|
+
it "should raise a TooManyRedirects exception with an appropriate message" do
|
294
|
+
@get.should raise_error(Sfn::TooManyRedirects, "Too many redirects")
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe "and the status is 302" do
|
299
|
+
before(:each) do
|
300
|
+
@get = lambda {
|
301
|
+
FakeWeb.register_uri(:get, "http://#{@api_host}:#{@api_port}", :status => 302, :location => @url)
|
302
|
+
@response = loader.get(@url)
|
303
|
+
}
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should raise a TooManyRedirects exception with an appropriate message" do
|
307
|
+
@get.should raise_error(Sfn::TooManyRedirects, "Too many redirects")
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
268
313
|
# ---- MAINTENANCE --------------------------------------------------------------------------------------------------
|
314
|
+
describe 'MAINTENANCE' do
|
315
|
+
before(:each) do
|
316
|
+
@api_url = "http://test"
|
317
|
+
@response = nil
|
318
|
+
@status_code = '200'
|
319
|
+
@post = lambda do
|
320
|
+
FakeWeb.register_uri(
|
321
|
+
:post,
|
322
|
+
@api_url,
|
323
|
+
:body => @response_body,
|
324
|
+
:status => [@status_code]
|
325
|
+
)
|
326
|
+
loader = Sfn::Loader.new
|
327
|
+
stub(loader).add_authentication {}
|
328
|
+
@response = loader.post(@api_url, "a=b")
|
329
|
+
end
|
330
|
+
end
|
269
331
|
|
270
332
|
shared_examples_for "the site is in maintenance mode" do
|
271
|
-
|
272
333
|
describe "and there is not an element with a class of error_message_summary in the HTML" do
|
273
334
|
before(:each) do
|
274
|
-
FakeWeb.register_uri(:get,
|
335
|
+
FakeWeb.register_uri(:get, @api_url, :body => "blah", :status => "503")
|
275
336
|
end
|
276
337
|
|
277
338
|
it "should raise an error and include the default maintenance message" do
|
@@ -282,15 +343,14 @@ describe Sfn::Loader do
|
|
282
343
|
describe "and there is an element with a class of error_message_summary in the HTML" do
|
283
344
|
before(:each) do
|
284
345
|
@custom_error = "Something crazy is going down!"
|
285
|
-
|
286
|
-
|
287
|
-
|
346
|
+
@response_body = "<html><head></head><body><h2 class='error_message_summary'>#{@custom_error}</h2></body>"
|
347
|
+
FakeWeb.register_uri(:get, @api_url, :body => @response_body, :status => "503")
|
348
|
+
end
|
288
349
|
|
289
350
|
it "should raise an error and include the contents of the element" do
|
290
351
|
@post.should raise_error(Sfn::SiteMaintenance, @custom_error)
|
291
352
|
end
|
292
353
|
end
|
293
|
-
|
294
354
|
end
|
295
355
|
|
296
356
|
describe "when the status is 405 (Method Not Allowed)" do
|
@@ -303,7 +363,7 @@ describe Sfn::Loader do
|
|
303
363
|
|
304
364
|
describe "when the site is not in maintenance mode" do
|
305
365
|
before(:each) do
|
306
|
-
FakeWeb.register_uri(:get,
|
366
|
+
FakeWeb.register_uri(:get, @api_url, :body => "blah", :status => "200")
|
307
367
|
end
|
308
368
|
|
309
369
|
it "should raise an error and include the reponse body" do
|
@@ -337,28 +397,5 @@ describe Sfn::Loader do
|
|
337
397
|
end
|
338
398
|
end
|
339
399
|
end
|
340
|
-
|
341
|
-
# ---- GATEWAY -----------------------------------------------------------------------------------------------
|
342
|
-
describe "when the status is 502 (Bad Gateway, returned when a Unicorn worker is killed)" do
|
343
|
-
before(:each) do
|
344
|
-
@status_code = '502'
|
345
|
-
end
|
346
|
-
|
347
|
-
it "should raise an Sfn::BadGateway error" do
|
348
|
-
@post.should raise_error(Sfn::BadGateway, "Bad Gateway")
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
describe "when the status is 504 (GatewayTimeOut)" do
|
353
|
-
before(:each) do
|
354
|
-
@status_code = '504'
|
355
|
-
end
|
356
|
-
|
357
|
-
it "should raise an Sfn::GatewayTimeOut error" do
|
358
|
-
@post.should raise_error(Sfn::GatewayTimeOut, "Gateway TimeOut")
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
400
|
end
|
363
|
-
|
364
401
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-satisfaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 3
|
10
|
+
version: 0.7.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Get Satisfaction
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-20 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -198,12 +198,12 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "="
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
hash:
|
201
|
+
hash: 31
|
202
202
|
segments:
|
203
203
|
- 1
|
204
204
|
- 0
|
205
|
-
-
|
206
|
-
version: 1.0.
|
205
|
+
- 4
|
206
|
+
version: 1.0.4
|
207
207
|
type: :development
|
208
208
|
version_requirements: *id012
|
209
209
|
description: Ruby client for using Get Satisfaction's RESTful API. Get Satisfaction is a simple way to build online communities that enable productive conversations between companies and their customers. More than 46,000 companies use Get Satisfaction to provide a more social support experience, build better products, increase SEO and improve customer loyalty. Get Satisfaction communities are available at http://getsatisfaction.com.
|
@@ -243,6 +243,7 @@ files:
|
|
243
243
|
- lib/satisfaction/util.rb
|
244
244
|
- lib/satisfaction/version.rb
|
245
245
|
- ruby-satisfaction.gemspec
|
246
|
+
- spec/integration_spec.rb
|
246
247
|
- spec/satisfaction/associations_spec.rb
|
247
248
|
- spec/satisfaction/identity_map_spec.rb
|
248
249
|
- spec/satisfaction/loader_spec.rb
|
@@ -285,6 +286,7 @@ signing_key:
|
|
285
286
|
specification_version: 3
|
286
287
|
summary: Get Satisfaction ruby client
|
287
288
|
test_files:
|
289
|
+
- spec/integration_spec.rb
|
288
290
|
- spec/satisfaction/associations_spec.rb
|
289
291
|
- spec/satisfaction/identity_map_spec.rb
|
290
292
|
- spec/satisfaction/loader_spec.rb
|