From dca493dd3f051bad894bded0171a4f953973e38e Mon Sep 17 00:00:00 2001 From: Willian Tenfen W Date: Tue, 26 Nov 2024 22:00:48 -0300 Subject: [PATCH] Fix undefined method 'close' when config.backlog is set to false --- lib/airbrake-ruby/sync_sender.rb | 2 ++ spec/sync_sender_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/airbrake-ruby/sync_sender.rb b/lib/airbrake-ruby/sync_sender.rb index 7d345c1b..38961593 100644 --- a/lib/airbrake-ruby/sync_sender.rb +++ b/lib/airbrake-ruby/sync_sender.rb @@ -66,6 +66,8 @@ def send(data, promise, endpoint = @config.error_endpoint) # @return [void] # @since v6.2.0 def close + return unless @backlog + @backlog.close end diff --git a/spec/sync_sender_spec.rb b/spec/sync_sender_spec.rb index d88a7959..2248af7b 100644 --- a/spec/sync_sender_spec.rb +++ b/spec/sync_sender_spec.rb @@ -204,5 +204,12 @@ sync_sender.close expect(mock_backlog).to have_received(:close) end + + it "doesn't error when config.backlog is false" do + Airbrake::Config.instance.merge(backlog: false) + + sync_sender.close + expect(mock_backlog).not_to have_received(:close) + end end end