From 9a71b8e98e842ae7096f2df6b12a5478fc6b6caf Mon Sep 17 00:00:00 2001 From: Greg McCullough Date: Tue, 2 May 2017 13:27:09 -0400 Subject: [PATCH] Merge pull request #14958 from bzwei/dialog_id_and_name Prefer :dialog_id to :new_dialog_name in config_info (cherry picked from commit ec26e2b9e064ecb8cfa3ce52fa8718290ce1748c) https://bugzilla.redhat.com/show_bug.cgi?id=1447427 --- app/models/service_template_ansible_playbook.rb | 13 +++++++------ .../service_template_ansible_playbook_spec.rb | 9 ++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/service_template_ansible_playbook.rb b/app/models/service_template_ansible_playbook.rb index ad45d40ae73..b3a2021ca8f 100644 --- a/app/models/service_template_ansible_playbook.rb +++ b/app/models/service_template_ansible_playbook.rb @@ -48,14 +48,15 @@ def self.create_catalog_item(options, auth_user) transaction do create_from_options(options).tap do |service_template| [:provision, :retirement, :reconfigure].each do |action| - dialog_name = config_info.fetch_path(action, :new_dialog_name) - next unless dialog_name + action_info = enhanced_config[action] + next unless service_template.send(:new_dialog_required?, action_info) - job_template = enhanced_config.fetch_path(action, :configuration_template) - hosts = enhanced_config.fetch_path(action, :hosts) + dialog_name = action_info[:new_dialog_name] + job_template = action_info[:configuration_template] + hosts = action_info[:hosts] new_dialog = service_template.send(:create_new_dialog, dialog_name, job_template, hosts) - enhanced_config[action][:dialog] = new_dialog + action_info[:dialog] = new_dialog service_template.options[:config_info][action][:dialog_id] = new_dialog.id end service_template.create_resource_actions(enhanced_config) @@ -202,7 +203,7 @@ def delete_job_templates(job_templates) end def new_dialog_required?(info) - info && info.key?(:new_dialog_name) + info && info.key?(:new_dialog_name) && !info.key?(:dialog_id) end def self.new_job_template_required?(info, action, service_template) diff --git a/spec/models/service_template_ansible_playbook_spec.rb b/spec/models/service_template_ansible_playbook_spec.rb index 2e81055a0f4..bf501de52ed 100644 --- a/spec/models/service_template_ansible_playbook_spec.rb +++ b/spec/models/service_template_ansible_playbook_spec.rb @@ -225,19 +225,18 @@ expect(service_template.resource_actions.first.dialog.id).to eq new_dialog_record.id end - it 'uses the existing dialog if :service_dialog_id is passed in' do + it 'uses the existing dialog if :dialog_id is passed in' do info = catalog_item_options_three.fetch_path(:config_info, :provision) - info.delete(:new_dialog_name) - info[:service_dialog_id] = service_template.dialogs.first.id + info[:dialog_id] = service_template.dialogs.first.id - expect(service_template.dialogs.first.id).to eq info[:service_dialog_id] + expect(service_template.dialogs.first.id).to eq info[:dialog_id] expect(described_class).to receive(:create_new_dialog).never expect(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript).to receive(:update_in_provider_queue).once service_template.update_catalog_item(catalog_item_options_three, user) service_template.reload - expect(service_template.dialogs.first.id).to eq info[:service_dialog_id] + expect(service_template.dialogs.first.id).to eq info[:dialog_id] end end