Browse Source

show full error report if not enough errors

- if errors summary table is empty as below threshold
- send users to full report
- remove the back button so they cannot access summary report
pull/1347/head
Phil Lee 3 years ago
parent
commit
46785effe6
  1. 8
      app/mailers/bulk_upload_mailer.rb
  2. 4
      app/views/bulk_upload_lettings_results/show.html.erb
  3. 4
      spec/mailers/bulk_upload_mailer_spec.rb

8
app/mailers/bulk_upload_mailer.rb

@ -46,6 +46,12 @@ class BulkUploadMailer < NotifyMailer
def send_correct_and_upload_again_mail(bulk_upload:) def send_correct_and_upload_again_mail(bulk_upload:)
error_description = "We noticed that you have a lot of similar errors in column #{columns_with_errors(bulk_upload:)}. Please correct your data export and upload again." error_description = "We noticed that you have a lot of similar errors in column #{columns_with_errors(bulk_upload:)}. Please correct your data export and upload again."
summary_report_link = if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors?
summary_bulk_upload_lettings_result_url(bulk_upload)
else
bulk_upload_lettings_result_url(bulk_upload)
end
send_email( send_email(
bulk_upload.user.email, bulk_upload.user.email,
BULK_UPLOAD_FAILED_CSV_ERRORS_TEMPLATE_ID, BULK_UPLOAD_FAILED_CSV_ERRORS_TEMPLATE_ID,
@ -55,7 +61,7 @@ class BulkUploadMailer < NotifyMailer
year_combo: bulk_upload.year_combo, year_combo: bulk_upload.year_combo,
lettings_or_sales: bulk_upload.log_type, lettings_or_sales: bulk_upload.log_type,
error_description:, error_description:,
summary_report_link: summary_bulk_upload_lettings_result_url(bulk_upload), summary_report_link:,
}, },
) )
end end

4
app/views/bulk_upload_lettings_results/show.html.erb

@ -1,5 +1,7 @@
<% content_for :before_content do %> <% if BulkUploadErrorSummaryTableComponent.new(bulk_upload: @bulk_upload).errors? %>
<% content_for :before_content do %>
<%= govuk_back_link(text: "Back", href: summary_bulk_upload_lettings_result_path(@bulk_upload)) %> <%= govuk_back_link(text: "Back", href: summary_bulk_upload_lettings_result_path(@bulk_upload)) %>
<% end %>
<% end %> <% end %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">

4
spec/mailers/bulk_upload_mailer_spec.rb

@ -93,7 +93,7 @@ RSpec.describe BulkUploadMailer do
year_combo: bulk_upload.year_combo, year_combo: bulk_upload.year_combo,
lettings_or_sales: bulk_upload.log_type, lettings_or_sales: bulk_upload.log_type,
error_description: "We noticed that you have a lot of similar errors in column A, B. Please correct your data export and upload again.", error_description: "We noticed that you have a lot of similar errors in column A, B. Please correct your data export and upload again.",
summary_report_link: "http://localhost:3000/lettings-logs/bulk-upload-results/#{bulk_upload.id}/summary", summary_report_link: "http://localhost:3000/lettings-logs/bulk-upload-results/#{bulk_upload.id}",
}, },
) )
@ -103,6 +103,8 @@ RSpec.describe BulkUploadMailer do
context "when 4 columns with errors" do context "when 4 columns with errors" do
before do before do
stub_const("BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD", 0)
create(:bulk_upload_error, bulk_upload:, col: "A") create(:bulk_upload_error, bulk_upload:, col: "A")
create(:bulk_upload_error, bulk_upload:, col: "B") create(:bulk_upload_error, bulk_upload:, col: "B")
create(:bulk_upload_error, bulk_upload:, col: "C") create(:bulk_upload_error, bulk_upload:, col: "C")

Loading…
Cancel
Save