Methods
T
Instance Public methods
test_assert_no_performed_jobs()
# File activejob/test/cases/test_helper_test.rb, line 322
def test_assert_no_performed_jobs
  assert_nothing_raised do
    assert_no_performed_jobs do
      # empty block won't perform jobs
    end
  end
end
test_assert_no_performed_jobs_failure()
# File activejob/test/cases/test_helper_test.rb, line 351
def test_assert_no_performed_jobs_failure
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_no_performed_jobs do
      HelloJob.perform_later('jeremy')
    end
  end

  assert_match(/0 .* but 1/, error.message)
end
test_assert_no_performed_jobs_with_no_block()
# File activejob/test/cases/test_helper_test.rb, line 316
def test_assert_no_performed_jobs_with_no_block
  assert_nothing_raised do
    assert_no_performed_jobs
  end
end
test_assert_no_performed_jobs_with_only_option()
# File activejob/test/cases/test_helper_test.rb, line 411
def test_assert_no_performed_jobs_with_only_option
  assert_nothing_raised do
    assert_no_performed_jobs only: HelloJob do
      LoggingJob.perform_later
    end
  end
end
test_assert_no_performed_jobs_with_only_option_as_array()
# File activejob/test/cases/test_helper_test.rb, line 419
def test_assert_no_performed_jobs_with_only_option_as_array
  assert_nothing_raised do
    assert_no_performed_jobs only: [HelloJob, RescueJob] do
      LoggingJob.perform_later
    end
  end
end
test_assert_no_performed_jobs_with_only_option_failure()
# File activejob/test/cases/test_helper_test.rb, line 427
def test_assert_no_performed_jobs_with_only_option_failure
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_no_performed_jobs only: HelloJob do
      HelloJob.perform_later('jeremy')
      LoggingJob.perform_later
    end
  end

  assert_match(/0 .* but 1/, error.message)
end
test_assert_performed_job()
# File activejob/test/cases/test_helper_test.rb, line 438
def test_assert_performed_job
  assert_performed_with(job: NestedJob, queue: 'default') do
    NestedJob.perform_later
  end
end
test_assert_performed_job_does_not_change_jobs_count()
# File activejob/test/cases/test_helper_test.rb, line 500
def test_assert_performed_job_does_not_change_jobs_count
  assert_performed_with(job: HelloJob) do
    HelloJob.perform_later
  end

  assert_performed_with(job: HelloJob) do
    HelloJob.perform_later
  end

  assert_equal 2, ActiveJob::Base.queue_adapter.performed_jobs.count
end
test_assert_performed_job_failure()
# File activejob/test/cases/test_helper_test.rb, line 455
def test_assert_performed_job_failure
  assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_with(job: LoggingJob) do
      HelloJob.perform_later
    end
  end

  assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_with(job: HelloJob, queue: 'low') do
      HelloJob.set(queue: 'important').perform_later
    end
  end
end
test_assert_performed_job_failure_with_global_id_args()
# File activejob/test/cases/test_helper_test.rb, line 488
def test_assert_performed_job_failure_with_global_id_args
  ricardo = Person.new(9)
  wilma = Person.new(11)
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_with(job: HelloJob, args: [wilma]) do
      HelloJob.perform_later(ricardo)
    end
  end

  assert_equal "No performed job found with {:job=>HelloJob, :args=>[#{wilma.inspect}]}", error.message
end
test_assert_performed_job_returns()
# File activejob/test/cases/test_helper_test.rb, line 444
def test_assert_performed_job_returns
  job = assert_performed_with(job: NestedJob, queue: 'default') do
    NestedJob.perform_later
  end

  assert_instance_of NestedJob, job
  assert_nil job.scheduled_at
  assert_equal [], job.arguments
  assert_equal 'default', job.queue_name
end
test_assert_performed_job_with_at_option()
# File activejob/test/cases/test_helper_test.rb, line 469
def test_assert_performed_job_with_at_option
  assert_performed_with(job: HelloJob, at: Date.tomorrow.noon) do
    HelloJob.set(wait_until: Date.tomorrow.noon).perform_later
  end

  assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_with(job: HelloJob, at: Date.today.noon) do
      HelloJob.set(wait_until: Date.tomorrow.noon).perform_later
    end
  end
end
test_assert_performed_job_with_global_id_args()
# File activejob/test/cases/test_helper_test.rb, line 481
def test_assert_performed_job_with_global_id_args
  ricardo = Person.new(9)
  assert_performed_with(job: HelloJob, args: [ricardo]) do
    HelloJob.perform_later(ricardo)
  end
