require "rails_helper"
require "gds_api/test_helpers/content_store"

RSpec.describe "taxonomy:health_checks" do
  include ::GdsApi::TestHelpers::ContentStore
  include PublishingApiHelper
  include ContentItemHelper
  include RakeTaskHelper
  include ActiveJob::TestHelper

  it "queues the expected jobs" do
    ActiveJob::Base.queue_adapter = :test

    expect {
      rake "taxonomy:health_checks"
    }.to change(TaxonomyHealth::MaximumDepthMetric.jobs, :size).by(1)
    .and change(TaxonomyHealth::ContentCountMetric.jobs, :size).by(1)
    .and change(TaxonomyHealth::ChildTaxonCountMetric.jobs, :size).by(1)
  end
end

require "rails_helper"

RSpec.describe "taxonomy:health_checks" do
  include RakeTaskHelper
  include ActiveJob::TestHelper

  it "queues the expected jobs" do
    ActiveJob::Base.queue_adapter = :test

    Sidekiq::Testing.fake! do
      expect {
        rake "taxonomy:health_checks"
      }.to change(TaxonomyHealth::MaximumDepthMetric.jobs, :size).by(1)
      .and change(TaxonomyHealth::ContentCountMetric.jobs, :size).by(1)
      .and change(TaxonomyHealth::ChildTaxonCountMetric.jobs, :size).by(1)
    end
  end
end

Fix sidekiq tests running inline
Fix sidekiq tests running inline

Occasionally (because of the random order of tests), other config which
sets Sidekiq to run inline leaks here. This causes the tests to fail because
the code is not run as a worker in test mode.

I've wrapped this test in a `fake!` block which ensures that this test
runs as we want and doesn't interfere with others.
