@@ -29,7 +29,7 @@ module Agents |
||
29 | 29 |
Events look like this: |
30 | 30 |
{ |
31 | 31 |
"status": 200, |
32 |
- "response_headers": { |
|
32 |
+ "headers": { |
|
33 | 33 |
"Content-Type": "text/html", |
34 | 34 |
... |
35 | 35 |
}, |
@@ -47,7 +47,8 @@ module Agents |
||
47 | 47 |
'key' => 'value', |
48 | 48 |
'something' => 'the event contained {{ somekey }}' |
49 | 49 |
}, |
50 |
- 'headers' => {} |
|
50 |
+ 'headers' => {}, |
|
51 |
+ 'emit_events' => 'false' |
|
51 | 52 |
} |
52 | 53 |
end |
53 | 54 |
|
@@ -68,7 +69,7 @@ module Agents |
||
68 | 69 |
errors.add(:base, "if provided, payload must be a hash") |
69 | 70 |
end |
70 | 71 |
|
71 |
- if options['emit_events'].present? && ![true, false, 'true', 'false'].include?(options['emit_events']) |
|
72 |
+ if options.has_key?('emit_events') && boolify(options['emit_events']).nil? |
|
72 | 73 |
errors.add(:base, "if provided, emit_events must be true or false") |
73 | 74 |
end |
74 | 75 |
|
@@ -133,7 +134,7 @@ module Agents |
||
133 | 134 |
} |
134 | 135 |
|
135 | 136 |
if boolify(interpolated['emit_events']) |
136 |
- create_event payload: { body: response.body, response_headers: response.headers, status: response.status } |
|
137 |
+ create_event payload: { body: response.body, headers: response.headers, status: response.status } |
|
137 | 138 |
end |
138 | 139 |
end |
139 | 140 |
end |
@@ -216,7 +216,7 @@ describe Agents::PostAgent do |
||
216 | 216 |
|
217 | 217 |
it "emits the response headers" do |
218 | 218 |
@checker.check |
219 |
- expect(@checker.events.last.payload['response_headers']).to eq({ 'Content-Type' => 'text/html' }) |
|
219 |
+ expect(@checker.events.last.payload['headers']).to eq({ 'Content-Type' => 'text/html' }) |
|
220 | 220 |
end |
221 | 221 |
end |
222 | 222 |
end |
@@ -321,11 +321,11 @@ describe Agents::PostAgent do |
||
321 | 321 |
expect(@checker).to be_valid |
322 | 322 |
end |
323 | 323 |
|
324 |
- it "requires emit_events to be true or false, if present" do |
|
324 |
+ it "requires emit_events to be true or false" do |
|
325 | 325 |
@checker.options['emit_events'] = 'what?' |
326 | 326 |
expect(@checker).not_to be_valid |
327 | 327 |
|
328 |
- @checker.options['emit_events'] = '' |
|
328 |
+ @checker.options.delete('emit_events') |
|
329 | 329 |
expect(@checker).to be_valid |
330 | 330 |
|
331 | 331 |
@checker.options['emit_events'] = 'true' |