From 681a89f684a54f2686324ecfddca250356da338b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 14 Mar 2024 05:24:00 -0400 Subject: [PATCH] Readability clean up in `ImportVacuum` spec (#28955) --- spec/lib/vacuum/imports_vacuum_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/lib/vacuum/imports_vacuum_spec.rb b/spec/lib/vacuum/imports_vacuum_spec.rb index c712b7b9b26..3a273d82763 100644 --- a/spec/lib/vacuum/imports_vacuum_spec.rb +++ b/spec/lib/vacuum/imports_vacuum_spec.rb @@ -13,7 +13,26 @@ RSpec.describe Vacuum::ImportsVacuum do describe '#perform' do it 'cleans up the expected imports' do - expect { subject.perform }.to change { BulkImport.pluck(:id) }.from([old_unconfirmed, new_unconfirmed, recent_ongoing, recent_finished, old_finished].map(&:id)).to([new_unconfirmed, recent_ongoing, recent_finished].map(&:id)) + expect { subject.perform } + .to change { ordered_bulk_imports.pluck(:id) } + .from(original_import_ids) + .to(remaining_import_ids) + end + + def ordered_bulk_imports + BulkImport.order(id: :asc) + end + + def original_import_ids + [old_unconfirmed, new_unconfirmed, recent_ongoing, recent_finished, old_finished].map(&:id) + end + + def vacuumed_import_ids + [old_unconfirmed, old_finished].map(&:id) + end + + def remaining_import_ids + original_import_ids - vacuumed_import_ids end end end