Browse Source
# Context - https://digital.dclg.gov.uk/jira/browse/CLDC-2184 - bulk upload error reports were not sorting by cells correctly # Changes - there was an issue where `Z100` would come after `AA100` which is not correct - fix ordering issue above - also made change so this is now delegated to the database rather than sorting in rubypull/1548/head
Phil Lee
2 years ago
committed by
GitHub
6 changed files with 27 additions and 26 deletions
@ -1,3 +1,6 @@
|
||||
class BulkUploadError < ApplicationRecord |
||||
belongs_to :bulk_upload |
||||
|
||||
scope :order_by_cell, -> { order(Arel.sql("LPAD(cell, 10, '0')")) } |
||||
scope :order_by_col, -> { order(Arel.sql("LPAD(col, 10, '0')")) } |
||||
end |
||||
|
@ -0,0 +1,20 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe "bulk_upload_lettings_results/show.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 |
Loading…
Reference in new issue