Updated

spec/jobs / job_priority_spec.rb

C
86 lines of codes
4 methods
24.2 complexity/method
2 churn
96.65 complexity
112 duplications
require 'rails_helper' RSpec.describe "setting job priorities" do before do ActiveJob::Base.queue_adapter = :delayed_job end describe "default priority" do it "is 100" do expect(Delayed::Worker.default_priority).to eq(100) end end describe "enqueuing" do let(:job) { Delayed::Job.last } let(:priority) { job.priority } before do job_class.perform_later end describe 'the highest priority job' do
  1. Similar code found in 4 nodes Locations: 0 1 2 3
let(:job_class) do Class.new(ActiveJob::Base) do queue_as :highest_priority def perform logger.info("Highest priority job") end end end it "is queued with a priority of 0" do expect(priority).to eq(0) end end describe "a high priority job" do
  1. Similar code found in 4 nodes Locations: 0 1 2 3
let(:job_class) do Class.new(ActiveJob::Base) do queue_as :high_priority def perform logger.info("High priority job") end end end it "is queued with a priority of 10" do expect(priority).to eq(10) end end describe "a low priority job" do
  1. Similar code found in 4 nodes Locations: 0 1 2 3
let(:job_class) do Class.new(ActiveJob::Base) do queue_as :low_priority def perform logger.info("Low priority job") end end end it "is queued with a priority of 50" do expect(priority).to eq(50) end end describe "an unclassified job" do
  1. Similar code found in 4 nodes Locations: 0 1 2 3
let(:job_class) do Class.new(ActiveJob::Base) do queue_as :unclassified def perform logger.info("Unclassified job") end end end it "is queued with a priority of 25" do expect(priority).to eq(25) end end end end