Skip to content

Commit

Permalink
Merge pull request #306 from hunner/fix_concat
Browse files Browse the repository at this point in the history
(MODULES-1195) Rebase of redhat-openstack#202
  • Loading branch information
Ashley Penney committed Jul 31, 2014
2 parents c5f6c26 + a6ad0af commit e310b1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/puppet/parser/functions/concat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ module Puppet::Parser::Functions
raise(Puppet::ParseError, 'concat(): Requires array to work with')
end

if b.is_a?(Array)
result = a.concat(b)
else
result = a << b
end
result = a + Array(b)

return result
end
Expand Down
5 changes: 5 additions & 0 deletions spec/functions/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@
expect(result).to(eq(['1','2','3',['4','5'],'6']))
end

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

0 comments on commit e310b1f

Please sign in to comment.