Browse Source
# Context - https://digital.dclg.gov.uk/jira/browse/CLDC-2305 - This is rework to add missing validations for sales setup fields for bulk upload # Changes - There is code that clears log fields if they are not a valid option. in order to generate errors for these we check certain fields for content prior to `log.valid?` being called. Unfortunately there does not appear to be an easy way to access to valid options therefore these values have been hard coded - Privacy notice must be accepted other considered a setup error - The `type` question can actually be one of three questions with the same identifier. these are excluded as part of `validate_valid_radio_option` and instead validated with a different mechanism. The rationale being that `log.valid?` will clear data before we get there - Remove tests associated to upload threshold which are no longer requiredpull/1655/head
Phil Lee
2 years ago
committed by
GitHub
15 changed files with 512 additions and 107 deletions
@ -1,6 +1,7 @@
|
||||
class BulkUploadError < ApplicationRecord |
||||
belongs_to :bulk_upload |
||||
|
||||
scope :order_by_row, -> { order(row: :asc) } |
||||
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,39 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe "bulk_upload_sales_results/show.html.erb" do |
||||
let(:bulk_upload) { create(:bulk_upload, :sales) } |
||||
|
||||
context "when mutiple rows in wrong order" do |
||||
before do |
||||
create(:bulk_upload_error, bulk_upload:, cell: "C14", row: "14", col: "C") |
||||
create(:bulk_upload_error, bulk_upload:, cell: "D10", row: "10", col: "D") |
||||
end |
||||
|
||||
it "renders errors order by row" do |
||||
assign(:bulk_upload, bulk_upload) |
||||
|
||||
render |
||||
|
||||
fragment = Capybara::Node::Simple.new(rendered) |
||||
|
||||
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"]) |
||||
end |
||||
end |
||||
|
||||
context "when 1 row with 2 errors" do |
||||
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 |
||||
end |
@ -0,0 +1,39 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe "bulk_upload_sales_results/summary.html.erb" do |
||||
let(:bulk_upload) { create(:bulk_upload, :sales) } |
||||
|
||||
context "when mutiple rows in wrong order" do |
||||
before do |
||||
create(:bulk_upload_error, bulk_upload:, cell: "C14", row: "14", col: "C") |
||||
create(:bulk_upload_error, bulk_upload:, cell: "D10", row: "10", col: "D") |
||||
end |
||||
|
||||
it "renders errors order by row" do |
||||
assign(:bulk_upload, bulk_upload) |
||||
|
||||
render |
||||
|
||||
fragment = Capybara::Node::Simple.new(rendered) |
||||
|
||||
expect(fragment.find_css(".x-govuk-summary-card__title strong").map(&:inner_text)).to eql(["Row 10", "Row 14"]) |
||||
end |
||||
end |
||||
|
||||
context "when 1 row with 2 errors" do |
||||
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 |
||||
end |
Loading…
Reference in new issue