このコミットが含まれているのは:
2026-09-26 20:23:11 +09:00
コミット 5abb6cca98
39個のファイルの変更、1005行の追加、377行の削除
+10 -1
ファイルの表示
@@ -1,6 +1,8 @@
require 'rails_helper'
RSpec.describe PostBulkCreator do
include_context 'English locale'
it 'limits workers to two and keeps failures in their request slots' do
actor = instance_double(User, id: 123)
allow(User).to receive(:find).with(123) {
@@ -9,6 +11,7 @@ RSpec.describe PostBulkCreator do
mutex = Mutex.new
active = 0
maximum_active = 0
creators = []
allow(PostCreatePreflight).to receive(:new) do |attributes:, **|
preflight = instance_double(PostCreatePreflight)
@@ -28,6 +31,7 @@ RSpec.describe PostBulkCreator do
end
allow(PostCreator).to receive(:new) do |attributes:, **|
creator = instance_double(PostCreator)
mutex.synchronize { creators << creator }
if attributes[:title] == 'broken'
allow(creator).to receive(:create!).and_raise(StandardError, 'broken')
else
@@ -45,7 +49,12 @@ RSpec.describe PostBulkCreator do
results = described_class.new(
actor:,
posts:,
thumbnails: { }).run.fetch(:results)
thumbnails: { }).run(locale).fetch(:results)
expect(creators.length).to eq(posts.length)
creators.each do |creator|
expect(creator).to have_received(:create!).with(locale).once
end
expect(maximum_active).to eq(2)
expect(results.length).to eq(posts.length)