1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-02-01 01:37:12 +00:00

Bug: Allow Flows#auto_flush if there are only auto_flushing flows

This commit is contained in:
Holger Just 2018-07-12 18:20:34 +02:00
parent 2c7d897889
commit 3ef0d56c2d
2 changed files with 9 additions and 1 deletions

View File

@ -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?

View File

@ -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