Skip to content

Commit

Permalink
Use YAML.load to load classes beyond the basic types
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrafanie committed Jan 9, 2020
1 parent 03cbde7 commit 963ffa9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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 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 963ffa9

Please sign in to comment.