Skip to content

Commit

Permalink
[#9470] Respect environment/settings in base context rich_data value
Browse files Browse the repository at this point in the history
  • Loading branch information
justinstoller committed Sep 5, 2024
1 parent 7739378 commit b284a3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def self.base_context(settings)
:ssl_context => proc { Puppet.runtime[:http].default_ssl_context },
:http_session => proc { Puppet.runtime[:http].create_session },
:plugins => proc { Puppet::Plugins::Configuration.load_plugins },
:rich_data => false
:rich_data => Puppet[:rich_data]
}
end

Expand Down
20 changes: 20 additions & 0 deletions spec/unit/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,26 @@ def inject_and_set_defaults(resource, scope)
# Note: to_stringified_spec.rb has tests for all other data types
end

describe 'when serializing resources' do
require 'puppet_spec/compiler'
include PuppetSpec::Compiler

it 'should do something' do
resource = compile_to_catalog('notify {"foo": message => Deferred("func", ["a", "b", "c"])}')

# This should be true by default
if Puppet[:rich_data]
expect(resource.to_data_hash.class).to be(Hash)
end

expect {
Puppet.override(rich_data: false) do
resource.to_data_hash
end
}.to raise_error(Puppet::PreformattedError)
end
end

describe "when converting from json" do
before do
@data = {
Expand Down

0 comments on commit b284a3e

Please sign in to comment.