<commit_before>require './test/test_helper'

def app
  Sidekiq::Web
end

describe 'Cron web' do
  include Rack::Test::Methods

  before do
    Sidekiq.redis = REDIS
    Sidekiq.redis {|c| c.flushdb }

    #clear all previous saved data from redis
    Sidekiq.redis do |conn|
      conn.keys("cron_job*").each do |key|
        conn.del(key)
      end
    end

    @args = {
      name: "TestNameOfCronJob",
      cron: "*/2 * * * *",
      klass: "CronTestClass"
    }


    @cron_args = {
      name: "TesQueueNameOfCronJob",
      cron: "*/2 * * * *",
      klass: "CronQueueTestClass",
      queue: "cron"
    }

  end

  it 'display cron web' do
    get '/cron'
    assert_equal 200, last_response.status
  end

  it 'display cron web with message - no cron jobs' do
    get '/cron'
    assert last_response.body.include?('No cron jobs found')
  end

  it 'display cron web with cron jobs table' do
    Sidekiq::Cron::Job.create(@args)

    get '/cron'
    assert_equal 200, last_response.status
    refute last_response.body.include?('No cron jobs found')
    assert last_response.body.include?('table')
    assert last_response.body.include?("TestNameOfCronJob")
  end

  describe "work with cron job" do

    before do
      @job = Sidekiq::Cron::Job.new(@args.merge(status: "enabled"))
      @job.save
      @name = "TestNameOfCronJob"

      @cron_job = Sidekiq::Cron::Job.new(@cron_args.merge(status: "enabled"))
      @cron_job.save
      @cron_job_name = "TesQueueNameOfCronJob"
    end

    it "disable and enable all cron jobs" do
      post "/cron/__all__/disable"
      assert_equal Sidekiq::Cron::Job.find(@name).status, "disabled"

      post "/cron/__all__/enable"<commit_msg>Updated tests<commit_after>require './test/test_helper'

def app
  Sidekiq::Web
end

describe 'Cron web' do
  include Rack::Test::Methods

  before do
    Sidekiq.redis = REDIS
    Sidekiq.redis {|c| c.flushdb }

    #clear all previous saved data from redis
    Sidekiq.redis do |conn|
      conn.keys("cron_job*").each do |key|
        conn.del(key)
      end
    end

    @args = {
      name: "TestNameOfCronJob",
      cron: "*/2 * * * *",
      klass: "CronTestClass"
    }


    @cron_args = {
      name: "TesQueueNameOfCronJob",
      cron: "*/2 * * * *",
      klass: "CronQueueTestClass",
      queue: "cron"
    }

  end

  it 'display cron web' do
    get '/cron'
    assert_equal 200, last_response.status
  end

  it 'display cron web with message - no cron jobs' do
    get '/cron'
    assert last_response.body.include?('No cron jobs were found')
  end

  it 'display cron web with cron jobs table' do
    Sidekiq::Cron::Job.create(@args)

    get '/cron'
    assert_equal 200, last_response.status
    refute last_response.body.include?('No cron jobs were found')
    assert last_response.body.include?('table')
    assert last_response.body.include?("TestNameOfCronJob")
  end

  describe "work with cron job" do

    before do
      @job = Sidekiq::Cron::Job.new(@args.merge(status: "enabled"))
      @job.save
      @name = "TestNameOfCronJob"

      @cron_job = Sidekiq::Cron::Job.new(@cron_args.merge(status: "enabled"))
      @cron_job.save
      @cron_job_name = "TesQueueNameOfCronJob"
    end

    it "disable and enable all cron jobs" do
      post "/cron/__all__/disable"
      assert_equal Sidekiq::Cron::Job.find(@name).status, "disabled"

      post "/cron/__all__/enable"
{'fraction_non_alphanumeric': 0.12477928193054738, 'fraction_numerical': 0.004708652148322542, 'mean_word_length': 2.7935267857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2467754', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1195, 'n_words': 286}