From 9b24ab41c00e1c4dd06ae387f60d6a3145a947aa Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Thu, 2 May 2019 14:56:07 +0200 Subject: [PATCH] Add better handling for delayed actions --- .../foreman_template_tasks/template_action.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/lib/actions/foreman_template_tasks/template_action.rb b/app/lib/actions/foreman_template_tasks/template_action.rb index 3319153..34378b0 100644 --- a/app/lib/actions/foreman_template_tasks/template_action.rb +++ b/app/lib/actions/foreman_template_tasks/template_action.rb @@ -7,9 +7,23 @@ module Actions middleware.use Actions::Middleware::KeepCurrentUser - def plan(context = nil, **template_params) + def delay(delay_options, context: nil, **task_params) + task_params = task_params.compact input.update context: context - input.update task_params: template_params + input.update task_params: task_params + + super delay_options, { context: context, task_params: task_params } + end + + # Rails passes hashes with keys as string by default + def plan(args = {}) + _plan(args.to_options) + end + + def _plan(context: nil, **task_params) + input.update context: context + input.update task_params: task_params.compact + plan_self end -- GitLab