interpolated response (#1682)

This commit is contained in:
Thiago Talma 2016-09-15 20:15:46 -03:00 committed by Andrew Cantino
parent 5868c7b4b2
commit 4fdd69c6f4
2 changed files with 7 additions and 5 deletions

View file

@ -88,7 +88,7 @@ module Agents
create_event(payload: payload)
end
[response_message, code]
[interpolated(params)['response'] || 'Event Created', code]
end
def working?
@ -108,9 +108,5 @@ module Agents
def payload_for(params)
Utils.value_at(params, interpolated['payload_path']) || {}
end
def response_message
interpolated['response'] || 'Event Created'
end
end
end

View file

@ -49,6 +49,12 @@ describe Agents::WebhookAgent do
expect(out).to eq(['', 201])
end
it 'should respond with interpolated response message if configured with `response` option' do
agent.options['response'] = '{{some_key.people[1].name}}'
out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html")
expect(out).to eq(['jon', 201])
end
it 'should respond with `Event Created` if the response option is nil or missing' do
agent.options['response'] = nil
out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html")