zendesk_api 1.3.9 → 1.4.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/.rspec +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +31 -21
- data/lib/zendesk_api/collection.rb +7 -0
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/association_spec.rb +40 -40
- data/spec/core/client_spec.rb +37 -37
- data/spec/core/collection_spec.rb +81 -70
- data/spec/core/configuration_spec.rb +4 -4
- data/spec/core/create_resource_spec.rb +2 -2
- data/spec/core/data_resource_spec.rb +28 -28
- data/spec/core/inflection_spec.rb +1 -1
- data/spec/core/lru_cache_spec.rb +8 -8
- data/spec/core/middleware/request/encode_json_spec.rb +8 -8
- data/spec/core/middleware/request/etag_cache_spec.rb +5 -5
- data/spec/core/middleware/request/retry_spec.rb +10 -8
- data/spec/core/middleware/request/upload_spec.rb +25 -25
- data/spec/core/middleware/response/callback_spec.rb +1 -1
- data/spec/core/middleware/response/deflate_spec.rb +1 -1
- data/spec/core/middleware/response/gzip_spec.rb +1 -1
- data/spec/core/middleware/response/parse_iso_dates_spec.rb +9 -9
- data/spec/core/middleware/response/parse_json_spec.rb +4 -4
- data/spec/core/middleware/response/raise_error_spec.rb +2 -2
- data/spec/core/read_resource_spec.rb +6 -6
- data/spec/core/resource_spec.rb +66 -66
- data/spec/core/search_spec.rb +3 -3
- data/spec/core/spec_helper.rb +5 -4
- data/spec/core/trackie_spec.rb +17 -17
- data/spec/live/app_installation_spec.rb +2 -2
- data/spec/live/app_spec.rb +1 -1
- data/spec/live/audit_spec.rb +2 -2
- data/spec/live/collection_spec.rb +8 -8
- data/spec/live/locale_spec.rb +1 -1
- data/spec/live/macro_spec.rb +4 -4
- data/spec/live/setting_spec.rb +1 -1
- data/spec/live/tag_spec.rb +7 -7
- data/spec/live/ticket_spec.rb +10 -10
- data/spec/live/topic_comment_spec.rb +2 -2
- data/spec/live/topic_spec.rb +2 -2
- data/spec/live/user_spec.rb +15 -15
- data/spec/macros/resource_macros.rb +17 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d07ce370fb28464897785ae66e33e426fc65b1f
|
4
|
+
data.tar.gz: df2e6e5fed6d5bb977b0707b7f46e7396a3c8c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 789311dcc288abb846bd53a6301df3f1c60988aefec37949272d260e58a85d2fa3faca796f50814578fc377acf813b159fccbe67328a334405b81f596f58fbd6
|
7
|
+
data.tar.gz: 19fc5162ac0a2956a4d6a70cfe082d39dcfdc87d56f81e3c5a53c11442882a507485e5a61529f350700ffbc9d0b32da38f6fb825111b72c6212ba3f1aaf756c6
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--color
|
2
|
-
--format
|
2
|
+
--format documentation
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zendesk_api (1.
|
4
|
+
zendesk_api (1.4.0)
|
5
5
|
faraday (~> 0.9)
|
6
6
|
hashie (>= 1.2)
|
7
7
|
inflection
|
@@ -12,9 +12,9 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
actionpack (3.2.
|
16
|
-
activemodel (= 3.2.
|
17
|
-
activesupport (= 3.2.
|
15
|
+
actionpack (3.2.19)
|
16
|
+
activemodel (= 3.2.19)
|
17
|
+
activesupport (= 3.2.19)
|
18
18
|
builder (~> 3.0.0)
|
19
19
|
erubis (~> 2.7.0)
|
20
20
|
journey (~> 1.0.4)
|
@@ -22,30 +22,35 @@ GEM
|
|
22
22
|
rack-cache (~> 1.2)
|
23
23
|
rack-test (~> 0.6.1)
|
24
24
|
sprockets (~> 2.2.1)
|
25
|
-
activemodel (3.2.
|
26
|
-
activesupport (= 3.2.
|
25
|
+
activemodel (3.2.19)
|
26
|
+
activesupport (= 3.2.19)
|
27
27
|
builder (~> 3.0.0)
|
28
|
-
activesupport (3.2.
|
28
|
+
activesupport (3.2.19)
|
29
29
|
i18n (~> 0.6, >= 0.6.4)
|
30
30
|
multi_json (~> 1.0)
|
31
31
|
addressable (2.3.6)
|
32
32
|
builder (3.0.4)
|
33
33
|
bump (0.5.0)
|
34
|
+
byebug (3.1.2)
|
35
|
+
columnize (~> 0.8)
|
36
|
+
debugger-linecache (~> 1.2)
|
37
|
+
columnize (0.8.9)
|
34
38
|
crack (0.4.2)
|
35
39
|
safe_yaml (~> 1.0.0)
|
40
|
+
debugger-linecache (1.2.0)
|
36
41
|
diff-lcs (1.2.5)
|
37
|
-
docile (1.1.
|
42
|
+
docile (1.1.5)
|
38
43
|
erubis (2.7.0)
|
39
44
|
faraday (0.9.0)
|
40
45
|
multipart-post (>= 1.2, < 3)
|
41
|
-
hashie (3.
|
46
|
+
hashie (3.2.0)
|
42
47
|
hike (1.2.3)
|
43
|
-
i18n (0.6.
|
48
|
+
i18n (0.6.11)
|
44
49
|
inflection (1.0.0)
|
45
50
|
journey (1.0.4)
|
46
51
|
json (1.8.1)
|
47
52
|
mime-types (1.25.1)
|
48
|
-
multi_json (1.10.
|
53
|
+
multi_json (1.10.1)
|
49
54
|
multipart-post (2.0.0)
|
50
55
|
rack (1.4.5)
|
51
56
|
rack-cache (1.2)
|
@@ -53,16 +58,20 @@ GEM
|
|
53
58
|
rack-test (0.6.2)
|
54
59
|
rack (>= 1.0)
|
55
60
|
rake (10.3.2)
|
56
|
-
rspec (
|
57
|
-
rspec-core (~>
|
58
|
-
rspec-expectations (~>
|
59
|
-
rspec-mocks (~>
|
60
|
-
rspec-core (
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
rspec (3.0.0)
|
62
|
+
rspec-core (~> 3.0.0)
|
63
|
+
rspec-expectations (~> 3.0.0)
|
64
|
+
rspec-mocks (~> 3.0.0)
|
65
|
+
rspec-core (3.0.2)
|
66
|
+
rspec-support (~> 3.0.0)
|
67
|
+
rspec-expectations (3.0.2)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.0.0)
|
70
|
+
rspec-mocks (3.0.2)
|
71
|
+
rspec-support (~> 3.0.0)
|
72
|
+
rspec-support (3.0.2)
|
64
73
|
safe_yaml (1.0.3)
|
65
|
-
simplecov (0.
|
74
|
+
simplecov (0.9.0)
|
66
75
|
docile (~> 1.1.0)
|
67
76
|
multi_json
|
68
77
|
simplecov-html (~> 0.8.0)
|
@@ -73,7 +82,7 @@ GEM
|
|
73
82
|
rack (~> 1.0)
|
74
83
|
tilt (~> 1.1, != 1.3.0)
|
75
84
|
tilt (1.4.1)
|
76
|
-
vcr (2.9.
|
85
|
+
vcr (2.9.2)
|
77
86
|
webmock (1.18.0)
|
78
87
|
addressable (>= 2.3.6)
|
79
88
|
crack (>= 0.3.2)
|
@@ -85,6 +94,7 @@ PLATFORMS
|
|
85
94
|
DEPENDENCIES
|
86
95
|
actionpack (~> 3.2)
|
87
96
|
bump
|
97
|
+
byebug
|
88
98
|
jruby-openssl
|
89
99
|
json
|
90
100
|
rake
|
@@ -263,6 +263,10 @@ module ZendeskAPI
|
|
263
263
|
# @private
|
264
264
|
def to_ary; nil; end
|
265
265
|
|
266
|
+
def respond_to?(name)
|
267
|
+
super || Array.new.respond_to?(name)
|
268
|
+
end
|
269
|
+
|
266
270
|
# Sends methods to underlying array of resources.
|
267
271
|
def method_missing(name, *args, &block)
|
268
272
|
if resource_methods.include?(name)
|
@@ -324,6 +328,9 @@ module ZendeskAPI
|
|
324
328
|
|
325
329
|
self.next
|
326
330
|
end
|
331
|
+
|
332
|
+
page(nil)
|
333
|
+
clear_cache
|
327
334
|
end
|
328
335
|
|
329
336
|
def _save(method = :save)
|
data/lib/zendesk_api/version.rb
CHANGED
@@ -13,38 +13,38 @@ describe ZendeskAPI::Association do
|
|
13
13
|
|
14
14
|
it "should not try and fetch nil child" do
|
15
15
|
instance.child_id = nil
|
16
|
-
instance.child.
|
16
|
+
expect(instance.child).to be_nil
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should cache an set object" do
|
20
20
|
instance.child = child
|
21
|
-
instance.child.
|
21
|
+
expect(instance.child).to eq(child)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should set id on set if it was there" do
|
25
25
|
instance.child_id = nil
|
26
26
|
instance.child = child
|
27
|
-
instance.child_id.
|
27
|
+
expect(instance.child_id).to eq(child.id)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should build a object set via hash" do
|
31
31
|
instance.child = {:id => 2}
|
32
|
-
instance.child.id.
|
32
|
+
expect(instance.child.id).to eq(2)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should build a object set via id" do
|
36
36
|
instance.child = 2
|
37
|
-
instance.child.id.
|
37
|
+
expect(instance.child.id).to eq(2)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should not fetch an unknown object" do
|
41
|
-
instance.child.
|
41
|
+
expect(instance.child).to be_nil
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should fetch an object known by id" do
|
45
45
|
stub_json_request(:get, %r{test_resources/1/child/5}, json(:test_child => {:id => 5}))
|
46
46
|
instance.child_id = 5
|
47
|
-
instance.child.id.
|
47
|
+
expect(instance.child.id).to eq(5)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should handle client errors" do
|
@@ -56,65 +56,65 @@ describe ZendeskAPI::Association do
|
|
56
56
|
it "should handle resource not found errors" do
|
57
57
|
stub_request(:get, %r{test_resources/1/child/5}).to_return(:status => 404)
|
58
58
|
instance.child_id = 5
|
59
|
-
silence_logger{ instance.child.
|
59
|
+
silence_logger{ expect(instance.child).to be_nil }
|
60
60
|
end
|
61
61
|
|
62
62
|
it "is not used when not used" do
|
63
|
-
instance.child_used
|
63
|
+
expect(instance.child_used?).to eq(false)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "is used when used" do
|
67
67
|
instance.child = child
|
68
|
-
instance.child_used
|
68
|
+
expect(instance.child_used?).to eq(true)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
context "has_many" do
|
73
73
|
it "should cache a set object" do
|
74
74
|
instance.children = [child]
|
75
|
-
instance.children.map(&:id).
|
76
|
-
instance.children.
|
75
|
+
expect(instance.children.map(&:id)).to eq([1])
|
76
|
+
expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should set ids" do
|
80
80
|
instance.children_ids = []
|
81
81
|
instance.children = [child]
|
82
|
-
instance.children_ids.
|
83
|
-
instance.children.
|
82
|
+
expect(instance.children_ids).to eq([child.id])
|
83
|
+
expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should build and cache objects set via hash" do
|
87
87
|
instance.children = [{:id => 2}]
|
88
|
-
instance.children.map(&:id).
|
89
|
-
instance.children.
|
88
|
+
expect(instance.children.map(&:id)).to eq([2])
|
89
|
+
expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should build a object set via id" do
|
93
93
|
instance.children = [2]
|
94
|
-
instance.children.map(&:id).
|
95
|
-
instance.children.
|
94
|
+
expect(instance.children.map(&:id)).to eq([2])
|
95
|
+
expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should fetch unknown objects" do
|
99
99
|
stub_json_request(:get, %r{test_resources/1/children}, json(:test_children => [{:id => 2}, {:id => 3}]))
|
100
|
-
instance.children.map(&:id).
|
101
|
-
instance.children.
|
100
|
+
expect(instance.children.map(&:id)).to eq([2,3])
|
101
|
+
expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should not change objects" do
|
105
105
|
child = 'foo'
|
106
106
|
children = [child]
|
107
107
|
instance.children = children
|
108
|
-
children[0].
|
108
|
+
expect(children[0]).to eq('foo')
|
109
109
|
end
|
110
110
|
|
111
111
|
it "is not used when not used" do
|
112
|
-
instance.children_used
|
112
|
+
expect(instance.children_used?).to eq(false)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "is used when used" do
|
116
116
|
instance.children = [child]
|
117
|
-
instance.children_used
|
117
|
+
expect(instance.children_used?).to eq(true)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -123,23 +123,23 @@ describe ZendeskAPI::Association do
|
|
123
123
|
subject { described_class.new(:class => ZendeskAPI::TestResource) }
|
124
124
|
|
125
125
|
it "should generate resource path" do
|
126
|
-
subject.generate_path.
|
126
|
+
expect(subject.generate_path).to eq("test_resources")
|
127
127
|
end
|
128
128
|
|
129
129
|
context "with an instance" do
|
130
130
|
it "should generate a specific resource path" do
|
131
|
-
subject.generate_path(instance).
|
131
|
+
expect(subject.generate_path(instance)).to eq("test_resources/1")
|
132
132
|
end
|
133
133
|
|
134
134
|
context "with_id => false" do
|
135
135
|
it "should generate general resource path" do
|
136
|
-
subject.generate_path(instance, :with_id => false).
|
136
|
+
expect(subject.generate_path(instance, :with_id => false)).to eq("test_resources")
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
context "with an instance that is a new record" do
|
141
141
|
it "should generate general resource path" do
|
142
|
-
subject.generate_path(ZendeskAPI::TestResource.new(client)).
|
142
|
+
expect(subject.generate_path(ZendeskAPI::TestResource.new(client))).to eq("test_resources")
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -148,15 +148,15 @@ describe ZendeskAPI::Association do
|
|
148
148
|
before(:each) { subject.options[:path] = "blergh" }
|
149
149
|
|
150
150
|
it "should generate general resource path" do
|
151
|
-
subject.generate_path.
|
151
|
+
expect(subject.generate_path).to eq("blergh")
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
context "with a passed in id" do
|
156
156
|
it "should generate specific resource path" do
|
157
157
|
opts = { :id => 1 }
|
158
|
-
subject.generate_path(opts).
|
159
|
-
opts.
|
158
|
+
expect(subject.generate_path(opts)).to eq("test_resources/1")
|
159
|
+
expect(opts).to be_empty
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
@@ -165,17 +165,17 @@ describe ZendeskAPI::Association do
|
|
165
165
|
subject { described_class.new(:class => ZendeskAPI::TestResource::TestChild, :parent => instance, :name => :children) }
|
166
166
|
|
167
167
|
it "should generate nested resource path" do
|
168
|
-
subject.generate_path.
|
168
|
+
expect(subject.generate_path).to eq("test_resources/1/children")
|
169
169
|
end
|
170
170
|
|
171
171
|
context "with an instance" do
|
172
172
|
it "should generate a specific nested resource path" do
|
173
|
-
subject.generate_path(child).
|
173
|
+
expect(subject.generate_path(child)).to eq("test_resources/1/children/1")
|
174
174
|
end
|
175
175
|
|
176
176
|
context "with_id => false" do
|
177
177
|
it "should generate nested resource path" do
|
178
|
-
subject.generate_path(child, :with_id => false).
|
178
|
+
expect(subject.generate_path(child, :with_id => false)).to eq("test_resources/1/children")
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
@@ -184,7 +184,7 @@ describe ZendeskAPI::Association do
|
|
184
184
|
before(:each) { subject.options[:path] = "blergh" }
|
185
185
|
|
186
186
|
it "should generate nested resource path" do
|
187
|
-
subject.generate_path.
|
187
|
+
expect(subject.generate_path).to eq("test_resources/1/blergh")
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -195,7 +195,7 @@ describe ZendeskAPI::Association do
|
|
195
195
|
end
|
196
196
|
|
197
197
|
it "should generate nested resource path" do
|
198
|
-
subject.generate_path.
|
198
|
+
expect(subject.generate_path).to eq("test_resources/1/blergh")
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
@@ -205,7 +205,7 @@ describe ZendeskAPI::Association do
|
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should generate nested resource path" do
|
208
|
-
subject.generate_path.
|
208
|
+
expect(subject.generate_path).to eq("test_resources/1/test_children")
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
@@ -218,14 +218,14 @@ describe ZendeskAPI::Association do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it "should generate specific nested resource path" do
|
221
|
-
subject.generate_path(child).
|
221
|
+
expect(subject.generate_path(child)).to eq("test_resources/2/children/1")
|
222
222
|
end
|
223
223
|
|
224
224
|
context "with parent id passed in" do
|
225
225
|
it "should generate nested resource path" do
|
226
226
|
opts = { :test_resource_id => 3 }
|
227
|
-
subject.generate_path(opts).
|
228
|
-
opts.
|
227
|
+
expect(subject.generate_path(opts)).to eq("test_resources/3/children")
|
228
|
+
expect(opts).to be_empty
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
@@ -235,7 +235,7 @@ describe ZendeskAPI::Association do
|
|
235
235
|
|
236
236
|
context "with an instance" do
|
237
237
|
it "should not generate a specific resource path" do
|
238
|
-
subject.generate_path(ZendeskAPI::SingularTestResource.new(client, :id => 1)).
|
238
|
+
expect(subject.generate_path(ZendeskAPI::SingularTestResource.new(client, :id => 1))).to eq("singular_test_resources")
|
239
239
|
end
|
240
240
|
end
|
241
241
|
end
|
data/spec/core/client_spec.rb
CHANGED
@@ -49,11 +49,11 @@ describe ZendeskAPI::Client do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should build basic auth middleware" do
|
52
|
-
subject.connection.builder.handlers.index(Faraday::Request::BasicAuthentication).
|
52
|
+
expect(subject.connection.builder.handlers.index(Faraday::Request::BasicAuthentication)).to_not be_nil
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should not build token middleware" do
|
56
|
-
subject.connection.headers["Authorization"].
|
56
|
+
expect(subject.connection.headers["Authorization"]).to be_nil
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -66,11 +66,11 @@ describe ZendeskAPI::Client do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should not build basic auth middleware" do
|
69
|
-
subject.connection.builder.handlers.index(Faraday::Request::BasicAuthentication).
|
69
|
+
expect(subject.connection.builder.handlers.index(Faraday::Request::BasicAuthentication)).to be_nil
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should build token middleware" do
|
73
|
-
subject.connection.headers["Authorization"].
|
73
|
+
expect(subject.connection.headers["Authorization"]).to match(/Bearer/)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -90,25 +90,25 @@ describe ZendeskAPI::Client do
|
|
90
90
|
let(:username) { "hello/token" }
|
91
91
|
|
92
92
|
it "should not add /token to the username" do
|
93
|
-
subject.username.
|
93
|
+
expect(subject.username).to eq("hello/token")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
context "with no password" do
|
98
98
|
it "should build basic auth middleware" do
|
99
|
-
client.connection.builder.handlers.index(Faraday::Request::BasicAuthentication).
|
99
|
+
expect(client.connection.builder.handlers.index(Faraday::Request::BasicAuthentication)).to_not be_nil
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should not build token middleware" do
|
103
|
-
client.connection.builder.handlers.index(Faraday::Request::TokenAuthentication).
|
103
|
+
expect(client.connection.builder.handlers.index(Faraday::Request::TokenAuthentication)).to be_nil
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should copy token to password" do
|
107
|
-
subject.token.
|
107
|
+
expect(subject.token).to eq(subject.password)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should add /token to the username" do
|
111
|
-
subject.username.
|
111
|
+
expect(subject.username).to eq("hello/token")
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -127,12 +127,12 @@ describe ZendeskAPI::Client do
|
|
127
127
|
subject { true }
|
128
128
|
|
129
129
|
it "should log in faraday" do
|
130
|
-
@client.connection.builder.handlers.
|
130
|
+
expect(@client.connection.builder.handlers).to include(ZendeskAPI::Middleware::Response::Logger)
|
131
131
|
end
|
132
132
|
|
133
133
|
context "with a request" do
|
134
134
|
it "should log" do
|
135
|
-
client.config.logger.
|
135
|
+
expect(client.config.logger).to receive(:info).at_least(:once)
|
136
136
|
@client.connection.get('/bs')
|
137
137
|
end
|
138
138
|
end
|
@@ -142,7 +142,7 @@ describe ZendeskAPI::Client do
|
|
142
142
|
subject { false }
|
143
143
|
|
144
144
|
it "should not log" do
|
145
|
-
@client.connection.builder.handlers.
|
145
|
+
expect(@client.connection.builder.handlers).to_not include(ZendeskAPI::Middleware::Response::Logger)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -150,7 +150,7 @@ describe ZendeskAPI::Client do
|
|
150
150
|
subject { nil }
|
151
151
|
|
152
152
|
it "should log" do
|
153
|
-
@client.connection.builder.handlers.
|
153
|
+
expect(@client.connection.builder.handlers).to include(ZendeskAPI::Middleware::Response::Logger)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
@@ -159,12 +159,12 @@ describe ZendeskAPI::Client do
|
|
159
159
|
subject { Logger.new(out) }
|
160
160
|
|
161
161
|
it "should log" do
|
162
|
-
@client.connection.builder.handlers.
|
162
|
+
expect(@client.connection.builder.handlers).to include(ZendeskAPI::Middleware::Response::Logger)
|
163
163
|
end
|
164
164
|
|
165
165
|
context "with a request" do
|
166
166
|
it "should log to the subject" do
|
167
|
-
out.
|
167
|
+
expect(out).to receive(:write).at_least(:once)
|
168
168
|
@client.connection.get('/bs')
|
169
169
|
end
|
170
170
|
end
|
@@ -178,49 +178,49 @@ describe ZendeskAPI::Client do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should be a user instance" do
|
181
|
-
client.current_user.
|
181
|
+
expect(client.current_user).to be_instance_of(ZendeskAPI::User)
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
185
|
context "#connection" do
|
186
186
|
it "should initially be false" do
|
187
|
-
subject.instance_variable_get(:@connection).
|
187
|
+
expect(subject.instance_variable_get(:@connection)).to be_falsey
|
188
188
|
end
|
189
189
|
|
190
190
|
it "connection should be initialized on first call to #connection" do
|
191
|
-
subject.connection.
|
191
|
+
expect(subject.connection).to be_instance_of(Faraday::Connection)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
195
|
context "resources" do
|
196
196
|
it "should return an instance of ZendeskAPI::Collection if there is no method" do
|
197
|
-
subject.instance_variable_get(:@resource_cache)["tickets"].
|
197
|
+
expect(subject.instance_variable_get(:@resource_cache)["tickets"]).to be_nil
|
198
198
|
|
199
|
-
subject.tickets.
|
199
|
+
expect(subject.tickets).to be_instance_of(ZendeskAPI::Collection)
|
200
200
|
|
201
|
-
subject.instance_variable_get(:@resource_cache)["tickets"].
|
202
|
-
subject.instance_variable_get(:@resource_cache)["tickets"][:class].
|
203
|
-
subject.instance_variable_get(:@resource_cache)["tickets"][:cache].
|
201
|
+
expect(subject.instance_variable_get(:@resource_cache)["tickets"]).to_not be_empty
|
202
|
+
expect(subject.instance_variable_get(:@resource_cache)["tickets"][:class]).to eq(ZendeskAPI::Ticket)
|
203
|
+
expect(subject.instance_variable_get(:@resource_cache)["tickets"][:cache]).to be_instance_of(ZendeskAPI::LRUCache)
|
204
204
|
|
205
|
-
ZendeskAPI.
|
206
|
-
subject.tickets.
|
205
|
+
expect(ZendeskAPI).to_not receive(:const_get)
|
206
|
+
expect(subject.tickets).to be_instance_of(ZendeskAPI::Collection)
|
207
207
|
end
|
208
208
|
|
209
209
|
it "should not cache calls with different options" do
|
210
|
-
subject.search(:query => 'abc').
|
210
|
+
expect(subject.search(:query => 'abc')).to_not eq(subject.search(:query => '123'))
|
211
211
|
end
|
212
212
|
|
213
213
|
it "should not cache calls with :reload => true options" do
|
214
|
-
subject.search(:query => 'abc').
|
214
|
+
expect(subject.search(:query => 'abc')).to_not eq(subject.search(:query => 'abc', :reload => true))
|
215
215
|
end
|
216
216
|
|
217
217
|
it "should not pass reload to the underlying collection" do
|
218
218
|
collection = subject.search(:query => 'abc', :reload => true)
|
219
|
-
collection.options.key?(:reload).
|
219
|
+
expect(collection.options.key?(:reload)).to be(false)
|
220
220
|
end
|
221
221
|
|
222
222
|
it "should cache calls with the same options" do
|
223
|
-
subject.search(:query => 'abc').
|
223
|
+
expect(subject.search(:query => 'abc')).to eq(subject.search(:query => 'abc'))
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
@@ -228,22 +228,22 @@ describe ZendeskAPI::Client do
|
|
228
228
|
client = SimpleClient.new do |config|
|
229
229
|
config.allow_http = true
|
230
230
|
end
|
231
|
-
client.config.allow_http.
|
232
|
-
client.connection.
|
233
|
-
client.connection.object_id.
|
231
|
+
expect(client.config.allow_http).to eq(true)
|
232
|
+
expect(client.connection).to eq("FOO")
|
233
|
+
expect(client.connection.object_id).to eq(client.connection.object_id) # it's cached
|
234
234
|
end
|
235
235
|
|
236
236
|
context ZendeskAPI::Voice do
|
237
237
|
it "defers to voice delegator" do
|
238
|
-
|
238
|
+
expect(subject).to receive(:phone_numbers).once
|
239
239
|
subject.voice.phone_numbers
|
240
240
|
end
|
241
241
|
|
242
242
|
it "manages namespace correctly" do
|
243
|
-
client.certification_addresses.path.
|
244
|
-
client.phone_numbers.path.
|
245
|
-
client.greetings.path.
|
246
|
-
client.greeting_categories.path.
|
243
|
+
expect(client.certification_addresses.path).to match(/channels\/voice\/certification_addresses/)
|
244
|
+
expect(client.phone_numbers.path).to match(/channels\/voice\/phone_numbers/)
|
245
|
+
expect(client.greetings.path).to match(/channels\/voice\/greetings/)
|
246
|
+
expect(client.greeting_categories.path).to match(/channels\/voice\/greeting_categories/)
|
247
247
|
end
|
248
248
|
end
|
249
249
|
end
|