Browse Source

Merge pull request #204 from hunner/fix_false

(MODULES-3145) Cast values to strings before passing to provider
Bryan Jen 8 years ago
parent
commit
1fe35c6868
2 changed files with 34 additions and 0 deletions
  1. 4 0
      lib/puppet/type/ini_setting.rb
  2. 30 0
      spec/unit/puppet/provider/ini_setting/ruby_spec.rb

+ 4 - 0
lib/puppet/type/ini_setting.rb

@@ -71,6 +71,10 @@ Puppet::Type.newtype(:ini_setting) do
   newproperty(:value) do
     desc 'The value of the setting to be defined.'
 
+    munge do |value|
+      value.to_s
+    end
+
     def should_to_s(newvalue)
       if (@resource[:show_diff] == :true && Puppet[:show_diff]) then
         return newvalue

+ 30 - 0
spec/unit/puppet/provider/ini_setting/ruby_spec.rb

@@ -268,6 +268,36 @@ subby=bar
       )
     end
 
+    it "should modify an existing setting with a different boolean value" do
+      resource = Puppet::Type::Ini_setting.new(common_params.merge(
+        :section => 'section1', :setting => 'master', :value => false))
+      provider = described_class.new(resource)
+      provider.exists?.should be true
+      expect(Puppet::Transaction::ResourceHarness.new(nil).evaluate(provider.resource).out_of_sync).to eq(true)
+      validate_file(<<-EOS
+# This is a comment
+[section1]
+; This is also a comment
+foo=foovalue
+
+bar = barvalue
+master = false
+[section2]
+
+foo= foovalue2
+baz=bazvalue
+url = http://192.168.1.1:8080
+[section:sub]
+subby=bar
+    #another comment
+ ; yet another comment
+
+-nonstandard-
+  shoes = purple
+      EOS
+)
+    end
+
     it "should modify an existing setting with pre/suffix with a different value" do
       resource = Puppet::Type::Ini_setting.new(common_params.merge(
            :section => 'nonstandard',