zendesk_api 1.3.0.rc3 → 1.3.0

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: e0af96893eadf039d7ee2f55140c99a2ebb6493b
4
- data.tar.gz: 3cece9eb1e9d0e1d6028741316148efd0d81aff5
3
+ metadata.gz: 9b310b67f1f0ce7aab3145806d7048e85b2a3803
4
+ data.tar.gz: bcc2ab5a29bc5779f2cd946753db97079ed11aa4
5
5
  SHA512:
6
- metadata.gz: d9a690f20225ad74dc19f0991786edef89b6fcfe721f81850897cca6d9b3b931f1d4c362c2baf26f81a9a21983db4f8479b239c7571999bc26e52cb0f2fc9b07
7
- data.tar.gz: ca2b7c76939a390ae9d7ae464e8a5780e69a13afe42e219080444dc9f2f812d9db1b770832da1bc99869e01db02997c9029b6895448b29dcc5cfad1cd0b01831
6
+ metadata.gz: 173b1e1da892d91d642d415c51cc91adf838f947550fdbec70a8cf3caeef0ff2b800aef04b51bb9e1a201f6a67042911df8d7b5d226d1f8ded5c9cfd61f39a8e
7
+ data.tar.gz: a5f27802163083b8b3932e6573dafd3ac7319bece572e582d05ad521e73c17e58ceb341daf180343b6003f2b2ffc8ea0e4373988e3ce35ad5644f37b6eaf80f2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zendesk_api (1.3.0.rc3)
4
+ zendesk_api (1.3.0)
5
5
  faraday (~> 0.9)
6
6
  hashie (>= 1.2)
7
7
  inflection
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "1.3.0.rc3"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -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.8.7"
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.rc3
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-14 00:00:00.000000000 Z
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.8.7
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