From 210a25eaf5db6e7fc0ff65432dc4589131174436 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Wed, 19 Apr 2023 15:03:36 +0100 Subject: [PATCH] fix bulk upload summary error ordering (#1562) --- .../summary.html.erb | 2 +- .../summary.html.erb_spec.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb diff --git a/app/views/bulk_upload_lettings_results/summary.html.erb b/app/views/bulk_upload_lettings_results/summary.html.erb index 533e2af05..51aa652f8 100644 --- a/app/views/bulk_upload_lettings_results/summary.html.erb +++ b/app/views/bulk_upload_lettings_results/summary.html.erb @@ -20,7 +20,7 @@ <% end %> <% c.with_tab(label: "Full error report") do %> - <% @bulk_upload.bulk_upload_errors.group_by(&:row).each do |_row, errors_for_row| %> + <% @bulk_upload.bulk_upload_errors.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %> <%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row) %> <% end %> <% end %> diff --git a/spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb b/spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb new file mode 100644 index 000000000..25499133d --- /dev/null +++ b/spec/views/bulk_upload_lettings_results/summary.html.erb_spec.rb @@ -0,0 +1,20 @@ +require "rails_helper" + +RSpec.describe "bulk_upload_lettings_results/summary.html.erb" do + let(:bulk_upload) { create(:bulk_upload, :lettings) } + + before do + create(:bulk_upload_error, bulk_upload:, cell: "AA100", row: "100", col: "AA") + create(:bulk_upload_error, bulk_upload:, cell: "Z100", row: "100", col: "Z") + end + + it "renders errors ordered by cell" do + assign(:bulk_upload, bulk_upload) + + render + + fragment = Capybara::Node::Simple.new(rendered) + + expect(fragment.find_css("table tbody th").map(&:inner_text)).to eql(%w[Z100 AA100]) + end +end