Skip to content

Commit e310b1f

Browse files
author
Ashley Penney
committed
Merge pull request #306 from hunner/fix_concat
(MODULES-1195) Rebase of #202
2 parents c5f6c26 + a6ad0af commit e310b1f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/puppet/parser/functions/concat.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ module Puppet::Parser::Functions
2828
raise(Puppet::ParseError, 'concat(): Requires array to work with')
2929
end
3030

31-
if b.is_a?(Array)
32-
result = a.concat(b)
33-
else
34-
result = a << b
35-
end
31+
result = a + Array(b)
3632

3733
return result
3834
end

spec/functions/concat_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@
2727
expect(result).to(eq(['1','2','3',['4','5'],'6']))
2828
end
2929

30+
it "should leave the original array intact" do
31+
array_original = ['1','2','3']
32+
result = scope.function_concat([array_original,['4','5','6']])
33+
array_original.should(eq(['1','2','3']))
34+
end
3035
end

0 commit comments

Comments
 (0)