Skip to content

Commit

Permalink
Merge pull request #954 from hlindberg/MODULES-7768_fix-undef-vs-nil
Browse files Browse the repository at this point in the history
(MODULES-7768) Handle nil in delete_undef_values() function
  • Loading branch information
hlindberg authored Sep 10, 2018
2 parents f357cf4 + 792bcd4 commit 2ad640c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/puppet/parser/functions/delete_undef_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ module Puppet::Parser::Functions
end
result = args[0].dup
if result.is_a?(Hash)
result.delete_if { |_key, val| val.equal? :undef }
result.delete_if { |_, val| val.equal?(:undef) || val.nil? }
elsif result.is_a?(Array)
result.delete :undef
result.delete nil
end
result
end
Expand Down
2 changes: 0 additions & 2 deletions spec/functions/delete_undef_values_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
describe "when undef is represented by #{undef_value.inspect}" do
before(:each) do
pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value.nil?
end
it { is_expected.to run.with_params([undef_value]).and_return([]) }
it { is_expected.to run.with_params(['one', undef_value, 'two', 'three']).and_return(['one', 'two', 'three']) }
Expand All @@ -35,7 +34,6 @@
describe "when undef is represented by #{undef_value.inspect}" do
before(:each) do
pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value.nil?
end
it { is_expected.to run.with_params('key' => undef_value).and_return({}) }
it {
Expand Down

0 comments on commit 2ad640c

Please sign in to comment.