diff options
author | Cristian Bica <cristian.bica@gmail.com> | 2014-08-18 10:19:41 +0300 |
---|---|---|
committer | Cristian Bica <cristian.bica@gmail.com> | 2014-09-11 00:38:56 +0300 |
commit | 175ba6666453684bba3c24d03b75580a1f8e68bb (patch) | |
tree | 1d89d3d7452428eb0c11358b8ae37e4363030509 /activejob/test/integration | |
parent | 467e5700e6c759276406d8dc3604ede2c86235cb (diff) | |
download | rails-175ba6666453684bba3c24d03b75580a1f8e68bb.tar.gz rails-175ba6666453684bba3c24d03b75580a1f8e68bb.tar.bz2 rails-175ba6666453684bba3c24d03b75580a1f8e68bb.zip |
ActiveJob Integration Tests
Diffstat (limited to 'activejob/test/integration')
-rw-r--r-- | activejob/test/integration/queuing_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/activejob/test/integration/queuing_test.rb b/activejob/test/integration/queuing_test.rb new file mode 100644 index 0000000000..779dedb53f --- /dev/null +++ b/activejob/test/integration/queuing_test.rb @@ -0,0 +1,46 @@ +require 'helper' +require 'jobs/logging_job' +require 'active_support/core_ext/numeric/time' + +class QueuingTest < ActiveSupport::TestCase + test 'should run jobs enqueued on a listenting queue' do + TestJob.perform_later @id + wait_for_jobs_to_finish_for(5.seconds) + assert job_executed + end + + test 'should not run jobs queued on a non-listenting queue' do + begin + skip if adapter_is?(:inline) || adapter_is?(:sucker_punch) + old_queue = TestJob.queue_name + TestJob.queue_as :some_other_queue + TestJob.perform_later @id + wait_for_jobs_to_finish_for(2.seconds) + assert_not job_executed + ensure + TestJob.queue_name = old_queue + end + end + + test 'should not run job enqueued in the future' do + begin + TestJob.set(wait: 10.minutes).perform_later @id + wait_for_jobs_to_finish_for(5.seconds) + assert_not job_executed + rescue NotImplementedError + skip + end + end + + test 'should run job enqueued in the future at the specified time' do + begin + TestJob.set(wait: 3.seconds).perform_later @id + wait_for_jobs_to_finish_for(2.seconds) + assert_not job_executed + wait_for_jobs_to_finish_for(10.seconds) + assert job_executed + rescue NotImplementedError + skip + end + end +end |