1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Initialize monitor and copy internal filters list on FilterChain#dup

This commit is contained in:
Holger Just 2017-08-02 17:50:53 +02:00
parent 6c145579ed
commit 271c547f05
2 changed files with 19 additions and 0 deletions

View File

@ -273,6 +273,15 @@ module Rackstash
private
def initialize_copy(orig)
super
mon_initialize
synchronize do
@filters = orig.to_a
end
end
def index_at(index)
case index
when Integer, ->(o) { o.respond_to?(:to_int) }

View File

@ -225,6 +225,16 @@ describe Rackstash::FilterChain do
end
end
describe '#dup' do
it 'duplicates the filters array' do
filter_chain << a_filter
dupped = filter_chain.dup
expect(filter_chain.length).to eql dupped.length
expect { filter_chain << a_filter }.not_to change { dupped.length }
end
end
describe '#each' do
it 'yields each filter' do
filter_chain << -> {}