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:
parent
2c7d897889
commit
3ef0d56c2d
@ -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?
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user