zendesk_api 1.3.0.rc3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/middleware/request/encode_json_spec.rb +73 -0
- data/spec/core/middleware/response/parse_json_spec.rb +53 -0
- data/zendesk_api.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b310b67f1f0ce7aab3145806d7048e85b2a3803
|
4
|
+
data.tar.gz: bcc2ab5a29bc5779f2cd946753db97079ed11aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 173b1e1da892d91d642d415c51cc91adf838f947550fdbec70a8cf3caeef0ff2b800aef04b51bb9e1a201f6a67042911df8d7b5d226d1f8ded5c9cfd61f39a8e
|
7
|
+
data.tar.gz: a5f27802163083b8b3932e6573dafd3ac7319bece572e582d05ad521e73c17e58ceb341daf180343b6003f2b2ffc8ea0e4373988e3ce35ad5644f37b6eaf80f2
|
data/Gemfile.lock
CHANGED
data/lib/zendesk_api/version.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'core/spec_helper'
|
2
|
+
|
3
|
+
describe ZendeskAPI::Middleware::Request::EncodeJson do
|
4
|
+
let(:app) do
|
5
|
+
ZendeskAPI::Middleware::Request::EncodeJson.new(lambda {|x| x})
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:response) { app.call({ :request_headers => {} }.merge(env)) }
|
9
|
+
|
10
|
+
context 'with a nil body' do
|
11
|
+
let(:env) {{ :body => nil }}
|
12
|
+
|
13
|
+
it 'should not return json' do
|
14
|
+
response[:body].should be_nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with an empty body' do
|
19
|
+
let(:env) {{ :body => '' }}
|
20
|
+
|
21
|
+
it 'should not return json' do
|
22
|
+
response[:body].should == ''
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with a proper mime type' do
|
27
|
+
context 'empty' do
|
28
|
+
let(:env) {{ :body => { :a => :b } }}
|
29
|
+
|
30
|
+
it 'encodes json' do
|
31
|
+
response[:body].should == JSON.dump(:a => :b)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'sets the content type' do
|
35
|
+
response[:request_headers]['Content-Type'].should == 'application/json'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'application/json' do
|
40
|
+
let(:env) {{
|
41
|
+
:body => { :a => :b },
|
42
|
+
:request_headers => {
|
43
|
+
'Content-Type' => 'application/json'
|
44
|
+
}
|
45
|
+
}}
|
46
|
+
|
47
|
+
it 'encodes json' do
|
48
|
+
response[:body].should == JSON.dump(:a => :b)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'keeps the content type' do
|
52
|
+
response[:request_headers]['Content-Type'].should == 'application/json'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'application/json; encoding=utf-8' do
|
57
|
+
let(:env) {{
|
58
|
+
:body => { :a => :b },
|
59
|
+
:request_headers => {
|
60
|
+
'Content-Type' => 'application/json; encoding=utf-8'
|
61
|
+
}
|
62
|
+
}}
|
63
|
+
|
64
|
+
it 'encodes json' do
|
65
|
+
response[:body].should == JSON.dump(:a => :b)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'keeps the content type' do
|
69
|
+
response[:request_headers]['Content-Type'].should == 'application/json; encoding=utf-8'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'core/spec_helper'
|
2
|
+
|
3
|
+
describe ZendeskAPI::Middleware::Response::ParseJson do
|
4
|
+
context "with another content-type" do
|
5
|
+
before(:each) do
|
6
|
+
stub_request(:get, %r{blergh}).to_return(
|
7
|
+
:headers => {
|
8
|
+
:content_type => "application/xml"
|
9
|
+
},
|
10
|
+
:body => '<nope></nope>'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return nil body" do
|
15
|
+
client.connection.get("blergh").body.should be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with content-type = 'application/json'" do
|
20
|
+
before(:each) do
|
21
|
+
stub_request(:get, %r{blergh}).to_return(
|
22
|
+
:headers => {
|
23
|
+
:content_type => "application/json"
|
24
|
+
},
|
25
|
+
:body => body
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with a nil body" do
|
30
|
+
let(:body) { nil }
|
31
|
+
|
32
|
+
it "should return nil body" do
|
33
|
+
client.connection.get("blergh").body.should be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with a empty body" do
|
38
|
+
let(:body) { '' }
|
39
|
+
|
40
|
+
it "should return nil body" do
|
41
|
+
client.connection.get("blergh").body.should be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'proper json' do
|
46
|
+
let(:body) { '{ "TESTDATA": true }' }
|
47
|
+
|
48
|
+
it "should parse returned body" do
|
49
|
+
client.connection.get("blergh").body['TESTDATA'].should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/zendesk_api.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.description = %q{Ruby wrapper for the REST API at http://www.zendesk.com. Documentation at http://developer.zendesk.com.}
|
16
16
|
s.license = 'Apache License Version 2.0'
|
17
17
|
|
18
|
-
s.required_ruby_version = ">= 1.
|
18
|
+
s.required_ruby_version = ">= 1.9.0"
|
19
19
|
s.required_rubygems_version = ">= 1.3.6"
|
20
20
|
|
21
21
|
s.add_development_dependency "bump"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Davidovitz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bump
|
@@ -411,6 +411,7 @@ files:
|
|
411
411
|
- spec/core/data_resource_spec.rb
|
412
412
|
- spec/core/inflection_spec.rb
|
413
413
|
- spec/core/lru_cache_spec.rb
|
414
|
+
- spec/core/middleware/request/encode_json_spec.rb
|
414
415
|
- spec/core/middleware/request/etag_cache_spec.rb
|
415
416
|
- spec/core/middleware/request/retry_spec.rb
|
416
417
|
- spec/core/middleware/request/test.jpg
|
@@ -419,6 +420,7 @@ files:
|
|
419
420
|
- spec/core/middleware/response/deflate_spec.rb
|
420
421
|
- spec/core/middleware/response/gzip_spec.rb
|
421
422
|
- spec/core/middleware/response/parse_iso_dates_spec.rb
|
423
|
+
- spec/core/middleware/response/parse_json_spec.rb
|
422
424
|
- spec/core/middleware/response/raise_error_spec.rb
|
423
425
|
- spec/core/read_resource_spec.rb
|
424
426
|
- spec/core/resource_spec.rb
|
@@ -501,7 +503,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
501
503
|
requirements:
|
502
504
|
- - ">="
|
503
505
|
- !ruby/object:Gem::Version
|
504
|
-
version: 1.
|
506
|
+
version: 1.9.0
|
505
507
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
506
508
|
requirements:
|
507
509
|
- - ">="
|
@@ -522,6 +524,7 @@ test_files:
|
|
522
524
|
- spec/core/data_resource_spec.rb
|
523
525
|
- spec/core/inflection_spec.rb
|
524
526
|
- spec/core/lru_cache_spec.rb
|
527
|
+
- spec/core/middleware/request/encode_json_spec.rb
|
525
528
|
- spec/core/middleware/request/etag_cache_spec.rb
|
526
529
|
- spec/core/middleware/request/retry_spec.rb
|
527
530
|
- spec/core/middleware/request/test.jpg
|
@@ -530,6 +533,7 @@ test_files:
|
|
530
533
|
- spec/core/middleware/response/deflate_spec.rb
|
531
534
|
- spec/core/middleware/response/gzip_spec.rb
|
532
535
|
- spec/core/middleware/response/parse_iso_dates_spec.rb
|
536
|
+
- spec/core/middleware/response/parse_json_spec.rb
|
533
537
|
- spec/core/middleware/response/raise_error_spec.rb
|
534
538
|
- spec/core/read_resource_spec.rb
|
535
539
|
- spec/core/resource_spec.rb
|