jobs: migrate mass updates to ActiveJob.

Also fixes a bug where mod actions weren't logged on mass updates.
Creating the mod action silently failed because it was called when
CurrentUser wasn' set.
This commit is contained in:
evazion
2019-08-19 00:46:31 -05:00
parent 48488d04db
commit dab43d96c9
7 changed files with 144 additions and 162 deletions

View File

@@ -64,15 +64,17 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
context "on approval" do
setup do
@post = create(:post, tag_string: "foo aaa")
@script = %q(
create alias foo -> bar
create implication bar -> baz
mass update aaa -> bbb
)
@bur = FactoryBot.create(:bulk_update_request, :script => @script)
@bur.approve!(@admin)
assert_enqueued_jobs(2)
assert_enqueued_jobs(3)
workoff_active_jobs
@ta = TagAlias.where(:antecedent_name => "foo", :consequent_name => "bar").first
@@ -92,6 +94,10 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
assert_equal("active", @ti.status)
end
should "process mass updates" do
assert_equal("bar baz bbb", @post.reload.tag_string)
end
should "set the alias/implication approvers" do
assert_equal(@admin.id, @ta.approver.id)
assert_equal(@admin.id, @ti.approver.id)