Skip to content

Commit

Permalink
Allow republishing all documents via service
Browse files Browse the repository at this point in the history
The code here is taken from the equivalent Rake task, which will be
deleted once all the tasks have been added to the bulk republishing UI
  • Loading branch information
yndajas committed May 30, 2024
1 parent 3de13ef commit b41e30f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/services/bulk_republisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ def republish_all_organisation_about_us_pages
)
end
end

def republish_all_documents
Document.find_each do |document|
PublishingApiDocumentRepublishingWorker.perform_async_in_queue("bulk_republishing", document.id, true)
end
end
end
17 changes: 17 additions & 0 deletions test/unit/app/services/bulk_republisher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ class BulkRepublisherTest < ActiveSupport::TestCase
BulkRepublisher.new.republish_all_organisation_about_us_pages
end
end

describe "#republish_all_documents" do
test "queues all documents for republishing" do
queue_sequence = sequence("queue")

2.times do
document = create(:document)

PublishingApiDocumentRepublishingWorker
.expects(:perform_async_in_queue)
.with("bulk_republishing", document.id, true)
.in_sequence(queue_sequence)
end

BulkRepublisher.new.republish_all_documents
end
end
end

0 comments on commit b41e30f

Please sign in to comment.