FIX: export csv file failed message (#25443)

When exporting a csv file and the size of the file exceeded the
max_export_file_size_kb it will still send the PM that the export
succeeded with a broken link to a missing export file. This change
ensures that a failed message will be sent instead.
This commit is contained in:
Blake Erickson 2024-01-26 11:16:02 -07:00 committed by GitHub
parent 6b185f8655
commit 7200a41207
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -433,7 +433,7 @@ module Jobs
if @current_user
post =
if upload
if upload&.errors&.empty?
SystemMessage.create_from_system_user(
@current_user,
:csv_export_succeeded,

View File

@ -52,6 +52,26 @@ RSpec.describe Jobs::ExportCsvFile do
admin.uploads.each(&:destroy!)
end
end
it "generates csv export failed message if upload is too large" do
action_log
SiteSetting.max_export_file_size_kb = 0
begin
Jobs::ExportCsvFile.new.execute(user_id: admin.id, entity: "staff_action")
system_message = admin.topics_allowed.last
expect(system_message.title).to eq(
I18n.t(
"system_messages.csv_export_failed.subject_template",
export_title: "Data export failed",
),
)
ensure
admin.uploads.each(&:destroy!)
end
end
end
describe ".report_export" do