diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 79e09cd7..04d0c220 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -104,10 +104,10 @@ namespace :assets do end def delete_and_update_draft asset - asset.state = "uploaded" if asset.state.to_s == "deleted" + (asset.state = "uploaded"; puts "Patched state: #{asset.id}") if asset.state.to_s == "deleted" asset.destroy! unless asset.deleted? - asset.parent_document_url = nil if asset.parent_document_url&.include?("draft-origin") + (asset.parent_document_url = nil; puts "Patched Parent URL: #{asset.id}") if asset.parent_document_url&.include?("draft-origin") asset.draft = false asset.save! end diff --git a/spec/lib/tasks/assets_spec.rb b/spec/lib/tasks/assets_spec.rb index 6ddeca3b..06efd7bc 100644 --- a/spec/lib/tasks/assets_spec.rb +++ b/spec/lib/tasks/assets_spec.rb @@ -71,6 +71,7 @@ FactoryBot.create(:asset, id: asset_id, replacement_id: replacement.id) expected_output = <<~OUTPUT + Patched Parent URL: #{replacement.id} Asset ID: #{asset_id} - OK. Draft replacement #{replacement.id} deleted and updated to false. OUTPUT expect { task.invoke(filepath) }.to output(expected_output).to_stdout @@ -99,6 +100,7 @@ replacement.save(validate: false) expected_output = <<~OUTPUT + Patched state: #{replacement.id} Asset ID: #{asset_id} - OK. Draft replacement #{replacement.id} deleted and updated to false. OUTPUT expect { task.invoke(filepath) }.to output(expected_output).to_stdout @@ -124,6 +126,7 @@ FactoryBot.create(:asset, replacement_id: asset.id) expected_output = <<~OUTPUT + Patched Parent URL: #{asset_id} Asset ID: #{asset_id} - is a replacement. Asset deleted and updated to false. OUTPUT expect { task.invoke(filepath) }.to output(expected_output).to_stdout @@ -152,6 +155,7 @@ asset.save(validate: false) expected_output = <<~OUTPUT + Patched state: #{asset_id} Asset ID: #{asset_id} - is a replacement. Asset deleted and updated to false. OUTPUT expect { task.invoke(filepath) }.to output(expected_output).to_stdout