mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
DryRunMemory (#1550)
This commit is contained in:
parent
e4e2782ebe
commit
5cdc37f716
2 changed files with 18 additions and 0 deletions
|
@ -18,6 +18,7 @@ module Agents
|
|||
if agent = current_user.agents.find_by(id: params[:agent_id])
|
||||
# POST /agents/:id/dry_run
|
||||
if attrs.present?
|
||||
attrs.merge!(memory: agent.memory)
|
||||
type = agent.type
|
||||
agent = Agent.build_for_type(type, current_user, attrs)
|
||||
end
|
||||
|
|
|
@ -100,5 +100,22 @@ describe Agents::DryRunsController do
|
|||
results = assigns(:results)
|
||||
expect(results[:log]).to match(/^\[\d\d:\d\d:\d\d\] INFO -- : Fetching #{Regexp.quote(url_from_event)}$/)
|
||||
end
|
||||
|
||||
it "uses the memory of an existing Agent" do
|
||||
valid_params = {
|
||||
:name => "somename",
|
||||
:options => {
|
||||
:code => "Agent.check = function() { this.createEvent({ 'message': this.memory('fu') }); };",
|
||||
}
|
||||
}
|
||||
agent = Agents::JavaScriptAgent.new(valid_params)
|
||||
agent.memory = {fu: "bar"}
|
||||
agent.user = users(:bob)
|
||||
agent.save!
|
||||
post :create, agent_id: agent, agent: valid_params
|
||||
results = assigns(:results)
|
||||
expect(results[:events][0]).to eql({"message" => "bar"})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue