jobs: add base ApplicationJob.
This commit is contained in:
8
app/jobs/application_job.rb
Normal file
8
app/jobs/application_job.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
queue_as :default
|
||||
queue_with_priority 0
|
||||
|
||||
discard_on ActiveJob::DeserializationError do |job, error|
|
||||
DanbooruLogger.log(error)
|
||||
end
|
||||
end
|
||||
@@ -62,7 +62,7 @@ Rails.application.configure do
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||
# config.active_job.queue_adapter = :resque
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
# config.active_job.queue_name_prefix = "danbooru_#{Rails.env}"
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
22
test/jobs/application_job_test.rb
Normal file
22
test/jobs/application_job_test.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TestJob < ApplicationJob
|
||||
def perform(record); end
|
||||
end
|
||||
|
||||
class ApplicationJobTest < ActiveJob::TestCase
|
||||
context "An active job" do
|
||||
should "discard and log jobs with deserialization errors" do
|
||||
DanbooruLogger.expects(:log)
|
||||
|
||||
assert_nothing_raised do
|
||||
perform_enqueued_jobs do
|
||||
tag = create(:tag, name: "tagme")
|
||||
tag.delete
|
||||
|
||||
TestJob.perform_later(tag)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user