sidekiq_process_check_spec.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Admin::SystemCheck::SidekiqProcessCheck do
  4. subject(:check) { described_class.new(user) }
  5. let(:user) { Fabricate(:user) }
  6. it_behaves_like 'a check available to devops users'
  7. describe 'pass?' do
  8. context 'when missing queues is empty' do
  9. before do
  10. process_set = instance_double(Sidekiq::ProcessSet, reduce: [])
  11. allow(Sidekiq::ProcessSet).to receive(:new).and_return(process_set)
  12. end
  13. it 'returns true' do
  14. expect(check.pass?).to be true
  15. end
  16. end
  17. context 'when missing queues is not empty' do
  18. before do
  19. process_set = instance_double(Sidekiq::ProcessSet, reduce: [:something])
  20. allow(Sidekiq::ProcessSet).to receive(:new).and_return(process_set)
  21. end
  22. it 'returns false' do
  23. expect(check.pass?).to be false
  24. end
  25. end
  26. end
  27. describe 'message' do
  28. it 'sends values to message instance' do
  29. allow(Admin::SystemCheck::Message).to receive(:new).with(:sidekiq_process_check, 'default, push, mailers, pull, scheduler, ingress')
  30. check.message
  31. expect(Admin::SystemCheck::Message).to have_received(:new).with(:sidekiq_process_check, 'default, push, mailers, pull, scheduler, ingress')
  32. end
  33. end
  34. end