diff --git a/app/jobs/regular/export_user_archive.rb b/app/jobs/regular/export_user_archive.rb index 3295f7aaf32..73ce107426b 100644 --- a/app/jobs/regular/export_user_archive.rb +++ b/app/jobs/regular/export_user_archive.rb @@ -112,7 +112,7 @@ module Jobs if upload.persisted? user_export.update_columns(upload_id: upload.id) else - Rails.logger.warn("Failed to upload the file #{zip_filename}") + Rails.logger.warn("Failed to upload the file #{zip_filename}: #{upload.errors.full_messages}") end end @@ -485,7 +485,7 @@ module Jobs post = nil if @current_user - post = if upload + post = if upload.persisted? SystemMessage.create_from_system_user( @current_user, :csv_export_succeeded, diff --git a/spec/jobs/export_user_archive_spec.rb b/spec/jobs/export_user_archive_spec.rb index 5db43f10600..3387a7144d8 100644 --- a/spec/jobs/export_user_archive_spec.rb +++ b/spec/jobs/export_user_archive_spec.rb @@ -92,6 +92,19 @@ describe Jobs::ExportUserArchive do expect(files.find { |f| f == 'user_archive.csv' }).to_not be_nil expect(files.find { |f| f == 'category_preferences.csv' }).to_not be_nil end + + it 'sends a message if it fails' do + SiteSetting.max_export_file_size_kb = 1 + + expect do + Jobs::ExportUserArchive.new.execute( + user_id: user.id, + ) + end.to change { Upload.count }.by(0) + + system_message = user.topics_allowed.last + expect(system_message.title).to eq(I18n.t("system_messages.csv_export_failed.subject_template")) + end end context 'user_archive posts' do