diff --git a/lib/rackstash/flows.rb b/lib/rackstash/flows.rb index 060f989..171f837 100644 --- a/lib/rackstash/flows.rb +++ b/lib/rackstash/flows.rb @@ -200,7 +200,7 @@ module Rackstash # `Hash`. # @return [Hash, nil] the flushed event or `nil` if nothing was flushed def auto_flush(event = nil) - flows = to_a.select!(&:auto_flush?) + flows = to_a.keep_if(&:auto_flush?) return unless flows.any? event ||= yield if block_given? diff --git a/spec/rackstash/flows_spec.rb b/spec/rackstash/flows_spec.rb index 387e523..ce6e604 100644 --- a/spec/rackstash/flows_spec.rb +++ b/spec/rackstash/flows_spec.rb @@ -435,5 +435,13 @@ RSpec.describe Rackstash::Flows do expect(flows.auto_flush('foo' => 'bar')).to be_nil expect { |b| flows.auto_flush(&b) }.not_to yield_control end + + it 'writes to all flows if they are all auto_flushing' do + auto_flush_flow = a_flow(auto_flush: true) + expect(auto_flush_flow).to receive(:write).with('foo' => 'bar') + flows << auto_flush_flow + + flows.auto_flush('foo' => 'bar') + end end end