diff options
Diffstat (limited to 'spec/lib/gitlab/memory/watchdog/handlers/puma_handler_spec.rb')
-rw-r--r-- | spec/lib/gitlab/memory/watchdog/handlers/puma_handler_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/memory/watchdog/handlers/puma_handler_spec.rb b/spec/lib/gitlab/memory/watchdog/handlers/puma_handler_spec.rb new file mode 100644 index 00000000000..7df95c1722e --- /dev/null +++ b/spec/lib/gitlab/memory/watchdog/handlers/puma_handler_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +RSpec.describe Gitlab::Memory::Watchdog::Handlers::PumaHandler, feature_category: :application_performance do + # rubocop: disable RSpec/VerifiedDoubles + # In tests, the Puma constant is not loaded so we cannot make this an instance_double. + let(:puma_worker_handle_class) { double('Puma::Cluster::WorkerHandle') } + let(:puma_worker_handle) { double('worker') } + # rubocop: enable RSpec/VerifiedDoubles + + subject(:handler) { described_class.new({}) } + + before do + stub_const('::Puma::Cluster::WorkerHandle', puma_worker_handle_class) + allow(puma_worker_handle_class).to receive(:new).and_return(puma_worker_handle) + allow(puma_worker_handle).to receive(:term) + end + + describe '#call' do + it 'invokes orderly termination via Puma API' do + expect(puma_worker_handle).to receive(:term) + + expect(handler.call).to be(true) + end + end +end |