Skip to content

Commit b284a3e

Browse files
committed
[#9470] Respect environment/settings in base context rich_data value
1 parent 7739378 commit b284a3e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/puppet.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def self.base_context(settings)
237237
:ssl_context => proc { Puppet.runtime[:http].default_ssl_context },
238238
:http_session => proc { Puppet.runtime[:http].create_session },
239239
:plugins => proc { Puppet::Plugins::Configuration.load_plugins },
240-
:rich_data => false
240+
:rich_data => Puppet[:rich_data]
241241
}
242242
end
243243

spec/unit/resource_spec.rb

+20
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,26 @@ def inject_and_set_defaults(resource, scope)
906906
# Note: to_stringified_spec.rb has tests for all other data types
907907
end
908908

909+
describe 'when serializing resources' do
910+
require 'puppet_spec/compiler'
911+
include PuppetSpec::Compiler
912+
913+
it 'should do something' do
914+
resource = compile_to_catalog('notify {"foo": message => Deferred("func", ["a", "b", "c"])}')
915+
916+
# This should be true by default
917+
if Puppet[:rich_data]
918+
expect(resource.to_data_hash.class).to be(Hash)
919+
end
920+
921+
expect {
922+
Puppet.override(rich_data: false) do
923+
resource.to_data_hash
924+
end
925+
}.to raise_error(Puppet::PreformattedError)
926+
end
927+
end
928+
909929
describe "when converting from json" do
910930
before do
911931
@data = {

0 commit comments

Comments
 (0)