jobs: migrate pool category updates to ActiveJob.

This commit is contained in:
evazion
2019-08-16 20:49:34 -05:00
parent 4e8b3d9310
commit 24eb1b155f
3 changed files with 13 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
class UpdatePoolPseudoTagsJob < ApplicationJob
queue_as :default
queue_with_priority 20
def perform(pool)
pool.update_category_pseudo_tags_for_posts
end
end

View File

@@ -291,7 +291,7 @@ class Pool < ApplicationRecord
def update_category_pseudo_tags_for_posts_async
if saved_change_to_category?
delay(:queue => "default").update_category_pseudo_tags_for_posts
UpdatePoolPseudoTagsJob.perform_later(self)
end
end

View File

@@ -267,8 +267,10 @@ class PoolTest < ActiveSupport::TestCase
end
should "allow Builders to change the category of large pools" do
@builder = FactoryBot.create(:builder_user)
as(@builder) { @pool.update(category: "collection") }
perform_enqueued_jobs do
@builder = create(:builder_user)
as(@builder) { @pool.update(category: "collection") }
end
assert_equal(true, @pool.valid?)
assert_equal("collection", @pool.category)