Skip to content

Send email with attachment exporting work items as CSV

Felipe Cardozo requested to merge issue_379082-email_work_items_csv into master

What does this MR do and why?

We did add the ability to parse work items as CSV with !110567 (merged), now this MR allows to send the CSV file as an attachment to the user.

It basically uses the same email to export issues for work items, just replacing the words on the subject and text body.

In a follow-up MR we will support exporting work items as CSV from a GraphQL mutation.

Screenshots or screen recordings

I did emulate a truncated email with more work items than it is possible to export so we can check how the truncated message looks. I also included a custom header, footer and additional text from admin panel.

Export email as html

work_items_html

Export email as text

work_items_text

How to set up and validate locally

  1. Create a project and create 1 requirement, 1 issue and 1 incident
  2. Go to the rails console and execute the following script:
p = Project.find_by_full_path(PROJECT_PATH)
relation = WorkItem.where(project: p) # For some reason we do not have this relationship on Project
WorkItems::ExportCsvService.new(relation, p).email(User.first)
  1. Use letter opener on http://127.0.0.1:3000/rails/letter_opener/ and check the email and the attachment.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Felipe Cardozo

Merge request reports

Loading