mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
interpolated response (#1682)
This commit is contained in:
parent
5868c7b4b2
commit
4fdd69c6f4
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue