]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Fix boolean rules being always recognized as changed.
authorGeorg Koester <georg.koester@gmail.com>
Thu, 11 Apr 2013 16:46:07 +0000 (09:46 -0700)
committerKen Barber <ken@bob.sh>
Sat, 13 Apr 2013 22:09:44 +0000 (23:09 +0100)
String and boolean types were compared.
Had to adapt the tests which checked for booleans, when in
reality strings where present.

lib/puppet/provider/firewall/iptables.rb
spec/unit/puppet/provider/iptables_spec.rb

index 978654ccb01946ab3692c34bc0cc056cbebb2d2c..edc7a53bbcdfe569c03d23f3f4f94932a5484c60 100644 (file)
@@ -208,9 +208,7 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
     # Convert booleans removing the previous cludge we did
     known_booleans.each do |bool|
       if hash[bool] != nil then
-        if hash[bool] == "true" then
-          hash[bool] = true
-        else
+        unless hash[bool] == "true" then
           raise "Parser error: #{bool} was meant to be a boolean but received value: #{hash[bool]}."
         end
       end
index a82fa6e274f007372d35754aefc51e26b426ec1a..37c6757455549fce21a3476e343aee2acea6b246 100644 (file)
@@ -87,7 +87,12 @@ describe 'iptables provider' do
         # Iterate across each parameter, creating an example for comparison
         data[:params].each do |param_name, param_value|
           it "the parameter '#{param_name.to_s}' should match #{param_value.inspect}" do
-            resource[param_name].should == data[:params][param_name]
+            # booleans get cludged to string "true"
+            if param_value == true then
+              resource[param_name].should == "true"
+            else
+              resource[param_name].should == data[:params][param_name]
+            end
           end
         end
       end