jobs: migrate pool category updates to ActiveJob.
This commit is contained in:
8
app/jobs/update_pool_pseudo_tags_job.rb
Normal file
8
app/jobs/update_pool_pseudo_tags_job.rb
Normal 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
|
||||||
@@ -291,7 +291,7 @@ class Pool < ApplicationRecord
|
|||||||
|
|
||||||
def update_category_pseudo_tags_for_posts_async
|
def update_category_pseudo_tags_for_posts_async
|
||||||
if saved_change_to_category?
|
if saved_change_to_category?
|
||||||
delay(:queue => "default").update_category_pseudo_tags_for_posts
|
UpdatePoolPseudoTagsJob.perform_later(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -267,8 +267,10 @@ class PoolTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "allow Builders to change the category of large pools" do
|
should "allow Builders to change the category of large pools" do
|
||||||
@builder = FactoryBot.create(:builder_user)
|
perform_enqueued_jobs do
|
||||||
as(@builder) { @pool.update(category: "collection") }
|
@builder = create(:builder_user)
|
||||||
|
as(@builder) { @pool.update(category: "collection") }
|
||||||
|
end
|
||||||
|
|
||||||
assert_equal(true, @pool.valid?)
|
assert_equal(true, @pool.valid?)
|
||||||
assert_equal("collection", @pool.category)
|
assert_equal("collection", @pool.category)
|
||||||
|
|||||||
Reference in New Issue
Block a user