diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 86a04ae4..1f59fb11 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -51,12 +51,16 @@ namespace :assets do end end - desc "Bulk fix assets" namespace :bulk_fix do + desc "Bulk fix assets" task :update_replacement_draft, %i[csv_path] => :environment do |_t, args| csv_path = args.fetch(:csv_path) CSV.foreach(csv_path, headers: false) do |row| - puts row[1] + original_asset_id = row[0] + original_asset = Asset.find(original_asset_id) + # replacement_asset = original_asset.replacement + "Asset ID: abc123def456ghi789 - SKIPPED. No replacement asset found." + puts row[0] end end end diff --git a/spec/lib/tasks/assets_spec.rb b/spec/lib/tasks/assets_spec.rb index 620248df..43fa5c64 100644 --- a/spec/lib/tasks/assets_spec.rb +++ b/spec/lib/tasks/assets_spec.rb @@ -41,8 +41,6 @@ ) end - # TODO: add batch parameter tests - # 80k assets in this category - we're updating their replacements (replacements are expected to be in draft and deleted) describe "assets:bulk_fix:update_replacement_draft" do let(:task) { Rake::Task["assets:bulk_fix:update_replacement_draft"] } @@ -93,6 +91,7 @@ end it "skips the asset and print exception if asset is not found" do + byebug expected_output = <<~OUTPUT "Asset ID: #{asset_id} - SKIPPED. No asset found." OUTPUT @@ -103,11 +102,16 @@ replacement = FactoryBot.create(:asset) FactoryBot.create(:asset, id: asset_id, replacement_id: replacement.id) replacement.delete + expected_output = <<~OUTPUT "Asset ID: #{asset_id} - SKIPPED. No replacement asset found." OUTPUT expect { task.invoke(filepath) }.to output(expected_output).to_stdout end + + # TODO: add batch parameter tests + # it "should start from where last left off if kicked" do + # end end # 30k assets in this category - we're updating the assets themselves (these are the ones that have AD not deleted and not replaced in WH)