Commit bba593dd authored by Micaël Bergeron's avatar Micaël Bergeron

fix outputs

parent cbd09793
......@@ -99,6 +99,10 @@ module ObjectStorage
def success?
error.nil?
end
def to_s
success? ? "Migration successful." : "Error while migrating #{upload.id}: #{error.message}"
end
end
module Report
......@@ -124,13 +128,11 @@ module ObjectStorage
end
def header(success, failures)
color = failures.count == 0 ? :green : :red
"Migrated #{success.count}/#{success.count + failures.count} files.".color(color)
"Migrated #{success.count}/#{success.count + failures.count} files."
end
def failures(failures)
failures.map { |f| "\t#{f}".color(:red) }.join('\n')
failures.map { |f| "\t#{f}" }.join('\n')
end
end
......
......@@ -78,7 +78,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
shared_examples 'outputs correctly' do |success: 0, failures: 0|
total = success + failures
if success
if success > 0
it 'outputs the reports' do
expect(Rails.logger).to receive(:info).with(%r{Migrated #{success}/#{total} files})
......@@ -86,7 +86,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
end
end
if failures
if failures > 0
it 'outputs upload failures' do
expect(Rails.logger).to receive(:warn).with(/Error .* I am a teapot/)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment