Browse Source

Deletion report sales bug fix (#2235)

* feat: don't display error row components for rows with no errors

* feat: add failing test for bug

* feat: remove redundant condition
pull/2238/head v0.4.15
natdeanlewissoftwire 11 months ago committed by GitHub
parent
commit
90cfedb0e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/views/bulk_upload_lettings_resume/deletion_report.html.erb
  2. 4
      app/views/bulk_upload_sales_resume/deletion_report.html.erb
  3. 17
      spec/requests/bulk_upload_lettings_resume_controller_spec.rb
  4. 17
      spec/requests/bulk_upload_sales_resume_controller_spec.rb

4
app/views/bulk_upload_lettings_resume/deletion_report.html.erb

@ -18,7 +18,9 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-full"> <div class="govuk-grid-column-full">
<% @bulk_upload.bulk_upload_errors.order_by_row.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %> <% @bulk_upload.bulk_upload_errors.order_by_row.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %>
<%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: all_answers_to_be_cleared(errors_for_row)) %> <% if all_answers_to_be_cleared(errors_for_row).present? %>
<%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: all_answers_to_be_cleared(errors_for_row)) %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

4
app/views/bulk_upload_sales_resume/deletion_report.html.erb

@ -18,7 +18,9 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-full"> <div class="govuk-grid-column-full">
<% @bulk_upload.bulk_upload_errors.order_by_row.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %> <% @bulk_upload.bulk_upload_errors.order_by_row.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %>
<%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: all_answers_to_be_cleared(errors_for_row)) %> <% if all_answers_to_be_cleared(errors_for_row).present? %>
<%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: all_answers_to_be_cleared(errors_for_row)) %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

17
spec/requests/bulk_upload_lettings_resume_controller_spec.rb

@ -211,5 +211,22 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do
expect(response).to redirect_to("/lettings-logs/bulk-upload-soft-validations-check/#{bulk_upload.id}/chosen") expect(response).to redirect_to("/lettings-logs/bulk-upload-soft-validations-check/#{bulk_upload.id}/chosen")
end end
end end
context "and has a row with all non-cleared errors" do
let(:bulk_upload_errors) { [create(:bulk_upload_error, row: 1), create(:bulk_upload_error, row: 2, category: :not_answered), create(:bulk_upload_error, row: 3, category: :soft_validation), create(:bulk_upload_error, row: 4)] }
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, bulk_upload_errors:) }
it "renders the page correctly" do
get "/lettings-logs/bulk-upload-resume/#{bulk_upload.id}/deletion-report"
expect(response).to be_successful
expect(response.body).to include("Bulk upload for lettings")
expect(response.body).to include("2023/24")
expect(response.body).to include("These 2 answers will be deleted if you upload the log")
expect(response.body).to include(bulk_upload.filename)
expect(response.body).to include("Clear this data and upload the logs")
end
end
end end
end end

17
spec/requests/bulk_upload_sales_resume_controller_spec.rb

@ -211,5 +211,22 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do
expect(response).to redirect_to("/sales-logs/bulk-upload-soft-validations-check/#{bulk_upload.id}/chosen") expect(response).to redirect_to("/sales-logs/bulk-upload-soft-validations-check/#{bulk_upload.id}/chosen")
end end
end end
context "and has a row with all non-cleared errors" do
let(:bulk_upload_errors) { [create(:bulk_upload_error, row: 1), create(:bulk_upload_error, row: 2, category: :not_answered), create(:bulk_upload_error, row: 3, category: :soft_validation), create(:bulk_upload_error, row: 4)] }
let(:bulk_upload) { create(:bulk_upload, :sales, user:, bulk_upload_errors:) }
it "renders the page correctly" do
get "/sales-logs/bulk-upload-resume/#{bulk_upload.id}/deletion-report"
expect(response).to be_successful
expect(response.body).to include("Bulk upload for sales")
expect(response.body).to include("2023/24")
expect(response.body).to include("These 2 answers will be deleted if you upload the log")
expect(response.body).to include(bulk_upload.filename)
expect(response.body).to include("Clear this data and upload the logs")
end
end
end end
end end

Loading…
Cancel
Save