end
test_assert_performed_jobs()
# File activejob/test/cases/test_helper_test.rb, line 265
def test_assert_performed_jobs
  assert_nothing_raised do
    assert_performed_jobs 1 do
      HelloJob.perform_later('david')
    end
  end
end
test_assert_performed_jobs_message()
# File activejob/test/cases/test_helper_test.rb, line 288
def test_assert_performed_jobs_message
  HelloJob.perform_later('sean')
  e = assert_raises Minitest::Assertion do
    assert_performed_jobs 2 do
      HelloJob.perform_later('sean')
    end
  end
  assert_match "Expected: 2", e.message
  assert_match "Actual: 1", e.message
end
test_assert_performed_jobs_too_few_sent()
# File activejob/test/cases/test_helper_test.rb, line 330
def test_assert_performed_jobs_too_few_sent
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_jobs 2 do
      HelloJob.perform_later('xavier')
    end
  end

  assert_match(/2 .* but 1/, error.message)
end
test_assert_performed_jobs_too_many_sent()
# File activejob/test/cases/test_helper_test.rb, line 340
def test_assert_performed_jobs_too_many_sent
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_jobs 1 do
      HelloJob.perform_later('cristian')
      HelloJob.perform_later('guillermo')
    end
  end

  assert_match(/1 .* but 2/, error.message)
end
test_assert_performed_jobs_with_no_block()
# File activejob/test/cases/test_helper_test.rb, line 299
def test_assert_performed_jobs_with_no_block
  assert_nothing_raised do
    perform_enqueued_jobs do
      HelloJob.perform_later('rafael')
    end
    assert_performed_jobs 1
  end

  assert_nothing_raised do
    perform_enqueued_jobs do
      HelloJob.perform_later('aaron')
      HelloJob.perform_later('matthew')
      assert_performed_jobs 3
    end
  end
end
test_assert_performed_jobs_with_only_option()
# File activejob/test/cases/test_helper_test.rb, line 361
def test_assert_performed_jobs_with_only_option
  assert_nothing_raised do
    assert_performed_jobs 1, only: HelloJob do
      HelloJob.perform_later('jeremy')
      LoggingJob.perform_later
    end
  end
end
test_assert_performed_jobs_with_only_option_and_none_sent()
# File activejob/test/cases/test_helper_test.rb, line 380
def test_assert_performed_jobs_with_only_option_and_none_sent
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_jobs 1, only: HelloJob do
      LoggingJob.perform_later
    end
  end

  assert_match(/1 .* but 0/, error.message)
end
test_assert_performed_jobs_with_only_option_and_too_few_sent()
# File activejob/test/cases/test_helper_test.rb, line 390
def test_assert_performed_jobs_with_only_option_and_too_few_sent
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_jobs 5, only: HelloJob do
      HelloJob.perform_later('jeremy')
      4.times { LoggingJob.perform_later }
    end
  end

  assert_match(/5 .* but 1/, error.message)
end
test_assert_performed_jobs_with_only_option_and_too_many_sent()
# File activejob/test/cases/test_helper_test.rb, line 401
def test_assert_performed_jobs_with_only_option_and_too_many_sent
  error = assert_raise ActiveSupport::TestCase::Assertion do
    assert_performed_jobs 1, only: HelloJob do
      2.times { HelloJob.perform_later('jeremy') }
    end
  end

  assert_match(/1 .* but 2/, error.message)
end
test_assert_performed_jobs_with_only_option_as_array()
# File activejob/test/cases/test_helper_test.rb, line 370
def test_assert_performed_jobs_with_only_option_as_array
  assert_nothing_raised do
    assert_performed_jobs 2, only: [HelloJob, LoggingJob] do
      HelloJob.perform_later('jeremy')
      LoggingJob.perform_later('stewie')
      RescueJob.perform_later('david')
    end
  end
end
test_performed_enqueue_jobs_with_only_option_doesnt_leak_outside_the_block()
# File activejob/test/cases/test_helper_test.rb, line 257
def test_performed_enqueue_jobs_with_only_option_doesnt_leak_outside_the_block
  assert_equal nil, queue_adapter.filter
  perform_enqueued_jobs only: HelloJob do
    assert_equal HelloJob, queue_adapter.filter
  end
  assert_equal nil, queue_adapter.filter
end
test_repeated_performed_jobs_calls()
# File activejob/test/cases/test_helper_test.rb, line 273
def test_repeated_performed_jobs_calls
  assert_nothing_raised do
    assert_performed_jobs 1 do
      HelloJob.perform_later('abdelkader')
    end
  end

  assert_nothing_raised do
    assert_performed_jobs 2 do
      HelloJob.perform_later('sean')
      HelloJob.perform_later('yves')
    end
  end
end