mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Make the dry_run action accept an event payload
This commit is contained in:
parent
fec382f24f
commit
fe857bc6f0
2 changed files with 20 additions and 1 deletions
|
@ -50,7 +50,13 @@ class AgentsController < ApplicationController
|
|||
agent.name ||= '(Untitled)'
|
||||
|
||||
if agent.valid?
|
||||
results = agent.dry_run!
|
||||
if event_payload = params[:event]
|
||||
dummy_agent = Agent.build_for_type('ManualEventAgent', current_user, name: 'Dry-Runner')
|
||||
dummy_agent.readonly!
|
||||
event = dummy_agent.events.build(user: current_user, payload: event_payload)
|
||||
end
|
||||
|
||||
results = agent.dry_run!(event)
|
||||
|
||||
render json: {
|
||||
log: results[:log],
|
||||
|
|
|
@ -377,6 +377,19 @@ describe AgentsController do
|
|||
[users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count, agent.name, agent.updated_at]
|
||||
}
|
||||
end
|
||||
|
||||
it "accepts an event" do
|
||||
sign_in users(:bob)
|
||||
agent = agents(:bob_website_agent)
|
||||
url_from_event = "http://xkcd.com/?from_event=1".freeze
|
||||
expect {
|
||||
post :dry_run, id: agent, event: { url: url_from_event }
|
||||
}.not_to change {
|
||||
[users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count, agent.name, agent.updated_at]
|
||||
}
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['log']).to match(/^I, .* : Fetching #{Regexp.quote(url_from_event)}$/)
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE memory" do
|
||||
|
|
Loading…
Add table
Reference in a new issue