kintone 0.1.4 → 0.1.5
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/.coveralls.yml +1 -0
- data/.rubocop.yml +11 -1
- data/.travis.yml +15 -1
- data/Guardfile +2 -2
- data/README.md +4 -0
- data/kintone.gemspec +3 -5
- data/lib/kintone/api.rb +18 -24
- data/lib/kintone/api/guest.rb +6 -2
- data/lib/kintone/command/accessor.rb +1 -1
- data/lib/kintone/command/guests.rb +1 -1
- data/lib/kintone/command/record.rb +1 -1
- data/lib/kintone/command/records.rb +3 -2
- data/lib/kintone/kintone_error.rb +11 -0
- data/lib/kintone/query.rb +1 -1
- data/lib/kintone/version.rb +1 -1
- data/spec/kintone/api/guest_spec.rb +98 -10
- data/spec/kintone/api_spec.rb +186 -75
- data/spec/kintone/command/apis_spec.rb +70 -8
- data/spec/kintone/command/app_acl_spec.rb +21 -6
- data/spec/kintone/command/app_spec.rb +22 -2
- data/spec/kintone/command/apps_spec.rb +25 -2
- data/spec/kintone/command/bulk_request_spec.rb +22 -2
- data/spec/kintone/command/field_acl_spec.rb +25 -7
- data/spec/kintone/command/file_spec.rb +28 -12
- data/spec/kintone/command/form_spec.rb +23 -6
- data/spec/kintone/command/guests_spec.rb +44 -4
- data/spec/kintone/command/record_acl_spec.rb +27 -8
- data/spec/kintone/command/record_spec.rb +77 -10
- data/spec/kintone/command/records_spec.rb +157 -15
- data/spec/kintone/command/space_body_spec.rb +25 -7
- data/spec/kintone/command/space_guests_spec.rb +22 -2
- data/spec/kintone/command/space_members_spec.rb +47 -13
- data/spec/kintone/command/space_spec.rb +49 -19
- data/spec/kintone/command/space_thread_spec.rb +26 -2
- data/spec/kintone/command/template_space_spec.rb +37 -20
- data/spec/kintone/kintone_error_spec.rb +22 -0
- data/spec/spec_helper.rb +3 -0
- metadata +17 -27
data/spec/kintone/api_spec.rb
CHANGED
@@ -15,10 +15,9 @@ describe Kintone::Api do
|
|
15
15
|
describe '#get_url' do
|
16
16
|
subject { target.get_url(command) }
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
18
|
+
let(:command) { 'path' }
|
19
|
+
|
20
|
+
it { is_expected.to eq('/k/v1/path.json') }
|
22
21
|
end
|
23
22
|
|
24
23
|
describe '#guest' do
|
@@ -52,8 +51,11 @@ describe Kintone::Api do
|
|
52
51
|
query: query,
|
53
52
|
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
54
53
|
)
|
55
|
-
.to_return(
|
56
|
-
|
54
|
+
.to_return(
|
55
|
+
body: '{"abc":"def"}',
|
56
|
+
status: 200,
|
57
|
+
headers: { 'Content-type' => 'application/json' }
|
58
|
+
)
|
57
59
|
end
|
58
60
|
|
59
61
|
subject { target.get(path, params) }
|
@@ -88,6 +90,28 @@ describe Kintone::Api do
|
|
88
90
|
|
89
91
|
it { is_expected.to eq 'abc' => 'def' }
|
90
92
|
end
|
93
|
+
|
94
|
+
context 'fail to request' do
|
95
|
+
before(:each) do
|
96
|
+
stub_request(
|
97
|
+
:get,
|
98
|
+
'https://www.example.com/k/v1/path'
|
99
|
+
)
|
100
|
+
.with(
|
101
|
+
query: query,
|
102
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
103
|
+
)
|
104
|
+
.to_return(
|
105
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
106
|
+
status: 500
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
let(:params) { {} }
|
111
|
+
let(:query) { nil }
|
112
|
+
|
113
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
114
|
+
end
|
91
115
|
end
|
92
116
|
|
93
117
|
describe '#post' do
|
@@ -101,10 +125,13 @@ describe Kintone::Api do
|
|
101
125
|
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
102
126
|
'Content-Type' => 'application/json'
|
103
127
|
},
|
104
|
-
body:
|
128
|
+
body: '{"p1":"abc","p2":"def"}'
|
129
|
+
)
|
130
|
+
.to_return(
|
131
|
+
body: '{"abc":"def"}',
|
132
|
+
status: 200,
|
133
|
+
headers: { 'Content-type' => 'application/json' }
|
105
134
|
)
|
106
|
-
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
107
|
-
headers: { 'Content-type' => 'application/json' })
|
108
135
|
end
|
109
136
|
|
110
137
|
subject { target.post(path, body) }
|
@@ -112,6 +139,28 @@ describe Kintone::Api do
|
|
112
139
|
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
113
140
|
|
114
141
|
it { is_expected.to eq 'abc' => 'def' }
|
142
|
+
|
143
|
+
context 'fail to request' do
|
144
|
+
before(:each) do
|
145
|
+
stub_request(
|
146
|
+
:post,
|
147
|
+
'https://www.example.com/k/v1/path'
|
148
|
+
)
|
149
|
+
.with(
|
150
|
+
headers: {
|
151
|
+
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
152
|
+
'Content-Type' => 'application/json'
|
153
|
+
},
|
154
|
+
body: '{"p1":"abc","p2":"def"}'
|
155
|
+
)
|
156
|
+
.to_return(
|
157
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
158
|
+
status: 500
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
163
|
+
end
|
115
164
|
end
|
116
165
|
|
117
166
|
describe '#put' do
|
@@ -125,10 +174,13 @@ describe Kintone::Api do
|
|
125
174
|
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
126
175
|
'Content-Type' => 'application/json'
|
127
176
|
},
|
128
|
-
body:
|
177
|
+
body: '{"p1":"abc","p2":"def"}'
|
178
|
+
)
|
179
|
+
.to_return(
|
180
|
+
body: '{"abc":"def"}',
|
181
|
+
status: 200,
|
182
|
+
headers: { 'Content-type' => 'application/json' }
|
129
183
|
)
|
130
|
-
.to_return(body: "{\"abc\":\"def\"}", status: 200,
|
131
|
-
headers: { 'Content-type' => 'application/json' })
|
132
184
|
end
|
133
185
|
|
134
186
|
subject { target.put(path, body) }
|
@@ -136,6 +188,28 @@ describe Kintone::Api do
|
|
136
188
|
let(:body) { { 'p1' => 'abc', 'p2' => 'def' } }
|
137
189
|
|
138
190
|
it { is_expected.to eq 'abc' => 'def' }
|
191
|
+
|
192
|
+
context 'fail to request' do
|
193
|
+
before(:each) do
|
194
|
+
stub_request(
|
195
|
+
:put,
|
196
|
+
'https://www.example.com/k/v1/path'
|
197
|
+
)
|
198
|
+
.with(
|
199
|
+
headers: {
|
200
|
+
'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=',
|
201
|
+
'Content-Type' => 'application/json'
|
202
|
+
},
|
203
|
+
body: '{"p1":"abc","p2":"def"}'
|
204
|
+
)
|
205
|
+
.to_return(
|
206
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
207
|
+
status: 500
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
212
|
+
end
|
139
213
|
end
|
140
214
|
|
141
215
|
describe '#delete' do
|
@@ -148,8 +222,11 @@ describe Kintone::Api do
|
|
148
222
|
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
|
149
223
|
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
150
224
|
)
|
151
|
-
.to_return(
|
152
|
-
|
225
|
+
.to_return(
|
226
|
+
body: '{"abc":"def"}',
|
227
|
+
status: 200,
|
228
|
+
headers: { 'Content-type' => 'application/json' }
|
229
|
+
)
|
153
230
|
end
|
154
231
|
|
155
232
|
subject { target.delete(path, params) }
|
@@ -157,24 +234,41 @@ describe Kintone::Api do
|
|
157
234
|
let(:params) { { 'p1' => 'abc', 'p2' => 'def' } }
|
158
235
|
|
159
236
|
it { is_expected.to eq 'abc' => 'def' }
|
237
|
+
|
238
|
+
context 'fail to request' do
|
239
|
+
before(:each) do
|
240
|
+
stub_request(
|
241
|
+
:delete,
|
242
|
+
'https://www.example.com/k/v1/path'
|
243
|
+
)
|
244
|
+
.with(
|
245
|
+
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
|
246
|
+
headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }
|
247
|
+
)
|
248
|
+
.to_return(
|
249
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
250
|
+
status: 500
|
251
|
+
)
|
252
|
+
end
|
253
|
+
|
254
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
255
|
+
end
|
160
256
|
end
|
161
257
|
|
162
258
|
describe '#post_file' do
|
163
259
|
before(:each) do
|
164
260
|
stub_request(
|
165
|
-
|
166
|
-
|
261
|
+
:post,
|
262
|
+
'https://www.example.com/k/v1/path'
|
167
263
|
)
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
'Content-Disposition' => 'form-data')
|
177
|
-
.and_return(attachment)
|
264
|
+
.with(headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }) { attachment } # rubocop:disable Metrics/LineLength
|
265
|
+
.to_return(
|
266
|
+
body: '{"fileKey":"abc"}',
|
267
|
+
status: 200,
|
268
|
+
headers: { 'Content-type' => 'application/json' }
|
269
|
+
)
|
270
|
+
|
271
|
+
expect(Faraday::UploadIO).to receive(:new).with(path, content_type, original_filename).and_return(attachment) # rubocop:disable Metrics/LineLength
|
178
272
|
end
|
179
273
|
|
180
274
|
subject { target.post_file(url, path, content_type, original_filename) }
|
@@ -185,6 +279,22 @@ describe Kintone::Api do
|
|
185
279
|
let(:original_filename) { 'fileName.txt' }
|
186
280
|
|
187
281
|
it { is_expected.to eq 'abc' }
|
282
|
+
|
283
|
+
context 'fail to request' do
|
284
|
+
before(:each) do
|
285
|
+
stub_request(
|
286
|
+
:post,
|
287
|
+
'https://www.example.com/k/v1/path'
|
288
|
+
)
|
289
|
+
.with(headers: { 'X-Cybozu-Authorization' => 'QWRtaW5pc3RyYXRvcjpjeWJvenU=' }) { attachment } # rubocop:disable Metrics/LineLength
|
290
|
+
.to_return(
|
291
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
292
|
+
status: 500
|
293
|
+
)
|
294
|
+
end
|
295
|
+
|
296
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
297
|
+
end
|
188
298
|
end
|
189
299
|
|
190
300
|
describe '#record' do
|
@@ -303,15 +413,15 @@ describe Kintone::Api do
|
|
303
413
|
describe '#get' do
|
304
414
|
before(:each) do
|
305
415
|
stub_request(
|
306
|
-
|
307
|
-
|
416
|
+
:get,
|
417
|
+
'https://www.example.com/k/v1/path'
|
308
418
|
)
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
419
|
+
.with(query: query, headers: { 'X-Cybozu-API-Token' => 'token-api' })
|
420
|
+
.to_return(
|
421
|
+
body: '{"abc":"def"}',
|
422
|
+
status: 200,
|
423
|
+
headers: { 'Content-type' => 'application/json' }
|
424
|
+
)
|
315
425
|
end
|
316
426
|
|
317
427
|
subject { target.get(path, params) }
|
@@ -330,18 +440,18 @@ describe Kintone::Api do
|
|
330
440
|
describe '#post' do
|
331
441
|
before(:each) do
|
332
442
|
stub_request(
|
333
|
-
|
334
|
-
|
443
|
+
:post,
|
444
|
+
'https://www.example.com/k/v1/path'
|
335
445
|
)
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
446
|
+
.with(
|
447
|
+
headers: { 'X-Cybozu-API-Token' => 'token-api', 'Content-Type' => 'application/json' },
|
448
|
+
body: '{"p1":"abc","p2":"def"}'
|
449
|
+
)
|
450
|
+
.to_return(
|
451
|
+
body: '{"abc":"def"}',
|
452
|
+
status: 200,
|
453
|
+
headers: { 'Content-type' => 'application/json' }
|
454
|
+
)
|
345
455
|
end
|
346
456
|
|
347
457
|
subject { target.post(path, body) }
|
@@ -354,18 +464,18 @@ describe Kintone::Api do
|
|
354
464
|
describe '#put' do
|
355
465
|
before(:each) do
|
356
466
|
stub_request(
|
357
|
-
|
358
|
-
|
467
|
+
:put,
|
468
|
+
'https://www.example.com/k/v1/path'
|
359
469
|
)
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
470
|
+
.with(
|
471
|
+
headers: { 'X-Cybozu-API-Token' => 'token-api', 'Content-Type' => 'application/json' },
|
472
|
+
body: '{"p1":"abc","p2":"def"}'
|
473
|
+
)
|
474
|
+
.to_return(
|
475
|
+
body: '{"abc":"def"}',
|
476
|
+
status: 200,
|
477
|
+
headers: { 'Content-type' => 'application/json' }
|
478
|
+
)
|
369
479
|
end
|
370
480
|
|
371
481
|
subject { target.put(path, body) }
|
@@ -378,15 +488,18 @@ describe Kintone::Api do
|
|
378
488
|
describe '#delete' do
|
379
489
|
before(:each) do
|
380
490
|
stub_request(
|
381
|
-
|
382
|
-
|
491
|
+
:delete,
|
492
|
+
'https://www.example.com/k/v1/path'
|
383
493
|
)
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
494
|
+
.with(
|
495
|
+
body: { 'p1' => 'abc', 'p2' => 'def' }.to_json,
|
496
|
+
headers: { 'X-Cybozu-API-Token' => 'token-api' }
|
497
|
+
)
|
498
|
+
.to_return(
|
499
|
+
body: '{"abc":"def"}',
|
500
|
+
status: 200,
|
501
|
+
headers: { 'Content-type' => 'application/json' }
|
502
|
+
)
|
390
503
|
end
|
391
504
|
|
392
505
|
subject { target.delete(path, params) }
|
@@ -399,19 +512,17 @@ describe Kintone::Api do
|
|
399
512
|
describe '#post_file' do
|
400
513
|
before(:each) do
|
401
514
|
stub_request(
|
402
|
-
|
403
|
-
|
515
|
+
:post,
|
516
|
+
'https://www.example.com/k/v1/path'
|
404
517
|
)
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
518
|
+
.with(headers: { 'X-Cybozu-API-Token' => 'token-api' })
|
519
|
+
.to_return(
|
520
|
+
body: '{"fileKey":"abc"}',
|
521
|
+
status: 200,
|
522
|
+
headers: { 'Content-type' => 'application/json' }
|
523
|
+
)
|
410
524
|
|
411
|
-
expect(Faraday::UploadIO).to receive(:new)
|
412
|
-
.with(path, content_type, original_filename,
|
413
|
-
'Content-Disposition' => 'form-data')
|
414
|
-
.and_return(attachment)
|
525
|
+
expect(Faraday::UploadIO).to receive(:new).with(path, content_type, original_filename).and_return(attachment) # rubocop:disable Metrics/LineLength
|
415
526
|
end
|
416
527
|
|
417
528
|
subject { target.post_file(url, path, content_type, original_filename) }
|
@@ -11,8 +11,11 @@ describe Kintone::Command::Apis do
|
|
11
11
|
:get,
|
12
12
|
'https://example.cybozu.com/k/v1/apis.json'
|
13
13
|
)
|
14
|
-
.to_return(
|
15
|
-
|
14
|
+
.to_return(
|
15
|
+
body: response_data.to_json,
|
16
|
+
status: 200,
|
17
|
+
headers: { 'Content-type' => 'application/json' }
|
18
|
+
)
|
16
19
|
end
|
17
20
|
|
18
21
|
subject { target.get }
|
@@ -29,6 +32,22 @@ describe Kintone::Command::Apis do
|
|
29
32
|
end
|
30
33
|
|
31
34
|
it { is_expected.to eq(response_data) }
|
35
|
+
|
36
|
+
context 'fail to request' do
|
37
|
+
before(:each) do
|
38
|
+
stub_request(
|
39
|
+
:get,
|
40
|
+
'https://example.cybozu.com/k/v1/apis.json'
|
41
|
+
)
|
42
|
+
.to_return(
|
43
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
44
|
+
status: 500,
|
45
|
+
headers: { 'Content-Type' => 'application/json' }
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
50
|
+
end
|
32
51
|
end
|
33
52
|
|
34
53
|
describe '#get_details_of' do
|
@@ -37,8 +56,11 @@ describe Kintone::Command::Apis do
|
|
37
56
|
:get,
|
38
57
|
'https://example.cybozu.com/k/v1/apis/records/get.json'
|
39
58
|
)
|
40
|
-
.to_return(
|
41
|
-
|
59
|
+
.to_return(
|
60
|
+
body: response_data.to_json,
|
61
|
+
status: 200,
|
62
|
+
headers: { 'Content-type' => 'application/json' }
|
63
|
+
)
|
42
64
|
end
|
43
65
|
|
44
66
|
subject { target.get_details_of(link) }
|
@@ -55,6 +77,22 @@ describe Kintone::Command::Apis do
|
|
55
77
|
end
|
56
78
|
|
57
79
|
it { is_expected.to eq(response_data) }
|
80
|
+
|
81
|
+
context 'fail to request' do
|
82
|
+
before(:each) do
|
83
|
+
stub_request(
|
84
|
+
:get,
|
85
|
+
'https://example.cybozu.com/k/v1/apis/records/get.json'
|
86
|
+
)
|
87
|
+
.to_return(
|
88
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
89
|
+
status: 500,
|
90
|
+
headers: { 'Content-Type' => 'application/json' }
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
95
|
+
end
|
58
96
|
end
|
59
97
|
|
60
98
|
describe '#get_details_of_key' do
|
@@ -63,15 +101,21 @@ describe Kintone::Command::Apis do
|
|
63
101
|
:get,
|
64
102
|
'https://example.cybozu.com/k/v1/apis.json'
|
65
103
|
)
|
66
|
-
.to_return(
|
67
|
-
|
104
|
+
.to_return(
|
105
|
+
body: apis_response_data.to_json,
|
106
|
+
status: 200,
|
107
|
+
headers: { 'Content-type' => 'application/json' }
|
108
|
+
)
|
68
109
|
|
69
110
|
stub_request(
|
70
111
|
:get,
|
71
112
|
'https://example.cybozu.com/k/v1/apis/records/get.json'
|
72
113
|
)
|
73
|
-
.to_return(
|
74
|
-
|
114
|
+
.to_return(
|
115
|
+
body: api_response_data.to_json,
|
116
|
+
status: 200,
|
117
|
+
headers: { 'Content-type' => 'application/json' }
|
118
|
+
)
|
75
119
|
end
|
76
120
|
|
77
121
|
subject { target.get_details_of_key(key) }
|
@@ -113,5 +157,23 @@ describe Kintone::Command::Apis do
|
|
113
157
|
|
114
158
|
it { expect { subject }.to raise_error NoMethodError }
|
115
159
|
end
|
160
|
+
|
161
|
+
context 'fail to request' do
|
162
|
+
before(:each) do
|
163
|
+
stub_request(
|
164
|
+
:get,
|
165
|
+
'https://example.cybozu.com/k/v1/apis/records/get.json'
|
166
|
+
)
|
167
|
+
.to_return(
|
168
|
+
body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
|
169
|
+
status: 500,
|
170
|
+
headers: { 'Content-Type' => 'application/json' }
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
let(:key) { 'records/get' }
|
175
|
+
|
176
|
+
it { expect { subject }.to raise_error Kintone::KintoneError }
|
177
|
+
end
|
116
178
|
end
|
117
179
|
end
|