From 4daa00fda88d7189dd099281a0974a636b4e67e0 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Thu, 17 Jan 2019 11:37:27 -0500 Subject: [PATCH] Fix rubocop issues --- app/models/service_orchestration.rb | 17 ++++++++++++----- spec/models/service_orchestration_spec.rb | 21 +++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/models/service_orchestration.rb b/app/models/service_orchestration.rb index 2a314b870e8..6f4591b32e7 100644 --- a/app/models/service_orchestration.rb +++ b/app/models/service_orchestration.rb @@ -28,7 +28,8 @@ def orchestration_stack_status def deploy_orchestration_stack creation_options = stack_options @orchestration_stack = ManageIQ::Providers::CloudManager::OrchestrationStack.create_stack( - orchestration_manager, stack_name, orchestration_template, creation_options) + orchestration_manager, stack_name, orchestration_template, creation_options + ) ensure # create options may never be saved before unless they were overridden save_create_options @@ -78,7 +79,11 @@ def all_vms end def add_resource(rsc, _options = {}) - rsc.class.to_s.demodulize.eql?("OrchestrationStack") ? super : raise "add resource not supported for ServiceOrchestration" + if rsc.class.to_s.demodulize.eql?("OrchestrationStack") + super + else + raise "add resource not supported for ServiceOrchestration" + end end # This is called when provision is completed and stack is added to VMDB through a refresh @@ -144,9 +149,11 @@ def pick_orchestration_template(dialog_options) end def save_create_options - stack_attributes = @orchestration_stack ? - @orchestration_stack.attributes.compact : - {:name => stack_name} + stack_attributes = if @orchestration_stack + @orchestration_stack.attributes.compact + else + {:name => stack_name} + end stack_attributes.delete('id') options.merge!(:orchestration_stack => stack_attributes, :create_options => dup_and_process_password(stack_options)) diff --git a/spec/models/service_orchestration_spec.rb b/spec/models/service_orchestration_spec.rb index 45d0e24e923..2ea77175312 100644 --- a/spec/models/service_orchestration_spec.rb +++ b/spec/models/service_orchestration_spec.rb @@ -9,8 +9,8 @@ let(:service_template) do FactoryBot.create(:service_template_orchestration, - :orchestration_manager => manager_in_st, - :orchestration_template => template_in_st) + :orchestration_manager => manager_in_st, + :orchestration_template => template_in_st) end let(:dialog_options) do @@ -27,11 +27,11 @@ let(:service) do FactoryBot.create(:service_orchestration, - :service_template => service_template, - :orchestration_manager => manager_in_st, - :orchestration_template => template_in_st, - :evm_owner => FactoryBot.create(:user), - :miq_group => FactoryBot.create(:miq_group)) + :service_template => service_template, + :orchestration_manager => manager_in_st, + :orchestration_template => template_in_st, + :evm_owner => FactoryBot.create(:user), + :miq_group => FactoryBot.create(:miq_group)) end let(:service_with_dialog_options) do @@ -93,7 +93,8 @@ describe "#stack_options" do before do allow_any_instance_of(ManageIQ::Providers::Amazon::CloudManager::OrchestrationServiceOptionConverter).to( - receive(:stack_create_options).and_return(dialog_options)) + receive(:stack_create_options).and_return(dialog_options) + ) end it "gets stack options set by dialog" do @@ -261,8 +262,8 @@ describe '#post_provision_configure' do before do - allow(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack).to receive( - :raw_create_stack).and_return("ems_ref") + allow(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack) + .to receive(:raw_create_stack).and_return("ems_ref") @resulting_stack = service.deploy_orchestration_stack service.miq_request_task = FactoryBot.create(:service_template_provision_task)