<commit_before># vim:fileencoding=utf-8
require_relative 'test_helper'

require 'resque/server/test_helper'

context 'on GET to /schedule' do
  setup { get '/schedule' }

  test('is 200') { assert last_response.ok? }
end

context 'on GET to /schedule with scheduled jobs' do
  setup do
    Resque::Scheduler.env = 'production'
    Resque.schedule = {
      'some_ivar_job' => {
        'cron' => '* * * * *',
        'class' => 'SomeIvarJob',
        'args' => '/tmp',
        'rails_env' => 'production'
      },
      'some_other_job' => {
        'every' => ['1m', ['1h']],
        'queue' => 'high',
        'custom_job_class' => 'SomeOtherJob',
        'args' => {
          'b' => 'blah'
        }
      },
      'some_fancy_job' => {
        'every' => ['1m'],
        'queue' => 'fancy',
        'class' => 'SomeFancyJob',
        'args' => 'sparkles',
        'rails_env' => 'fancy'
      },
      'shared_env_job' => {
        'cron' => '* * * * *',
        'class' => 'SomeSharedEnvJob',
        'args' => '/tmp',
        'rails_env' => 'fancy, production'
      }
    }
    Resque::Scheduler.load_schedule!
    get '/schedule'
  end

  test('is 200') { assert last_response.ok? }

  test 'see the scheduled job' do
    assert last_response.body.include?('SomeIvarJob')
  end

  test 'excludes jobs for other envs' do
    assert !last_response.body.include?('SomeFancyJob')<commit_msg>Fixing test for including non env jobs.<commit_after># vim:fileencoding=utf-8
require_relative 'test_helper'

require 'resque/server/test_helper'

context 'on GET to /schedule' do
  setup { get '/schedule' }

  test('is 200') { assert last_response.ok? }
end

context 'on GET to /schedule with scheduled jobs' do
  setup do
    Resque::Scheduler.env = 'production'
    Resque.schedule = {
      'some_ivar_job' => {
        'cron' => '* * * * *',
        'class' => 'SomeIvarJob',
        'args' => '/tmp',
        'rails_env' => 'production'
      },
      'some_other_job' => {
        'every' => ['1m', ['1h']],
        'queue' => 'high',
        'custom_job_class' => 'SomeOtherJob',
        'args' => {
          'b' => 'blah'
        }
      },
      'some_fancy_job' => {
        'every' => ['1m'],
        'queue' => 'fancy',
        'class' => 'SomeFancyJob',
        'args' => 'sparkles',
        'rails_env' => 'fancy'
      },
      'shared_env_job' => {
        'cron' => '* * * * *',
        'class' => 'SomeSharedEnvJob',
        'args' => '/tmp',
        'rails_env' => 'fancy, production'
      }
    }
    Resque::Scheduler.load_schedule!
    get '/schedule'
  end

  test('is 200') { assert last_response.ok? }

  test 'see the scheduled job' do
    assert last_response.body.include?('SomeIvarJob')
  end

  test 'include(highlight) jobs for other envs' do
    assert last_response.body.include?('SomeFancyJob')
{'fraction_non_alphanumeric': 0.17474354439334985, 'fraction_numerical': 0.007074637424831978, 'mean_word_length': 2.327058823529412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 47, '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': '5075178', 'n_tokens_mistral': 1007, 'n_tokens_neox': 974, 'n_words': 203}