test/plugins/job/throttle_test.rb in rocketjob-3.0.5 vs test/plugins/job/throttle_test.rb in rocketjob-3.1.0

- old
+ new

@@ -17,37 +17,54 @@ describe RocketJob::Plugins::Job::Throttle do before do RocketJob::Job.delete_all end - describe '#throttle_exceeded?' do + describe '.has_throttle?' do + it 'defines the running jobs throttle' do + assert ThrottleJob.has_throttle?(:throttle_running_jobs_exceeded?), ThrottleJob.rocket_job_throttles + refute ThrottleJob.has_throttle?(:blah?), ThrottleJob.rocket_job_throttles + end + end + + describe '.undefine_throttle' do + it 'undefines the running jobs throttle' do + assert ThrottleJob.has_throttle?(:throttle_running_jobs_exceeded?), ThrottleJob.rocket_job_throttles + ThrottleJob.undefine_throttle(:throttle_running_jobs_exceeded?) + refute ThrottleJob.has_throttle?(:throttle_running_jobs_exceeded?), ThrottleJob.rocket_job_throttles + ThrottleJob.define_throttle(:throttle_running_jobs_exceeded?) + assert ThrottleJob.has_throttle?(:throttle_running_jobs_exceeded?), ThrottleJob.rocket_job_throttles + end + end + + describe '#throttle_running_jobs_exceeded??' do it 'does not exceed throttle when no other jobs are running' do ThrottleJob.create! job = ThrottleJob.new - refute job.throttle_exceeded? + refute job.send(:throttle_running_jobs_exceeded?) end it 'exceeds throttle when other jobs are running' do job1 = ThrottleJob.new job1.start! job2 = ThrottleJob.new - assert job2.throttle_exceeded? + assert job2.send(:throttle_running_jobs_exceeded?) end it 'excludes paused jobs' do job1 = ThrottleJob.new job1.start job1.pause! job2 = ThrottleJob.new - refute job2.throttle_exceeded? + refute job2.send(:throttle_running_jobs_exceeded?) end it 'excludes failed jobs' do job1 = ThrottleJob.new job1.start job1.fail! job2 = ThrottleJob.new - refute job2.throttle_exceeded? + refute job2.send(:throttle_running_jobs_exceeded?) end end describe '.rocket_job_next_job' do before do