zendesk_api 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gem "simplecov", :platforms => :ruby_19, :group => :development
4
4
  gem "jruby-openssl", :platforms => :jruby
5
5
  gem "hashie", :git => "git://github.com/intridea/hashie.git"
6
6
  gem "multipart-post", :git => "git://github.com/steved555/multipart-post.git"
7
+ gem "multi_json", :group => :test
7
8
 
8
9
  group :server do
9
10
  gem "rack-ssl-enforcer"
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- zendesk_api (0.2.4)
16
+ zendesk_api (0.2.5)
17
17
  faraday (>= 0.8.0)
18
18
  faraday_middleware (>= 0.8.7)
19
19
  hashie
@@ -32,10 +32,12 @@ GEM
32
32
  i18n (~> 0.6)
33
33
  multi_json (~> 1.0)
34
34
  addressable (2.3.2)
35
- backports (2.6.5)
35
+ backports (2.8.2)
36
36
  bond (0.4.3)
37
+ bond (0.4.3-java)
37
38
  bootstrap-sass (2.2.2.0)
38
39
  sass (~> 3.2)
40
+ bouncy-castle-java (1.5.0146.1)
39
41
  builder (3.0.4)
40
42
  bump (0.3.9)
41
43
  chunky_png (1.2.7)
@@ -50,25 +52,28 @@ GEM
50
52
  database_cleaner (0.9.1)
51
53
  diff-lcs (1.1.3)
52
54
  eventmachine (1.0.0)
53
- faraday (0.8.4)
55
+ eventmachine (1.0.0-java)
56
+ faraday (0.8.5)
54
57
  multipart-post (~> 1.1)
55
58
  faraday_middleware (0.9.0)
56
59
  faraday (>= 0.7.4, < 0.9)
57
- fssm (0.2.9)
60
+ fssm (0.2.10)
58
61
  haml (3.1.7)
59
62
  i18n (0.6.1)
60
63
  inflection (1.0.0)
64
+ jruby-openssl (0.8.2)
65
+ bouncy-castle-java (>= 1.5.0146.1)
61
66
  json (1.7.6)
62
- mime-types (1.19)
63
- mongoid (3.0.16)
67
+ mime-types (1.20.1)
68
+ mongoid (3.0.21)
64
69
  activemodel (~> 3.1)
65
- moped (~> 1.1)
70
+ moped (~> 1.2)
66
71
  origin (~> 1.0)
67
72
  tzinfo (~> 0.3.22)
68
73
  moped (1.3.2)
69
74
  multi_json (1.5.0)
70
75
  origin (1.0.11)
71
- rack (1.4.3)
76
+ rack (1.5.1)
72
77
  rack-protection (1.3.2)
73
78
  rack
74
79
  rack-ssl-enforcer (0.2.5)
@@ -85,15 +90,15 @@ GEM
85
90
  rspec-core (2.12.2)
86
91
  rspec-expectations (2.12.1)
87
92
  diff-lcs (~> 1.1.3)
88
- rspec-mocks (2.12.1)
93
+ rspec-mocks (2.12.2)
89
94
  sass (3.2.5)
90
95
  simplecov (0.7.1)
91
96
  multi_json (~> 1.0)
92
97
  simplecov-html (~> 0.7.1)
93
98
  simplecov-html (0.7.1)
94
- sinatra (1.3.3)
95
- rack (~> 1.3, >= 1.3.6)
96
- rack-protection (~> 1.2)
99
+ sinatra (1.3.4)
100
+ rack (~> 1.4)
101
+ rack-protection (~> 1.3)
97
102
  tilt (~> 1.3, >= 1.3.3)
98
103
  sinatra-contrib (1.3.2)
99
104
  backports (>= 2.0)
@@ -108,9 +113,10 @@ GEM
108
113
  webmock (1.9.0)
109
114
  addressable (>= 2.2.7)
