From f402744d3840291e3d94760e05f1f8c03932c130 Mon Sep 17 00:00:00 2001 From: Tim Yiu Date: Wed, 23 Aug 2023 11:27:20 -0700 Subject: [PATCH] fix bug in workers.rb flush --- lib/amplitude/workers.rb | 2 +- spec/amplitude/client_spec.rb | 1 - spec/spec_helper.rb | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/amplitude/workers.rb b/lib/amplitude/workers.rb index d85160f..3df624e 100644 --- a/lib/amplitude/workers.rb +++ b/lib/amplitude/workers.rb @@ -40,8 +40,8 @@ def stop end def flush + events = @storage.pull_all Concurrent::Future.execute do - events = @storage.pull_all if events && !events.empty? send(events) end diff --git a/spec/amplitude/client_spec.rb b/spec/amplitude/client_spec.rb index 32ac628..5b077b4 100644 --- a/spec/amplitude/client_spec.rb +++ b/spec/amplitude/client_spec.rb @@ -30,7 +30,6 @@ def setup_stub 25.times do |i| @client.track(BaseEvent.new('test_event', user_id: 'test_user_id', event_properties: { 'id' => i })) end - sleep(1) futures = @client.flush futures.each do |flush_future| flush_future&.value diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 243f496..93fb05a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,5 +7,4 @@ add_filter '/spec/' add_filter '/vendor/' end - WebMock.disable_net_connect!(allow_localhost: true)