From e9f91a36e9892e00dfc055bb382b67854152b27d Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 17 Jun 2019 15:01:23 +0200 Subject: [PATCH] [bug] prevent task migrate_pdf_invoices_folders from raising an error when run with no invoices --- CHANGELOG.md | 3 ++- lib/tasks/fablab/setup.rake | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f3db7acb..856b6e10e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog Fab Manager -- Fix a bug : cookie consent modal is not shown +- Fix a bug: cookie consent modal is not shown +- Fix a bug: prevent task migrate_pdf_invoices_folders from raising an error when run with no invoices ## v4.0.0 2019 June 17 diff --git a/lib/tasks/fablab/setup.rake b/lib/tasks/fablab/setup.rake index 2a96ce485..7991f40c6 100644 --- a/lib/tasks/fablab/setup.rake +++ b/lib/tasks/fablab/setup.rake @@ -82,6 +82,8 @@ namespace :fablab do desc 'migrate PDF invoices to folders numbered by invoicing_profile' task migrate_pdf_invoices_folders: :environment do + puts 'No invoices, exiting...' and return if Invoice.count.zero? + require 'fileutils' Invoice.all.each do |i| invoicing_profile = i.invoicing_profile