]> gitweb.fluxo.info Git - puppet-stdlib.git/commit
(#20681) fix behaviour of delete_undef_values
authorLeonardo Rodrigues de Mello <l@lmello.eu.org>
Mon, 16 Sep 2013 14:08:13 +0000 (11:08 -0300)
committerLeonardo Rodrigues de Mello <l@lmello.eu.org>
Wed, 18 Sep 2013 14:19:52 +0000 (11:19 -0300)
commit80a8b7bd1fdb3aadd53d112ce9a20b86d8ea9a62
tree1701fb9cc05f0d766c0d81e3bc3151083f25ed1e
parent806430224ad0da860be3761ab83f1e574b64fc60
(#20681) fix behaviour of delete_undef_values

The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin array/hash and this is not the desired behaviour.

To solve this, we should dup or clone the array/hash
before using the delete or delete_if ruby functions.

We should also check if args[0] is not nil before using
dup, since dup on nil raises exception.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.
lib/puppet/parser/functions/delete_undef_values.rb
spec/unit/puppet/parser/functions/delete_undef_values_spec.rb