mackerel-client 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/example/01_invitation.rb +12 -0
- data/example/02_dashboard.rb +29 -0
- data/example/03_host.rb +97 -0
- data/example/04_metrics.rb +44 -0
- data/example/05_service_role.rb +10 -0
- data/example/06_annotation.rb +26 -0
- data/example/07_monitoring.rb +100 -0
- data/example/08_alert.rb +10 -0
- data/example/Gemfile +6 -0
- data/lib/mackerel/alert.rb +48 -0
- data/lib/mackerel/annotation.rb +61 -0
- data/lib/mackerel/api_command.rb +67 -0
- data/lib/mackerel/channel.rb +32 -0
- data/lib/mackerel/client.rb +30 -154
- data/lib/mackerel/dashboard.rb +71 -0
- data/lib/mackerel/host.rb +62 -0
- data/lib/mackerel/invitation.rb +20 -0
- data/lib/mackerel/metadata.rb +15 -47
- data/lib/mackerel/metric.rb +50 -0
- data/lib/mackerel/monitor.rb +23 -53
- data/lib/mackerel/monitoring.rb +13 -0
- data/lib/mackerel/notification_group.rb +58 -0
- data/lib/mackerel/organization.rb +33 -0
- data/lib/mackerel/role.rb +24 -0
- data/lib/mackerel/service.rb +51 -0
- data/lib/mackerel/user.rb +42 -0
- data/lib/mackerel/version.rb +3 -0
- data/lib/mackerel.rb +2 -3
- data/spec/mackerel/alert_spec.rb +103 -0
- data/spec/mackerel/annotation_spec.rb +208 -0
- data/spec/mackerel/channel_spec.rb +50 -0
- data/spec/mackerel/client_spec.rb +69 -103
- data/spec/mackerel/dashboard_spec.rb +252 -0
- data/spec/mackerel/invitation_spec.rb +93 -0
- data/spec/mackerel/metric_spec.rb +287 -0
- data/spec/mackerel/monitor_spec.rb +4 -4
- data/spec/mackerel/monitoring_spec.rb +71 -0
- data/spec/mackerel/notification_group_spec.rb +274 -0
- data/spec/mackerel/organization_spec.rb +47 -0
- data/spec/mackerel/service_spec.rb +155 -0
- data/spec/mackerel/user_spec.rb +99 -0
- metadata +47 -2
@@ -54,6 +54,49 @@ describe Mackerel::Client do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
|
58
|
+
describe '#update_host' do
|
59
|
+
let(:stubbed_response) {
|
60
|
+
[
|
61
|
+
200,
|
62
|
+
{},
|
63
|
+
JSON.dump(response_object)
|
64
|
+
]
|
65
|
+
}
|
66
|
+
|
67
|
+
let(:test_client) {
|
68
|
+
Faraday.new do |builder|
|
69
|
+
builder.adapter :test do |stubs|
|
70
|
+
stubs.put(api_path) { stubbed_response }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
}
|
74
|
+
|
75
|
+
let(:hostId) { '21obeF4PhZN' }
|
76
|
+
|
77
|
+
let(:api_path) { "/api/v0/hosts/#{hostId}" }
|
78
|
+
|
79
|
+
let(:host) {
|
80
|
+
{
|
81
|
+
'name' => 'host001',
|
82
|
+
'meta' => {"abcd" => "abcdefghijklmnopqlstu"}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
let(:response_object) {
|
87
|
+
{ 'id' => hostId }
|
88
|
+
}
|
89
|
+
|
90
|
+
before do
|
91
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "successfully update host" do
|
95
|
+
expect(client.update_host(hostId, host)).to eq(response_object)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
57
100
|
describe '#get_host' do
|
58
101
|
let(:stubbed_response) {
|
59
102
|
[
|
@@ -143,7 +186,8 @@ describe Mackerel::Client do
|
|
143
186
|
end
|
144
187
|
end
|
145
188
|
|
146
|
-
|
189
|
+
|
190
|
+
describe '#update_host_roles' do
|
147
191
|
let(:stubbed_response) {
|
148
192
|
[
|
149
193
|
200,
|
@@ -155,110 +199,37 @@ describe Mackerel::Client do
|
|
155
199
|
let(:test_client) {
|
156
200
|
Faraday.new do |builder|
|
157
201
|
builder.adapter :test do |stubs|
|
158
|
-
stubs.
|
202
|
+
stubs.put(api_path) { stubbed_response }
|
159
203
|
end
|
160
204
|
end
|
161
205
|
}
|
162
206
|
|
163
207
|
let(:hostId) { '21obeF4PhZN' }
|
164
208
|
|
165
|
-
let(:api_path) { "/api/v0/hosts/#{hostId}/
|
209
|
+
let(:api_path) { "/api/v0/hosts/#{hostId}/role-fullnames" }
|
166
210
|
|
167
|
-
let(:
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
before do
|
172
|
-
allow(client).to receive(:http_client).and_return(test_client)
|
173
|
-
end
|
174
|
-
|
175
|
-
it "successfully retire a host" do
|
176
|
-
expect(client.retire_host(hostId)).to eq(response_object)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe '#post_metrics' do
|
181
|
-
let(:stubbed_response) {
|
182
|
-
[
|
183
|
-
200,
|
184
|
-
{},
|
185
|
-
JSON.dump(response_object)
|
186
|
-
]
|
187
|
-
}
|
188
|
-
|
189
|
-
let(:test_client) {
|
190
|
-
Faraday.new do |builder|
|
191
|
-
builder.adapter :test do |stubs|
|
192
|
-
stubs.post(api_path) { stubbed_response }
|
193
|
-
end
|
194
|
-
end
|
211
|
+
let(:roles) {
|
212
|
+
[
|
213
|
+
'Web', 'Linux', 'NetworkG1'
|
214
|
+
]
|
195
215
|
}
|
196
216
|
|
197
|
-
let(:hostId) { '21obeF4PhZN' }
|
198
|
-
|
199
|
-
let(:api_path) { "/api/v0/tsdb" }
|
200
|
-
|
201
217
|
let(:response_object) {
|
202
|
-
{ 'success' => true
|
218
|
+
{ 'success' => true}
|
203
219
|
}
|
204
220
|
|
205
|
-
let(:metrics) { [
|
206
|
-
{ 'hostId' => hostId, 'name' => 'custom.metrics.loadavg', 'time' => 1401537844, 'value' => 1.4 },
|
207
|
-
{ 'hostId' => hostId, 'name' => 'custom.metrics.uptime', 'time' => 1401537844, 'value' => 500 },
|
208
|
-
] }
|
209
|
-
|
210
221
|
before do
|
211
222
|
allow(client).to receive(:http_client).and_return(test_client)
|
212
223
|
end
|
213
224
|
|
214
|
-
it "successfully
|
215
|
-
expect(client.
|
225
|
+
it "successfully update host" do
|
226
|
+
expect(client.update_host_roles(hostId, roles)).to eq({'success' => true})
|
216
227
|
end
|
217
228
|
end
|
218
229
|
|
219
|
-
describe "#get_latest_metrics" do
|
220
|
-
let(:stubbed_response) {
|
221
|
-
[
|
222
|
-
200,
|
223
|
-
{},
|
224
|
-
JSON.dump(response_object)
|
225
|
-
]
|
226
|
-
}
|
227
|
-
|
228
|
-
let(:test_client) {
|
229
|
-
Faraday.new do |builder|
|
230
|
-
builder.adapter :test do |stubs|
|
231
|
-
stubs.get(api_path) { stubbed_response }
|
232
|
-
end
|
233
|
-
end
|
234
|
-
}
|
235
|
-
|
236
|
-
let(:hostId) { '21obeF4PhZN' }
|
237
230
|
|
238
|
-
let(:metric_name) { "loadavg5" }
|
239
231
|
|
240
|
-
|
241
|
-
|
242
|
-
let(:response_object) {
|
243
|
-
{
|
244
|
-
"tsdbLatest" => {
|
245
|
-
hostId => {
|
246
|
-
metric_name => {"time"=>1407898200, "value"=>0.03666666666666667},
|
247
|
-
}
|
248
|
-
}
|
249
|
-
}
|
250
|
-
}
|
251
|
-
|
252
|
-
before do
|
253
|
-
allow(client).to receive(:http_client).and_return(test_client)
|
254
|
-
end
|
255
|
-
|
256
|
-
it "successfully post metrics" do
|
257
|
-
expect(client.get_latest_metrics([hostId], [metric_name])).to eq(response_object["tsdbLatest"])
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe '#post_service_metrics' do
|
232
|
+
describe '#retire_host' do
|
262
233
|
let(:stubbed_response) {
|
263
234
|
[
|
264
235
|
200,
|
@@ -275,25 +246,20 @@ describe Mackerel::Client do
|
|
275
246
|
end
|
276
247
|
}
|
277
248
|
|
278
|
-
let(:
|
249
|
+
let(:hostId) { '21obeF4PhZN' }
|
279
250
|
|
280
|
-
let(:api_path) { "/api/v0/
|
251
|
+
let(:api_path) { "/api/v0/hosts/#{hostId}/retire" }
|
281
252
|
|
282
253
|
let(:response_object) {
|
283
254
|
{ 'success' => true }
|
284
255
|
}
|
285
256
|
|
286
|
-
let(:metrics) { [
|
287
|
-
{ 'name' => 'custom.metrics.latency', 'time' => 1401537844, 'value' => 0.5 },
|
288
|
-
{ 'name' => 'custom.metrics.uptime', 'time' => 1401537844, 'value' => 500 },
|
289
|
-
] }
|
290
|
-
|
291
257
|
before do
|
292
258
|
allow(client).to receive(:http_client).and_return(test_client)
|
293
259
|
end
|
294
260
|
|
295
|
-
it "successfully
|
296
|
-
expect(client.
|
261
|
+
it "successfully retire a host" do
|
262
|
+
expect(client.retire_host(hostId)).to eq(response_object)
|
297
263
|
end
|
298
264
|
end
|
299
265
|
|
@@ -435,7 +401,7 @@ describe Mackerel::Client do
|
|
435
401
|
let(:api_path) { '/api/v0/graph-annotations' }
|
436
402
|
|
437
403
|
let(:response_object) {
|
438
|
-
{
|
404
|
+
Mackerel::Annotation.new({
|
439
405
|
'id' => 'XXX',
|
440
406
|
'service' => 'myService',
|
441
407
|
'roles' => ['role1', 'role2'],
|
@@ -443,17 +409,17 @@ describe Mackerel::Client do
|
|
443
409
|
'to' => 123457,
|
444
410
|
'title' => 'Some event',
|
445
411
|
'description' => 'Something happend!'
|
446
|
-
}
|
412
|
+
})
|
447
413
|
}
|
448
414
|
|
449
415
|
let(:annotation) {
|
450
416
|
{
|
451
|
-
service
|
452
|
-
roles
|
453
|
-
from
|
454
|
-
to
|
455
|
-
title
|
456
|
-
description
|
417
|
+
'service' => 'myService',
|
418
|
+
'roles' => ['role1', 'role2'],
|
419
|
+
'from' => 123456,
|
420
|
+
'to' => 123457,
|
421
|
+
'title' => 'Some event',
|
422
|
+
'description' => 'Something happend!'
|
457
423
|
}
|
458
424
|
}
|
459
425
|
|
@@ -461,8 +427,8 @@ describe Mackerel::Client do
|
|
461
427
|
allow(client).to receive(:http_client).and_return(test_client)
|
462
428
|
end
|
463
429
|
|
464
|
-
it "successfully post annotations" do
|
465
|
-
expect(client.post_graph_annotation(annotation)).to eq(
|
430
|
+
it "successfully post graph annotations" do
|
431
|
+
expect(client.post_graph_annotation(annotation).to_h).to eq(annotation.merge({ "id" => "XXX" }))
|
466
432
|
end
|
467
433
|
end
|
468
434
|
|
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'mackerel'
|
2
|
+
require 'mackerel/host'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
describe Mackerel::Client do
|
6
|
+
let(:api_key) { 'xxxxxxxx' }
|
7
|
+
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
|
+
|
9
|
+
describe '#post_dashboard' do
|
10
|
+
let(:stubbed_response) {
|
11
|
+
[
|
12
|
+
200,
|
13
|
+
{},
|
14
|
+
JSON.dump(response_object)
|
15
|
+
]
|
16
|
+
}
|
17
|
+
|
18
|
+
let(:test_client) {
|
19
|
+
Faraday.new do |builder|
|
20
|
+
builder.adapter :test do |stubs|
|
21
|
+
stubs.post(api_path) { stubbed_response }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
let(:id) { 'abcxyz' }
|
27
|
+
let(:api_path) { '/api/v0/dashboards' }
|
28
|
+
let(:title) { 'HogeHoge' }
|
29
|
+
let(:bodyMarkdown) { '#HogeHoge' }
|
30
|
+
let(:urlPath) { 'Hoge' }
|
31
|
+
|
32
|
+
let(:dashboard) {
|
33
|
+
{
|
34
|
+
'title' => title,
|
35
|
+
'bodyMarkdown' => bodyMarkdown,
|
36
|
+
'urlPath' => urlPath,
|
37
|
+
'createdAt' => 1234567890,
|
38
|
+
'updatedAt' => 1234567891
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
let(:response_object) {
|
43
|
+
dashboard
|
44
|
+
}
|
45
|
+
|
46
|
+
before do
|
47
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "successfully post dashboard" do
|
51
|
+
expect(client.post_dashboard(title, bodyMarkdown, urlPath).to_h).to eq(response_object)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
describe '#update_dashboard' do
|
58
|
+
let(:stubbed_response) {
|
59
|
+
[
|
60
|
+
200,
|
61
|
+
{},
|
62
|
+
JSON.dump(response_object)
|
63
|
+
]
|
64
|
+
}
|
65
|
+
|
66
|
+
let(:test_client) {
|
67
|
+
Faraday.new do |builder|
|
68
|
+
builder.adapter :test do |stubs|
|
69
|
+
stubs.put(api_path) { stubbed_response }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
}
|
73
|
+
|
74
|
+
let(:id) { 'abcxyz' }
|
75
|
+
let(:api_path) { "/api/v0/dashboards/#{id}" }
|
76
|
+
let(:title) { 'HogeHoge' }
|
77
|
+
let(:bodyMarkdown) { '#HogeHoge' }
|
78
|
+
let(:urlPath) { 'Hoge' }
|
79
|
+
|
80
|
+
let(:dashboard) {
|
81
|
+
{
|
82
|
+
'id' => id,
|
83
|
+
'title' => title,
|
84
|
+
'bodyMarkdown' => bodyMarkdown,
|
85
|
+
'urlPath' => urlPath,
|
86
|
+
'createdAt' => 1234567890,
|
87
|
+
'updatedAt' => 1234567891
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
let(:response_object) {
|
92
|
+
dashboard
|
93
|
+
}
|
94
|
+
|
95
|
+
before do
|
96
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "successfully update dashboard" do
|
100
|
+
expect(client.update_dashboard(id, title, bodyMarkdown, urlPath).to_h).to eq(response_object)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
describe '#get_dashboards' do
|
107
|
+
let(:stubbed_response) {
|
108
|
+
[
|
109
|
+
200,
|
110
|
+
{},
|
111
|
+
JSON.dump(response_object)
|
112
|
+
]
|
113
|
+
}
|
114
|
+
|
115
|
+
let(:test_client) {
|
116
|
+
Faraday.new do |builder|
|
117
|
+
builder.adapter :test do |stubs|
|
118
|
+
stubs.get(api_path) { stubbed_response }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
}
|
122
|
+
|
123
|
+
let(:id) { 'abcxyz' }
|
124
|
+
let(:api_path) { "/api/v0/dashboards" }
|
125
|
+
let(:title) { 'HogeHoge' }
|
126
|
+
let(:bodyMarkdown) { '#HogeHoge' }
|
127
|
+
let(:urlPath) { 'Hoge' }
|
128
|
+
|
129
|
+
let(:dashboards) {
|
130
|
+
[
|
131
|
+
{
|
132
|
+
'id' => id,
|
133
|
+
'title' => title,
|
134
|
+
'bodyMarkdown' => bodyMarkdown,
|
135
|
+
'urlPath' => urlPath,
|
136
|
+
'createdAt' => 1234567890,
|
137
|
+
'updatedAt' => 1234567891
|
138
|
+
}
|
139
|
+
]
|
140
|
+
}
|
141
|
+
|
142
|
+
let(:response_object) {
|
143
|
+
{ 'dashboards' => dashboards }
|
144
|
+
}
|
145
|
+
|
146
|
+
before do
|
147
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "successfully get dashboards" do
|
151
|
+
expect(client.get_dashboards().map(&:to_h)).to eq(response_object['dashboards'])
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
describe '#get_dashboard' do
|
157
|
+
let(:stubbed_response) {
|
158
|
+
[
|
159
|
+
200,
|
160
|
+
{},
|
161
|
+
JSON.dump(response_object)
|
162
|
+
]
|
163
|
+
}
|
164
|
+
|
165
|
+
let(:test_client) {
|
166
|
+
Faraday.new do |builder|
|
167
|
+
builder.adapter :test do |stubs|
|
168
|
+
stubs.get(api_path) { stubbed_response }
|
169
|
+
end
|
170
|
+
end
|
171
|
+
}
|
172
|
+
|
173
|
+
let(:id) { 'abcxyz' }
|
174
|
+
let(:api_path) { "/api/v0/dashboards/#{id}" }
|
175
|
+
let(:title) { 'HogeHoge' }
|
176
|
+
let(:bodyMarkdown) { '#HogeHoge' }
|
177
|
+
let(:urlPath) { 'Hoge' }
|
178
|
+
|
179
|
+
let(:dashboard) {
|
180
|
+
{
|
181
|
+
'id' => id,
|
182
|
+
'title' => title,
|
183
|
+
'bodyMarkdown' => bodyMarkdown,
|
184
|
+
'urlPath' => urlPath,
|
185
|
+
'createdAt' => 1234567890,
|
186
|
+
'updatedAt' => 1234567891
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
let(:response_object) {
|
191
|
+
dashboard
|
192
|
+
}
|
193
|
+
|
194
|
+
before do
|
195
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "successfully get dashboard" do
|
199
|
+
expect(client.get_dashboard(id).to_h).to eq(response_object)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
describe '#delete_dashboard' do
|
205
|
+
let(:stubbed_response) {
|
206
|
+
[
|
207
|
+
200,
|
208
|
+
{},
|
209
|
+
JSON.dump(response_object)
|
210
|
+
]
|
211
|
+
}
|
212
|
+
|
213
|
+
let(:test_client) {
|
214
|
+
Faraday.new do |builder|
|
215
|
+
builder.adapter :test do |stubs|
|
216
|
+
stubs.delete(api_path) { stubbed_response }
|
217
|
+
end
|
218
|
+
end
|
219
|
+
}
|
220
|
+
|
221
|
+
let(:id) { 'abcxyz' }
|
222
|
+
let(:api_path) { "/api/v0/dashboards/#{id}" }
|
223
|
+
let(:title) { 'HogeHoge' }
|
224
|
+
let(:bodyMarkdown) { '#HogeHoge' }
|
225
|
+
let(:urlPath) { 'Hoge' }
|
226
|
+
|
227
|
+
let(:dashboard) {
|
228
|
+
{
|
229
|
+
'id' => id,
|
230
|
+
'title' => title,
|
231
|
+
'bodyMarkdown' => bodyMarkdown,
|
232
|
+
'urlPath' => urlPath,
|
233
|
+
'createdAt' => 1234567890,
|
234
|
+
'updatedAt' => 1234567891
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
let(:response_object) {
|
239
|
+
dashboard
|
240
|
+
}
|
241
|
+
|
242
|
+
before do
|
243
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "successfully delete dashboard" do
|
247
|
+
expect(client.delete_dashboard(id).to_h).to eq(response_object)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'mackerel'
|
2
|
+
require 'mackerel/host'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
describe Mackerel::Client do
|
6
|
+
let(:api_key) { 'xxxxxxxx' }
|
7
|
+
let(:client) { Mackerel::Client.new(:mackerel_api_key => api_key) }
|
8
|
+
|
9
|
+
describe '#post_invitation' do
|
10
|
+
|
11
|
+
let(:api_path) { "/api/v0/invitations" }
|
12
|
+
let(:stubbed_response) {
|
13
|
+
[
|
14
|
+
200,
|
15
|
+
{},
|
16
|
+
JSON.dump(response_object)
|
17
|
+
]
|
18
|
+
}
|
19
|
+
|
20
|
+
let(:test_client) {
|
21
|
+
Faraday.new do |builder|
|
22
|
+
builder.adapter :test do |stubs|
|
23
|
+
stubs.post(api_path) { stubbed_response }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
}
|
27
|
+
|
28
|
+
let(:email) { "example@example.com" }
|
29
|
+
let(:authority) { "viewer" }
|
30
|
+
let(:invitation) {
|
31
|
+
{
|
32
|
+
"email" => email,
|
33
|
+
"authority" => authority
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
let(:response_object) {
|
38
|
+
invitation
|
39
|
+
}
|
40
|
+
|
41
|
+
before do
|
42
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "successfully post invitation" do
|
46
|
+
expect(client.post_invitation(email, authority)).to eq(response_object)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
describe '#revoke_invitation' do
|
53
|
+
let(:stubbed_response) {
|
54
|
+
[
|
55
|
+
200,
|
56
|
+
{},
|
57
|
+
JSON.dump(response_object)
|
58
|
+
]
|
59
|
+
}
|
60
|
+
|
61
|
+
let(:test_client) {
|
62
|
+
Faraday.new do |builder|
|
63
|
+
builder.adapter :test do |stubs|
|
64
|
+
stubs.post(api_path) { stubbed_response }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
69
|
+
let(:id) { 'abcxyz' }
|
70
|
+
let(:email) { "example@example.com" }
|
71
|
+
let(:api_path) { "/api/v0/invitations/revoke" }
|
72
|
+
|
73
|
+
let(:invitation) {
|
74
|
+
{
|
75
|
+
"email" => email,
|
76
|
+
"authority" => "viewer",
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
let(:response_object) {
|
81
|
+
invitation.merge({ "expiresAt" => 1492393387 })
|
82
|
+
}
|
83
|
+
|
84
|
+
before do
|
85
|
+
allow(client).to receive(:http_client).and_return(test_client)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "successfully revoke invitation" do
|
89
|
+
expect(client.revoke_invitation(email)).to eq(invitation.merge({ "expiresAt" => 1492393387 }))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|