flapjack-diner 1.4.0 → 2.0.0.a4
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/.gitignore +1 -0
- data/.rspec +1 -1
- data/README.md +620 -413
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner/argument_validator.rb +77 -7
- data/lib/flapjack-diner/configuration.rb +409 -0
- data/lib/flapjack-diner/index_range.rb +42 -0
- data/lib/flapjack-diner/log_formatter.rb +22 -0
- data/lib/flapjack-diner/query.rb +114 -0
- data/lib/flapjack-diner/relationships.rb +180 -0
- data/lib/flapjack-diner/request.rb +280 -0
- data/lib/flapjack-diner/resources.rb +64 -0
- data/lib/flapjack-diner/response.rb +91 -0
- data/lib/flapjack-diner/tools.rb +47 -251
- data/lib/flapjack-diner/utility.rb +16 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/lib/flapjack-diner.rb +54 -20
- data/spec/argument_validator_spec.rb +87 -28
- data/spec/flapjack-diner_spec.rb +42 -64
- data/spec/relationships_spec.rb +211 -0
- data/spec/resources/checks_spec.rb +219 -79
- data/spec/resources/contacts_spec.rb +179 -151
- data/spec/resources/events_spec.rb +208 -0
- data/spec/resources/maintenance_periods_spec.rb +177 -565
- data/spec/resources/media_spec.rb +157 -171
- data/spec/resources/metrics_spec.rb +45 -0
- data/spec/resources/rules_spec.rb +278 -0
- data/spec/resources/states_spec.rb +93 -0
- data/spec/resources/statistics_spec.rb +53 -0
- data/spec/resources/tags_spec.rb +243 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/fixture_data.rb +541 -0
- metadata +33 -31
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -135
- data/lib/flapjack-diner/resources/checks.rb +0 -64
- data/lib/flapjack-diner/resources/contacts.rb +0 -70
- data/lib/flapjack-diner/resources/entities.rb +0 -68
- data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -82
- data/lib/flapjack-diner/resources/media.rb +0 -61
- data/lib/flapjack-diner/resources/notification_rules.rb +0 -66
- data/lib/flapjack-diner/resources/notifications.rb +0 -28
- data/lib/flapjack-diner/resources/pagerduty_credentials.rb +0 -59
- data/lib/flapjack-diner/resources/reports.rb +0 -33
- data/spec/pacts/flapjack-diner-flapjack.json +0 -4515
- data/spec/resources/entities_spec.rb +0 -181
- data/spec/resources/notification_rules_spec.rb +0 -341
- data/spec/resources/notifications_spec.rb +0 -208
- data/spec/resources/pagerduty_credentials_spec.rb +0 -237
- data/spec/resources/reports_spec.rb +0 -255
@@ -1,181 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack-diner'
|
3
|
-
|
4
|
-
describe Flapjack::Diner, :pact => true do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
Flapjack::Diner.base_uri('localhost:19081')
|
8
|
-
Flapjack::Diner.logger = nil
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'create' do
|
12
|
-
|
13
|
-
it "submits a POST request for an entity" do
|
14
|
-
entity_data = [{
|
15
|
-
:name => 'example.org',
|
16
|
-
:id => '57_example'
|
17
|
-
}]
|
18
|
-
|
19
|
-
flapjack.given("no entity exists").
|
20
|
-
upon_receiving("a POST request with one entity").
|
21
|
-
with(:method => :post, :path => '/entities',
|
22
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
23
|
-
:body => {:entities => entity_data}).
|
24
|
-
will_respond_with(
|
25
|
-
:status => 201,
|
26
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
27
|
-
:body => ['57_example'] )
|
28
|
-
|
29
|
-
result = Flapjack::Diner.create_entities(entity_data)
|
30
|
-
expect(result).not_to be_nil
|
31
|
-
expect(result).to eq(['57_example'])
|
32
|
-
end
|
33
|
-
|
34
|
-
it "submits a POST request for several entities" do
|
35
|
-
entity_data = [{
|
36
|
-
:name => 'example.org',
|
37
|
-
:id => '57_example'
|
38
|
-
}, {
|
39
|
-
:name => 'example2.org',
|
40
|
-
:id => '58'
|
41
|
-
}]
|
42
|
-
|
43
|
-
flapjack.given("no entity exists").
|
44
|
-
upon_receiving("a POST request with two entities").
|
45
|
-
with(:method => :post, :path => '/entities',
|
46
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
47
|
-
:body => {:entities => entity_data}).
|
48
|
-
will_respond_with(
|
49
|
-
:status => 201,
|
50
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
51
|
-
:body => ['57_example', '58'] )
|
52
|
-
|
53
|
-
result = Flapjack::Diner.create_entities(entity_data)
|
54
|
-
expect(result).not_to be_nil
|
55
|
-
expect(result).to eq(['57_example', '58'])
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'read' do
|
61
|
-
|
62
|
-
context 'GET all entities' do
|
63
|
-
|
64
|
-
it 'has some data' do
|
65
|
-
entity_data = {
|
66
|
-
:name => 'www.example.com',
|
67
|
-
:id => '1234'
|
68
|
-
}
|
69
|
-
|
70
|
-
flapjack.given("an entity 'www.example.com' with id '1234' exists").
|
71
|
-
upon_receiving("a GET request for all entities").
|
72
|
-
with(:method => :get, :path => '/entities').
|
73
|
-
will_respond_with(
|
74
|
-
:status => 200,
|
75
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
76
|
-
:body => {:entities => [entity_data]} )
|
77
|
-
|
78
|
-
result = Flapjack::Diner.entities
|
79
|
-
expect(result).not_to be_nil
|
80
|
-
expect(result).to eq([entity_data])
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'has no data' do
|
84
|
-
flapjack.given("no entity exists").
|
85
|
-
upon_receiving("a GET request for all entities").
|
86
|
-
with(:method => :get, :path => '/entities').
|
87
|
-
will_respond_with(
|
88
|
-
:status => 200,
|
89
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
90
|
-
:body => {:entities => []} )
|
91
|
-
|
92
|
-
result = Flapjack::Diner.entities
|
93
|
-
expect(result).not_to be_nil
|
94
|
-
expect(result).to eq([])
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'GET a single entity' do
|
100
|
-
|
101
|
-
it 'finds the entity' do
|
102
|
-
entity_data = {
|
103
|
-
:name => 'www.example.com',
|
104
|
-
:id => '1234'
|
105
|
-
}
|
106
|
-
|
107
|
-
flapjack.given("an entity 'www.example.com' with id '1234' exists").
|
108
|
-
upon_receiving("a GET request for a single entity").
|
109
|
-
with(:method => :get, :path => '/entities/1234').
|
110
|
-
will_respond_with(
|
111
|
-
:status => 200,
|
112
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
113
|
-
:body => {:entities => [entity_data]} )
|
114
|
-
|
115
|
-
result = Flapjack::Diner.entities('1234')
|
116
|
-
expect(result).not_to be_nil
|
117
|
-
expect(result).to eq([entity_data])
|
118
|
-
end
|
119
|
-
|
120
|
-
it "can't find the entity" do
|
121
|
-
entity_data = {
|
122
|
-
:name => 'www.example.com',
|
123
|
-
:id => '1234'
|
124
|
-
}
|
125
|
-
|
126
|
-
flapjack.given("no entity exists").
|
127
|
-
upon_receiving("a GET request for a single entity").
|
128
|
-
with(:method => :get, :path => '/entities/1234').
|
129
|
-
will_respond_with(
|
130
|
-
:status => 404,
|
131
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
132
|
-
:body => {:errors => ["could not find entities: '1234'"]} )
|
133
|
-
|
134
|
-
result = Flapjack::Diner.entities('1234')
|
135
|
-
expect(result).to be_nil
|
136
|
-
expect(Flapjack::Diner.last_error).to eq(:status_code => 404,
|
137
|
-
:errors => ["could not find entities: '1234'"])
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
context 'update' do
|
145
|
-
|
146
|
-
it "submits a PATCH request for an entity" do
|
147
|
-
flapjack.given("an entity 'www.example.com' with id '1234' exists").
|
148
|
-
upon_receiving("a PATCH request for a single entity").
|
149
|
-
with(:method => :patch,
|
150
|
-
:path => '/entities/1234',
|
151
|
-
:body => [{:op => 'replace', :path => '/entities/0/name', :value => 'example3.com'}],
|
152
|
-
:headers => {'Content-Type'=>'application/json-patch+json'}).
|
153
|
-
will_respond_with(
|
154
|
-
:status => 204,
|
155
|
-
:body => '')
|
156
|
-
|
157
|
-
result = Flapjack::Diner.update_entities('1234', :name => 'example3.com')
|
158
|
-
expect(result).not_to be_nil
|
159
|
-
expect(result).to be_truthy
|
160
|
-
end
|
161
|
-
|
162
|
-
it "can't find the entity to update" do
|
163
|
-
flapjack.given("no entity exists").
|
164
|
-
upon_receiving("a PATCH request for a single entity").
|
165
|
-
with(:method => :patch,
|
166
|
-
:path => '/entities/1234',
|
167
|
-
:body => [{:op => 'replace', :path => '/entities/0/name', :value => 'example3.com'}],
|
168
|
-
:headers => {'Content-Type'=>'application/json-patch+json'}).
|
169
|
-
will_respond_with(
|
170
|
-
:status => 404,
|
171
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
172
|
-
:body => {:errors => ["could not find entity '1234'"]} )
|
173
|
-
|
174
|
-
result = Flapjack::Diner.update_entities('1234', :name => 'example3.com')
|
175
|
-
expect(Flapjack::Diner.last_error).to eq(:status_code => 404,
|
176
|
-
:errors => ["could not find entity '1234'"])
|
177
|
-
end
|
178
|
-
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
@@ -1,341 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'flapjack-diner'
|
3
|
-
|
4
|
-
describe Flapjack::Diner::Resources::NotificationRules, :pact => true do
|
5
|
-
|
6
|
-
let(:rule_id_regexp) {
|
7
|
-
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
8
|
-
}
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
Flapjack::Diner.base_uri('localhost:19081')
|
12
|
-
Flapjack::Diner.logger = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'create' do
|
16
|
-
|
17
|
-
it "submits a POST request for a notification rule" do
|
18
|
-
data = [{
|
19
|
-
:entity_tags => ["database","physical"],
|
20
|
-
:entities => ["foo-app-01.example.com"],
|
21
|
-
:time_restrictions => nil,
|
22
|
-
:warning_media => ["email"],
|
23
|
-
:critical_media => ["sms", "email"],
|
24
|
-
:warning_blackhole => false,
|
25
|
-
:critical_blackhole => false
|
26
|
-
}]
|
27
|
-
|
28
|
-
flapjack.given("a contact with id 'abc' exists").
|
29
|
-
upon_receiving("a POST request with one notification rule").
|
30
|
-
with(:method => :post, :path => '/contacts/abc/notification_rules',
|
31
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
32
|
-
:body => {:notification_rules => data}).
|
33
|
-
will_respond_with(
|
34
|
-
:status => 201,
|
35
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
36
|
-
:body => [ Pact::Term.new(
|
37
|
-
:generate => '05983623-fcef-42da-af44-ed6990b500fa',
|
38
|
-
:matcher => rule_id_regexp
|
39
|
-
) ]
|
40
|
-
)
|
41
|
-
|
42
|
-
result = Flapjack::Diner.create_contact_notification_rules('abc', data)
|
43
|
-
expect(result).not_to be_nil
|
44
|
-
expect(result).to eq(['05983623-fcef-42da-af44-ed6990b500fa'])
|
45
|
-
end
|
46
|
-
|
47
|
-
it "submits a POST request for several notification rules" do
|
48
|
-
data = [{
|
49
|
-
:entity_tags => ["database","physical"],
|
50
|
-
:entities => ["foo-app-01.example.com"],
|
51
|
-
:time_restrictions => nil,
|
52
|
-
:warning_media => ["email"],
|
53
|
-
:critical_media => ["sms", "email"],
|
54
|
-
:warning_blackhole => false,
|
55
|
-
:critical_blackhole => false
|
56
|
-
}, {
|
57
|
-
:entity_tags => nil,
|
58
|
-
:entities => ["foo-app-02.example.com"],
|
59
|
-
:time_restrictions => nil,
|
60
|
-
:warning_media => ["email"],
|
61
|
-
:critical_media => ["sms", "email"],
|
62
|
-
:warning_blackhole => true,
|
63
|
-
:critical_blackhole => false
|
64
|
-
}]
|
65
|
-
|
66
|
-
flapjack.given("a contact with id 'abc' exists").
|
67
|
-
upon_receiving("a POST request with two notification rules").
|
68
|
-
with(:method => :post, :path => '/contacts/abc/notification_rules',
|
69
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
70
|
-
:body => {:notification_rules => data}).
|
71
|
-
will_respond_with(
|
72
|
-
:status => 201,
|
73
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
74
|
-
:body => [ Pact::Term.new(
|
75
|
-
:generate => '05983623-fcef-42da-af44-ed6990b500fa',
|
76
|
-
:matcher => rule_id_regexp
|
77
|
-
), Pact::Term.new(
|
78
|
-
:generate => '20f182fc-6e32-4794-9007-97366d162c51',
|
79
|
-
:matcher => rule_id_regexp
|
80
|
-
) ]
|
81
|
-
)
|
82
|
-
|
83
|
-
result = Flapjack::Diner.create_contact_notification_rules('abc', data)
|
84
|
-
expect(result).not_to be_nil
|
85
|
-
expect(result).to eq(['05983623-fcef-42da-af44-ed6990b500fa',
|
86
|
-
'20f182fc-6e32-4794-9007-97366d162c51'])
|
87
|
-
end
|
88
|
-
|
89
|
-
it "can't find the contact to add a notification rule to" do
|
90
|
-
data = [{
|
91
|
-
:entity_tags => ["database","physical"],
|
92
|
-
:entities => ["foo-app-01.example.com"],
|
93
|
-
:time_restrictions => nil,
|
94
|
-
:warning_media => ["email"],
|
95
|
-
:critical_media => ["sms", "email"],
|
96
|
-
:warning_blackhole => false,
|
97
|
-
:critical_blackhole => false
|
98
|
-
}]
|
99
|
-
|
100
|
-
flapjack.given("no contact exists").
|
101
|
-
upon_receiving("a POST request with one notification rule").
|
102
|
-
with(:method => :post, :path => '/contacts/abc/notification_rules',
|
103
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
104
|
-
:body => {:notification_rules => data}).
|
105
|
-
will_respond_with(
|
106
|
-
:status => 404,
|
107
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
108
|
-
:body => {:errors => ["could not find contact 'abc'"]}
|
109
|
-
)
|
110
|
-
|
111
|
-
result = Flapjack::Diner.create_contact_notification_rules('abc', data)
|
112
|
-
expect(result).to be_nil
|
113
|
-
expect(Flapjack::Diner.last_error).to eq(:status_code => 404,
|
114
|
-
:errors => ["could not find contact 'abc'"])
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'read' do
|
120
|
-
it "submits a GET request for all notification rules" do
|
121
|
-
data = {
|
122
|
-
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
123
|
-
:tags => [],
|
124
|
-
:regex_tags => [],
|
125
|
-
:entities => [],
|
126
|
-
:regex_entities => [],
|
127
|
-
:time_restrictions => [],
|
128
|
-
:warning_media => ["email"],
|
129
|
-
:critical_media => ["sms", "email"],
|
130
|
-
:warning_blackhole => false,
|
131
|
-
:critical_blackhole => false
|
132
|
-
}
|
133
|
-
|
134
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' exists").
|
135
|
-
upon_receiving("a GET request for all notification rules").
|
136
|
-
with(:method => :get, :path => '/notification_rules').
|
137
|
-
will_respond_with(
|
138
|
-
:status => 200,
|
139
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
140
|
-
:body => {:notification_rules => [data]} )
|
141
|
-
|
142
|
-
result = Flapjack::Diner.notification_rules
|
143
|
-
expect(result).not_to be_nil
|
144
|
-
expect(result).to eq([data])
|
145
|
-
end
|
146
|
-
|
147
|
-
it "submits a GET request for one notification rule" do
|
148
|
-
data = {
|
149
|
-
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
150
|
-
:tags => [],
|
151
|
-
:regex_tags => [],
|
152
|
-
:entities => [],
|
153
|
-
:regex_entities => [],
|
154
|
-
:time_restrictions => [],
|
155
|
-
:warning_media => ["email"],
|
156
|
-
:critical_media => ["sms", "email"],
|
157
|
-
:warning_blackhole => false,
|
158
|
-
:critical_blackhole => false
|
159
|
-
}
|
160
|
-
|
161
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' exists").
|
162
|
-
upon_receiving("a GET request for a single notification rule").
|
163
|
-
with(:method => :get, :path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa').
|
164
|
-
will_respond_with(
|
165
|
-
:status => 200,
|
166
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
167
|
-
:body => {:notification_rules => [data]} )
|
168
|
-
|
169
|
-
result = Flapjack::Diner.notification_rules('05983623-fcef-42da-af44-ed6990b500fa')
|
170
|
-
expect(result).not_to be_nil
|
171
|
-
expect(result).to eq([data])
|
172
|
-
end
|
173
|
-
|
174
|
-
it "submits a GET request for several notification rules" do
|
175
|
-
data = {
|
176
|
-
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
177
|
-
:tags => [],
|
178
|
-
:regex_tags => [],
|
179
|
-
:entities => [],
|
180
|
-
:regex_entities => [],
|
181
|
-
:time_restrictions => [],
|
182
|
-
:warning_media => ["email"],
|
183
|
-
:critical_media => ["sms", "email"],
|
184
|
-
:warning_blackhole => false,
|
185
|
-
:critical_blackhole => false
|
186
|
-
}
|
187
|
-
|
188
|
-
data_2 = {
|
189
|
-
:id => '20f182fc-6e32-4794-9007-97366d162c51',
|
190
|
-
:tags => ['physical'],
|
191
|
-
:regex_tags => [],
|
192
|
-
:entities => ['example.com'],
|
193
|
-
:regex_entities => [],
|
194
|
-
:time_restrictions => [],
|
195
|
-
:warning_media => ["email"],
|
196
|
-
:critical_media => ["sms", "email"],
|
197
|
-
:warning_blackhole => true,
|
198
|
-
:critical_blackhole => true
|
199
|
-
}
|
200
|
-
|
201
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' and notification rule '20f182fc-6e32-4794-9007-97366d162c51' exists").
|
202
|
-
upon_receiving("a GET request for two notification rules").
|
203
|
-
with(:method => :get, :path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa,20f182fc-6e32-4794-9007-97366d162c51').
|
204
|
-
will_respond_with(
|
205
|
-
:status => 200,
|
206
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
207
|
-
:body => {:notification_rules => [data, data_2]} )
|
208
|
-
|
209
|
-
result = Flapjack::Diner.notification_rules('05983623-fcef-42da-af44-ed6990b500fa',
|
210
|
-
'20f182fc-6e32-4794-9007-97366d162c51')
|
211
|
-
expect(result).not_to be_nil
|
212
|
-
expect(result).to eq([data, data_2])
|
213
|
-
end
|
214
|
-
|
215
|
-
it "can't find the notification rule to read" do
|
216
|
-
flapjack.given("no notification rule exists").
|
217
|
-
upon_receiving("a GET request for a single notification rule").
|
218
|
-
with(:method => :get, :path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa').
|
219
|
-
will_respond_with(
|
220
|
-
:status => 404,
|
221
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
222
|
-
:body => {:errors => ["could not find notification rules '05983623-fcef-42da-af44-ed6990b500fa'"]}
|
223
|
-
)
|
224
|
-
|
225
|
-
result = Flapjack::Diner.notification_rules('05983623-fcef-42da-af44-ed6990b500fa')
|
226
|
-
expect(result).to be_nil
|
227
|
-
expect(Flapjack::Diner.last_error).to eq(:status_code => 404,
|
228
|
-
:errors => ["could not find notification rules '05983623-fcef-42da-af44-ed6990b500fa'"])
|
229
|
-
end
|
230
|
-
|
231
|
-
end
|
232
|
-
|
233
|
-
context 'update' do
|
234
|
-
|
235
|
-
it "submits a PATCH request for one notification rule" do
|
236
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' exists").
|
237
|
-
upon_receiving("a PATCH request to change properties for a single notification rule").
|
238
|
-
with(:method => :patch,
|
239
|
-
:path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa',
|
240
|
-
:body => [{:op => 'replace', :path => '/notification_rules/0/warning_blackhole', :value => false}],
|
241
|
-
:headers => {'Content-Type'=>'application/json-patch+json'}).
|
242
|
-
will_respond_with(
|
243
|
-
:status => 204,
|
244
|
-
:body => '')
|
245
|
-
|
246
|
-
result = Flapjack::Diner.update_notification_rules('05983623-fcef-42da-af44-ed6990b500fa',
|
247
|
-
:warning_blackhole => false)
|
248
|
-
expect(result).not_to be_nil
|
249
|
-
expect(result).to be_truthy
|
250
|
-
end
|
251
|
-
|
252
|
-
it "submits a PATCH request for several notification rules" do
|
253
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' and notification rule '20f182fc-6e32-4794-9007-97366d162c51' exists").
|
254
|
-
upon_receiving("a PATCH request to change properties for two notification rules").
|
255
|
-
with(:method => :patch,
|
256
|
-
:path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa,20f182fc-6e32-4794-9007-97366d162c51',
|
257
|
-
:body => [{:op => 'replace', :path => '/notification_rules/0/warning_blackhole', :value => false}],
|
258
|
-
:headers => {'Content-Type'=>'application/json-patch+json'}).
|
259
|
-
will_respond_with(
|
260
|
-
:status => 204,
|
261
|
-
:body => '')
|
262
|
-
|
263
|
-
result = Flapjack::Diner.update_notification_rules('05983623-fcef-42da-af44-ed6990b500fa',
|
264
|
-
'20f182fc-6e32-4794-9007-97366d162c51', :warning_blackhole => false)
|
265
|
-
expect(result).not_to be_nil
|
266
|
-
expect(result).to be_truthy
|
267
|
-
end
|
268
|
-
|
269
|
-
it "can't find the notification rule to update" do
|
270
|
-
flapjack.given("no notification rule exists").
|
271
|
-
upon_receiving("a PATCH request to change properties for a single notification rule").
|
272
|
-
with(:method => :patch,
|
273
|
-
:path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa',
|
274
|
-
:body => [{:op => 'replace', :path => '/notification_rules/0/warning_blackhole', :value => false}],
|
275
|
-
:headers => {'Content-Type'=>'application/json-patch+json'}).
|
276
|
-
will_respond_with(
|
277
|
-
:status => 404,
|
278
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
279
|
-
:body => {:errors => ["could not find notification rule '05983623-fcef-42da-af44-ed6990b500fa'"]}
|
280
|
-
)
|
281
|
-
|
282
|
-
result = Flapjack::Diner.update_notification_rules('05983623-fcef-42da-af44-ed6990b500fa',
|
283
|
-
:warning_blackhole => false)
|
284
|
-
expect(result).to be_nil
|
285
|
-
expect(Flapjack::Diner.last_error).to eq(:status_code => 404,
|
286
|
-
:errors => ["could not find notification rule '05983623-fcef-42da-af44-ed6990b500fa'"])
|
287
|
-
end
|
288
|
-
|
289
|
-
end
|
290
|
-
|
291
|
-
context 'delete' do
|
292
|
-
it "submits a DELETE request for a notification rule" do
|
293
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' exists").
|
294
|
-
upon_receiving("a DELETE request for a single notification rule").
|
295
|
-
with(:method => :delete,
|
296
|
-
:path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa',
|
297
|
-
:body => nil).
|
298
|
-
will_respond_with(:status => 204,
|
299
|
-
:body => '')
|
300
|
-
|
301
|
-
result = Flapjack::Diner.delete_notification_rules('05983623-fcef-42da-af44-ed6990b500fa')
|
302
|
-
expect(result).not_to be_nil
|
303
|
-
expect(result).to be_truthy
|
304
|
-
end
|
305
|
-
|
306
|
-
it "submits a DELETE request for several notification rules" do
|
307
|
-
flapjack.given("a contact 'abc' with generic notification rule '05983623-fcef-42da-af44-ed6990b500fa' and notification rule '20f182fc-6e32-4794-9007-97366d162c51' exists").
|
308
|
-
upon_receiving("a DELETE request for two notification rules").
|
309
|
-
with(:method => :delete,
|
310
|
-
:path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa,20f182fc-6e32-4794-9007-97366d162c51',
|
311
|
-
:body => nil).
|
312
|
-
will_respond_with(:status => 204,
|
313
|
-
:body => '')
|
314
|
-
|
315
|
-
result = Flapjack::Diner.delete_notification_rules('05983623-fcef-42da-af44-ed6990b500fa',
|
316
|
-
'20f182fc-6e32-4794-9007-97366d162c51')
|
317
|
-
expect(result).not_to be_nil
|
318
|
-
expect(result).to be_truthy
|
319
|
-
end
|
320
|
-
|
321
|
-
it "can't find the notification rule to delete" do
|
322
|
-
flapjack.given("no notification rule exists").
|
323
|
-
upon_receiving("a DELETE request for a single notification rule").
|
324
|
-
with(:method => :delete,
|
325
|
-
:path => '/notification_rules/05983623-fcef-42da-af44-ed6990b500fa',
|
326
|
-
:body => nil).
|
327
|
-
will_respond_with(
|
328
|
-
:status => 404,
|
329
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
330
|
-
:body => {:errors => ["could not find notification rule '05983623-fcef-42da-af44-ed6990b500fa'"]}
|
331
|
-
)
|
332
|
-
|
333
|
-
result = Flapjack::Diner.delete_notification_rules('05983623-fcef-42da-af44-ed6990b500fa')
|
334
|
-
expect(result).to be_nil
|
335
|
-
expect(Flapjack::Diner.last_error).to eq(:status_code => 404,
|
336
|
-
:errors => ["could not find notification rule '05983623-fcef-42da-af44-ed6990b500fa'"])
|
337
|
-
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
end
|