110
115
  crack (>= 0.1.7)
111
- yard (0.8.3)
116
+ yard (0.8.4.1)
112
117
 
113
118
  PLATFORMS
119
+ java
114
120
  ruby
115
121
 
116
122
  DEPENDENCIES
@@ -124,6 +130,7 @@ DEPENDENCIES
124
130
  hashie!
125
131
  jruby-openssl
126
132
  mongoid
133
+ multi_json
127
134
  multipart-post!
128
135
  rack-ssl-enforcer
129
136
  rake
@@ -20,14 +20,16 @@ module ZendeskAPI
20
20
  def attach_error(e)
21
21
  return unless e.response
22
22
 
23
- if error = e.response[:body]
24
- if error.is_a?(Hash)
23
+ if respond_to?("error_message=")
24
+ self.error_message = nil
25
+
26
+ if (error = e.response[:body]) && error.is_a?(Hash)
25
27
  error = Hashie::Mash.new(error)
26
- self.error_message = (error.error || error.description) if respond_to?("error_message=")
28
+ self.error_message = (error.error || error.description)
27
29
  end
28
-
29
- self.error = error if respond_to?("error=")
30
30
  end
31
+
32
+ self.error = e if respond_to?("error=")
31
33
  end
32
34
 
33
35
  def rescue_client_error(*args)
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -61,21 +61,55 @@ describe ZendeskAPI::Rescue do
61
61
  end
62
62
 
63
63
  context "when class has error attributes", :silence_logger do
64
- let(:response) {{ :body => { :error => { :description => "hello" } } }}
65
64
  let(:instance) { Boom.new(client) }
66
65
 
67
- before do
68
- Boom.send(:attr_accessor, :error, :error_message)
69
-
66
+ let(:exception) do
70
67
  exception = Exception.new("message")
71
68
  exception.set_backtrace([])
69
+ exception
70
+ end
71
+
72
+ let(:error) do
73
+ Faraday::Error::ClientError.new(exception, response)
74
+ end
72
75
 
73
- error = Faraday::Error::ClientError.new(exception, response)
76
+ before do
77
+ Boom.send(:attr_accessor, :error, :error_message)
74
78
  instance.puff(error)
75
79
  end
76
80
 
77
- it "should attach the error" do
78
- instance.error.should_not be_nil
81
+ context "with no response" do
82
+ let(:response) {{}}
83
+
84
+ it "should attach the error" do
85
+ instance.error.should_not be_nil
86
+ end
87
+
88
+ it "should not attach the message" do
89
+ instance.error_message.should be_nil
90
+ end
91
+ end
92
+
93
+ context "with a response" do
94
+ let(:response) {{ :body => { :error => { :description => "hello" } } }}
95
+
96
+ it "should attach the error" do
97
+ instance.error.should_not be_nil
98
+ end
99
+
100
+ it "should attach the error message" do
101
+ instance.error_message.should_not be_nil
102
+ end
103
+
104
+ context "and again with no response" do
105
+ before do
106
+ instance.puff(Faraday::Error::ClientError.new(exception, {}))
107
+ end
108
+
109
+ it "should clear the error message" do
110
+ instance.error_message.should be_nil
111
+ end
112
+ end
79
113
  end
80
114
  end
81
115
 
@@ -51,8 +51,7 @@ describe ZendeskAPI::Ticket do
51
51
 
52
52
  it "is able to do next" do
53
53
  first = results.to_a.first
54
- recent_url = "api/v2/exports/tickets.json\\?start_time=#{Time.now.to_i.to_s[0..5]}"
55
- stub_json_request(:get, /#{recent_url}/, json(:results => []))
54
+ stub_json_request(:get, %r{/api/v2/exports/tickets}, json(:results => []))
56
55
 
57
56
  results.next
58
57
  results.first.should_not == first
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: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-04 00:00:00.000000000 Z
13
+ date: 2013-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bump