Skip to content

Work item import - email type errors

What does this MR do and why?

Dependent on !112271 (merged) and this branch is based on that one.

In !112271 (merged) we introduced specifying a work item type of Issue or Requirement when importing work items. The emails were created in !112003 (merged) and this MR updates the emails to also display preprocessing errors.

Screenshots or screen recordings

Old screencaps can be found in !112003 (merged)

Scenario console Previous This MR
Successful, no errors Notify.import_work_items_csv_email(user.id, project.id, {success: 43, parse_error: false}).deliver! image image
Successful, invalid record errors Notify.import_work_items_csv_email(user.id, project.id, {success: 43, parse_error: false, error_lines: [27, 29, 45]}).deliver! image image
Unsuccessful, parse error Notify.import_work_items_csv_email(user.id, project.id, {success: 0, parse_error: true}).deliver! image image
Unsuccessful, blank work item type Notify.import_work_items_csv_email(user.id, project.id, {success: 0, parse_error: false, type_errors: { blank: [6,7,10], missing: [], disallowed: []}}).deliver! n/a image
Unsuccessful, missing work item type Notify.import_work_items_csv_email(user.id, project.id, {success: 0, parse_error: false, type_errors: { blank: [], missing: [6,7,10], disallowed: []}}).deliver! n/a image
Unsuccessful, multiple work item type failures Notify.import_work_items_csv_email(user.id, project.id, {success: 0, parse_error: false, type_errors: { blank: [], missing: [6,7,10], disallowed: [9,15]}}).deliver! n/a image

(yes, some of the console numbers don't match but you get the idea 😸 )

How to set up and validate locally

the more integration test kind of way

In console:

project = Project.find(1)
user = User.find(1) # user with sufficient access to project
Feature.enable(:import_work_items_csv)
csv_io = FileUploader.new(project)
csv_io.store!(File.open("/path/to/work_items.csv"))
service = ::WorkItems::ImportCsvService.new(user, project, csv_io)
service.execute

the console cheat way

You can also just check the mail bit by feeding it a project and some fake results in console:

project = Project.find(1)
user = User.find(1) # any user, at this level it does not care about auth, only which email to send to
Notify.import_work_items_csv_email(user.id, project.id, {success: 0, parse_error: false, type_errors: { blank: [], missing: [4,5], disallowed: [6]}}).deliver!

Check the letter_opener for incoming mail. 👉 http://gdk.test:3443/rails/letter_opener.

You can see the text versions by clicking the plaintext link in the top right hand corner of each mail.

the most superficial but also maybe most fun way

You can also view sample mailer with fake info in http://localhost:3000/rails/mailers/notify/import_work_items_csv_email. If you play with the values on your local in app/mailers/previews/notify_preview.rb you can preview different what different values will look like.

MR acceptance checklist

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

Related to #379153 (closed)

Edited by charlie ablett

Merge request reports