Skip to content

Commit

Permalink
Merge pull request #407 from jrafanie/fix_invalid_usage_of_yaml_safe_…
Browse files Browse the repository at this point in the history
…load

Use YAML.load to load classes beyond the basic types
  • Loading branch information
gmcculloug authored Jan 9, 2020
2 parents 03cbde7 + c51ae7a commit 6fe3c54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/engine/miq_ae_state_machine_retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6fe3c54

Please sign in to comment.