diff --git a/lib/active_interaction/filters/array_filter.rb b/lib/active_interaction/filters/array_filter.rb index 9b091d15..3c0d08f1 100644 --- a/lib/active_interaction/filters/array_filter.rb +++ b/lib/active_interaction/filters/array_filter.rb @@ -49,7 +49,7 @@ def process(value, context) children = [] unless filters.empty? - value.map! do |item| + value = value.map do |item| result = filters[:'0'].process(item, context) children.push(result) result.value diff --git a/spec/active_interaction/filters/array_filter_spec.rb b/spec/active_interaction/filters/array_filter_spec.rb index e0847ad8..f22484ed 100644 --- a/spec/active_interaction/filters/array_filter_spec.rb +++ b/spec/active_interaction/filters/array_filter_spec.rb @@ -74,6 +74,11 @@ def to_ary it 'returns the transformed value' do expect(result.value).to eql [:test] end + + it 'does not modify the original value' do + expect(result.value.object_id).to_not eql value.object_id + expect(value).to eql ['test'] + end end context 'with a nested filter' do