diff --git a/lib/puppet/provider/chocolateyfeature/windows.rb b/lib/puppet/provider/chocolateyfeature/windows.rb index c6b73508..c0338fcb 100644 --- a/lib/puppet/provider/chocolateyfeature/windows.rb +++ b/lib/puppet/provider/chocolateyfeature/windows.rb @@ -60,6 +60,7 @@ def self.get_choco_feature(element) feature[:ensure] = :disabled feature[:ensure] = :enabled if enabled + feature[:ensure] = :not_explicit if element.attributes['setExplicitly'].casecmp('false').zero? Puppet.debug("Loaded feature '#{feature.inspect}'.") diff --git a/spec/unit/puppet/provider/chocolateyfeature/windows_spec.rb b/spec/unit/puppet/provider/chocolateyfeature/windows_spec.rb index 86a5fdd2..581f4076 100644 --- a/spec/unit/puppet/provider/chocolateyfeature/windows_spec.rb +++ b/spec/unit/puppet/provider/chocolateyfeature/windows_spec.rb @@ -154,9 +154,10 @@ element_name = 'default' element_enabled = 'true' + element_set_explicitly = 'true' before :each do - element.add_attributes('name' => element_name, 'enabled' => element_enabled) + element.add_attributes('name' => element_name, 'enabled' => element_enabled, 'setExplicitly' => element_set_explicitly) end it 'returns nil feature when element is nil' do @@ -177,5 +178,13 @@ feature = provider_class.get_choco_feature(element) expect(feature[:ensure]).to eq(:disabled) end + + it 'when feature is not set explicitly' do + element.delete_attribute('setExplicitly') + element.add_attribute('setExplicitly', 'false') + + feature = provider_class.get_choco_feature(element) + expect(feature[:ensure]).to eq(:not_explicit) + end end end