Browse Source

show summary when on error threshold

pull/1520/head
Phil Lee 3 years ago
parent
commit
01661b8627
  1. 4
      app/components/bulk_upload_error_summary_table_component.rb
  2. 2
      app/views/bulk_upload_lettings_results/summary.html.erb
  3. 13
      spec/components/bulk_upload_error_summary_table_component_spec.rb

4
app/components/bulk_upload_error_summary_table_component.rb

@ -15,7 +15,7 @@ class BulkUploadErrorSummaryTableComponent < ViewComponent::Base
@sorted_errors ||= setup_errors.presence || bulk_upload @sorted_errors ||= setup_errors.presence || bulk_upload
.bulk_upload_errors .bulk_upload_errors
.group(:col, :field, :error) .group(:col, :field, :error)
.having("count(*) > ?", display_threshold) .having("count(*) >= ?", display_threshold)
.count .count
.sort_by { |el| el[0][0].rjust(3, "0") } .sort_by { |el| el[0][0].rjust(3, "0") }
end end
@ -31,7 +31,7 @@ private
.bulk_upload_errors .bulk_upload_errors
.where(category: "setup") .where(category: "setup")
.group(:col, :field, :error) .group(:col, :field, :error)
.having("count(*) > ?", display_threshold) .having("count(*) >= ?", display_threshold)
.count .count
.sort_by { |el| el[0][0].rjust(3, "0") } .sort_by { |el| el[0][0].rjust(3, "0") }
end end

2
app/views/bulk_upload_lettings_results/summary.html.erb

@ -17,7 +17,7 @@
<%= govuk_tabs(title: "Error reports") do |c| %> <%= govuk_tabs(title: "Error reports") do |c| %>
<% c.with_tab(label: "Summary") do %> <% c.with_tab(label: "Summary") do %>
<p class="govuk-body"> <p class="govuk-body">
This summary shows questions that have at least <%= BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD %> errors or more. See full error report for more details. This summary shows questions that have more than <%= BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD - 1 %> errors. See full error report for more details.
</p> </p>
<%= render BulkUploadErrorSummaryTableComponent.new(bulk_upload: @bulk_upload) %> <%= render BulkUploadErrorSummaryTableComponent.new(bulk_upload: @bulk_upload) %>

13
spec/components/bulk_upload_error_summary_table_component_spec.rb

@ -30,6 +30,19 @@ RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do
end end
end end
context "when on threshold" do
before do
stub_const("BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD", 1)
create(:bulk_upload_error, bulk_upload:, col: "A", row: 1)
end
it "renders tables" do
result = render_inline(component)
expect(result).to have_selector("table", count: 1)
end
end
context "when there are 2 independent errors" do context "when there are 2 independent errors" do
let!(:error_2) { create(:bulk_upload_error, bulk_upload:, col: "B", row: 2) } let!(:error_2) { create(:bulk_upload_error, bulk_upload:, col: "B", row: 2) }
let!(:error_1) { create(:bulk_upload_error, bulk_upload:, col: "A", row: 1) } let!(:error_1) { create(:bulk_upload_error, bulk_upload:, col: "A", row: 1) }

Loading…
Cancel
Save