From: Georg Koester Date: Thu, 11 Apr 2013 16:46:07 +0000 (-0700) Subject: Fix boolean rules being always recognized as changed. X-Git-Tag: 0.3.0~7^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d4790594e29717c857962fb18cd3a599e2deddf0;p=puppet-modules%2Fpuppetlabs-firewall.git Fix boolean rules being always recognized as changed. String and boolean types were compared. Had to adapt the tests which checked for booleans, when in reality strings where present. --- diff --git a/lib/puppet/provider/firewall/iptables.rb b/lib/puppet/provider/firewall/iptables.rb index 978654c..edc7a53 100644 --- a/lib/puppet/provider/firewall/iptables.rb +++ b/lib/puppet/provider/firewall/iptables.rb @@ -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 diff --git a/spec/unit/puppet/provider/iptables_spec.rb b/spec/unit/puppet/provider/iptables_spec.rb index a82fa6e..37c6757 100644 --- a/spec/unit/puppet/provider/iptables_spec.rb +++ b/spec/unit/puppet/provider/iptables_spec.rb @@ -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