From 963ffa9988bdaa1df522c4610e942a76d7779ef3 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 9 Jan 2020 11:48:29 -0500 Subject: [PATCH 1/2] Use YAML.load to load classes beyond the basic types https://bugzilla.redhat.com/show_bug.cgi?id=1789153 Followup to ManageIQ/manageiq#19701 The prior behavior in core was to treat YAML.safe_load like YAML.load so let's change some of these to .load for now. We'll enumerate the list of classes where we can. --- .../miq_ae_method_service/miq_ae_service_model_base_spec.rb | 4 ++-- spec/engine/miq_ae_state_machine_retry_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb b/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb index 100705f9c..d23c19b7b 100644 --- a/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb +++ b/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb @@ -104,13 +104,13 @@ end it 'loads object from yaml' do - expect(YAML.safe_load(svc_service.to_yaml)).to eq(svc_service) + expect(YAML.safe_load(svc_service.to_yaml, [MiqAeMethodService::MiqAeServiceService])).to eq(svc_service) end it 'loads invalid svc_model for objects without related ar_model' do yaml = svc_service.to_yaml service.delete - model_from_yaml = YAML.safe_load(yaml) + model_from_yaml = YAML.safe_load(yaml, [MiqAeMethodService::MiqAeServiceService]) expect { model_from_yaml.reload }.to raise_error( NoMethodError, "undefined method `reload' for nil:NilClass" diff --git a/spec/engine/miq_ae_state_machine_retry_spec.rb b/spec/engine/miq_ae_state_machine_retry_spec.rb index 0c320ad83..223c44856 100644 --- a/spec/engine/miq_ae_state_machine_retry_spec.rb +++ b/spec/engine/miq_ae_state_machine_retry_spec.rb @@ -280,6 +280,6 @@ def create_restart_model(script1, script2, script3) expect(MiqQueue.count).to eq(2) q = MiqQueue.where(:state => 'ready').first expect(q[:server_guid]).to be_nil - expect(YAML.safe_load(q.args.first[:ae_state_data])).to eq(ae_state_data) + expect(YAML.load(q.args.first[:ae_state_data])).to eq(ae_state_data) end end From c51ae7af3f43e5fec9fae6048694bfb851e0d089 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 9 Jan 2020 13:45:24 -0500 Subject: [PATCH 2/2] Fix typo of backtick instead of quote https://bugzilla.redhat.com/show_bug.cgi?id=1789153 Followup to ManageIQ/manageiq#19701 Seen when run locally or in travis output: ``` 472.50s$ bundle exec rake ** ManageIQ master, codename: Jansa [Coveralls] Set up the SimpleCov formatter. [Coveralls] Using SimpleCov's 'rails' settings. ** ManageIQ master, codename: Jansa /home/travis/build/ManageIQ/manageiq-automation_engine/vendor/bundle/gems/rspec-core-3.9.1/exe/rspec: No such file or directory - does /home/travis/build/ManageIQ/manageiq-automation_engine/vendor/bundle/gems/rspec-core-3.9.1/exe/rspec: No such file or directory - does Randomized with seed 8807 .... ``` --- .../miq_ae_method_service/miq_ae_service_model_base_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb b/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb index d23c19b7b..5ca247e5c 100644 --- a/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb +++ b/spec/engine/miq_ae_method_service/miq_ae_service_model_base_spec.rb @@ -122,11 +122,11 @@ let(:service_model) { MiqAeMethodService::MiqAeServiceManageIQ_Providers_InfraManager_Vm } describe '.ar_subclass_associations' do - it `does not return the tags association` do + it 'does not return the tags association' do expect(service_model.ar_model_associations).to_not include(:tags) end - it `does not include associations from superclass` do + it 'does not include associations from superclass' do expect(service_model.ar_model_associations).to_not include(service_model.superclass.ar_model_associations) end end