Browse Source

CLDC-2494 Add duplicate logs page (#1763)

* CLDC-2494: WIP

* CLDC-2494: wip

* CLDC-2494: page work in progress

* cleanup

* Add a path for duplicate logs

* Display all duplicate logs

* Move a test

* Display duplicate check answers for logs

* Add buttons to delete duplicates

* Add a route for sales logs duplicates

* Update duplicated page to work for sales logs

* Update styling

* lint

* Add auth

* Rebase updates

* Remove propcode from dedulication checks

* Update fields to work with supported housing

* Trigger duplicate log check on buyer 1 age not known

* compare correct charges

* Update displayed questions

* BU test

* Put redirect to duplicate logs path behind a feature flag

* More BU tests

---------

Co-authored-by: Kat <katrina@kosiak.co.uk>
pull/1767/head
Aaron Spencer 1 year ago committed by GitHub
parent
commit
3fc5a68a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 50
      app/controllers/duplicate_logs_controller.rb
  2. 10
      app/controllers/form_controller.rb
  3. 2
      app/helpers/tag_helper.rb
  4. 14
      app/models/lettings_log.rb
  5. 8
      app/models/sales_log.rb
  6. 3
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  7. 3
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  8. 4
      app/services/feature_toggle.rb
  9. 26
      app/views/duplicate_logs/_duplicate_log.html.erb
  10. 39
      app/views/duplicate_logs/_duplicate_log_check_answers.erb
  11. 20
      app/views/duplicate_logs/show.erb
  12. 2
      config/routes.rb
  13. 39
      spec/models/lettings_log_spec.rb
  14. 27
      spec/models/sales_log_spec.rb
  15. 112
      spec/requests/duplicate_logs_controller_spec.rb
  16. 48
      spec/requests/form_controller_spec.rb
  17. 2
      spec/services/bulk_upload/lettings/validator_spec.rb
  18. 3
      spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb
  19. 3
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

50
app/controllers/duplicate_logs_controller.rb

@ -0,0 +1,50 @@
class DuplicateLogsController < ApplicationController
before_action :authenticate_user!
before_action :find_resource_by_named_id
def show
if @log
@duplicate_logs = if @log.lettings?
current_user.lettings_logs.duplicate_logs(@log)
else
current_user.sales_logs.duplicate_logs(@log)
end
@all_duplicates = [@log, *@duplicate_logs]
@duplicate_check_questions = duplicate_check_question_ids.map { |question_id|
question = @log.form.get_question(question_id, @log)
question if question.page.routed_to?(@log, current_user)
}.compact
else
render_not_found
end
end
private
def find_resource_by_named_id
@log = if params[:sales_log_id].present?
current_user.sales_logs.visible.find_by(id: params[:sales_log_id])
else
current_user.lettings_logs.visible.find_by(id: params[:lettings_log_id])
end
end
def duplicate_check_question_ids
if @log.lettings?
["owning_organisation_id",
"startdate",
"tenancycode",
"postcode_full",
"scheme_id",
"location_id",
"age1",
"sex1",
"ecstat1",
@log.household_charge == 1 ? "household_charge" : nil,
"tcharge",
@log.is_carehome? ? "chcharge" : nil].compact
else
%w[owning_organisation_id saledate purchid age1 sex1 ecstat1 postcode_full]
end
end
end

10
app/controllers/form_controller.rb

@ -155,6 +155,16 @@ private
end
def successful_redirect_path
if FeatureToggle.deduplication_flow_enabled?
if @log.lettings?
if current_user.lettings_logs.duplicate_logs(@log).count.positive?
return send("lettings_log_duplicate_logs_path", @log)
end
elsif current_user.sales_logs.duplicate_logs(@log).count.positive?
return send("sales_log_duplicate_logs_path", @log)
end
end
if is_referrer_type?("check_answers")
next_page_id = form.next_page_id(@page, @log, current_user)
next_page = form.get_page(next_page_id)

2
app/helpers/tag_helper.rb

@ -12,6 +12,7 @@ module TagHelper
activating_soon: "Activating soon",
reactivating_soon: "Reactivating soon",
deactivated: "Deactivated",
deleted: "Deleted",
}.freeze
COLOUR = {
@ -25,6 +26,7 @@ module TagHelper
activating_soon: "blue",
reactivating_soon: "blue",
deactivated: "grey",
deleted: "red",
}.freeze
def status_tag(status, classes = [])

14
app/models/lettings_log.rb

@ -54,10 +54,18 @@ class LettingsLog < Log
scope :unresolved, -> { where(unresolved: true) }
scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org).or(where(managing_organisation: org)) }
scope :duplicate_logs, lambda { |log|
visible.where(log.slice(*DUPLICATE_LOG_ATTRIBUTES))
visible
.where(log.slice(*DUPLICATE_LOG_ATTRIBUTES))
.where.not(id: log.id)
.where.not("startdate IS NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR tcharge IS NULL OR postcode_full IS NULL OR propcode IS NULL OR needstype IS NULL")
.where.not(startdate: nil)
.where.not(sex1: nil)
.where.not(ecstat1: nil)
.where.not(needstype: nil)
.where("age1 IS NOT NULL OR age1_known = 1")
.where("tcharge IS NOT NULL OR household_charge = 1 OR is_carehome = 1")
.where("chcharge IS NOT NULL OR is_carehome IS NULL OR is_carehome = 0")
.where("location_id = ? OR needstype = 1", log.location_id)
.where("postcode_full = ? OR needstype = 2", log.postcode_full)
}
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
@ -67,7 +75,7 @@ class LettingsLog < Log
NUM_OF_WEEKS_FROM_PERIOD = { 2 => 26, 3 => 13, 4 => 12, 5 => 50, 6 => 49, 7 => 48, 8 => 47, 9 => 46, 1 => 52, 10 => 53 }.freeze
SUFFIX_FROM_PERIOD = { 2 => "every 2 weeks", 3 => "every 4 weeks", 4 => "every month" }.freeze
RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze
DUPLICATE_LOG_ATTRIBUTES = %w[tenancycode propcode startdate age1 sex1 ecstat1 tcharge postcode_full].freeze
DUPLICATE_LOG_ATTRIBUTES = %w[tenancycode startdate age1_known age1 sex1 ecstat1 tcharge household_charge chcharge].freeze
def form
FormHandler.instance.get_form(form_name) || FormHandler.instance.current_lettings_form

8
app/models/sales_log.rb

@ -44,12 +44,16 @@ class SalesLog < Log
scope :duplicate_logs, lambda { |log|
visible.where(log.slice(*DUPLICATE_LOG_ATTRIBUTES))
.where.not(id: log.id)
.where.not("saledate is NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR postcode_full IS NULL")
.where.not(saledate: nil)
.where.not(sex1: nil)
.where.not(ecstat1: nil)
.where.not(postcode_full: nil)
.where("age1 IS NOT NULL OR age1_known = 1 OR age1_known = 2")
}
OPTIONAL_FIELDS = %w[purchid othtype].freeze
RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze
DUPLICATE_LOG_ATTRIBUTES = %w[purchid saledate age1 sex1 ecstat1 postcode_full].freeze
DUPLICATE_LOG_ATTRIBUTES = %w[purchid saledate age1_known age1 sex1 ecstat1 postcode_full].freeze
def lettings?
false

3
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -450,7 +450,6 @@ class BulkUpload::Lettings::Year2022::RowParser
"field_96", # startdate
"field_97", # startdate
"field_98", # startdate
"field_100", # propcode
bulk_upload.needstype != 2 ? "field_108" : nil, # postcode
bulk_upload.needstype != 2 ? "field_109" : nil, # postcode
"field_111", # owning org
@ -525,7 +524,6 @@ private
"ecstat1",
"owning_organisation",
"tcharge",
"propcode",
bulk_upload.needstype != 2 ? "postcode_full" : nil,
bulk_upload.needstype != 1 ? "location" : nil,
].compact
@ -862,7 +860,6 @@ private
errors.add(:field_96, error_message) # startdate
errors.add(:field_97, error_message) # startdate
errors.add(:field_98, error_message) # startdate
errors.add(:field_100, error_message) # propcode
errors.add(:field_108, error_message) if bulk_upload.needstype != 2 # postcode_full
errors.add(:field_109, error_message) if bulk_upload.needstype != 2 # postcode_full
errors.add(:field_111, error_message) # owning_organisation

3
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -464,7 +464,6 @@ class BulkUpload::Lettings::Year2023::RowParser
"field_8", # startdate
"field_9", # startdate
"field_13", # tenancycode
"field_14", # propcode
field_4 != 1 ? "field_17" : nil, # location
field_4 != 2 ? "field_23" : nil, # postcode
field_4 != 2 ? "field_24" : nil, # postcode
@ -561,7 +560,6 @@ private
"ecstat1",
"owning_organisation",
"tcharge",
"propcode",
field_4 != 2 ? "postcode_full" : nil,
field_4 != 1 ? "location" : nil,
"tenancycode",
@ -856,7 +854,6 @@ private
errors.add(:field_8, error_message) # startdate
errors.add(:field_9, error_message) # startdate
errors.add(:field_13, error_message) # tenancycode
errors.add(:field_14, error_message) # propcode
errors.add(:field_17, error_message) if field_4 != 1 # location
errors.add(:field_23, error_message) if field_4 != 2 # postcode_full
errors.add(:field_24, error_message) if field_4 != 2 # postcode_full

4
app/services/feature_toggle.rb

@ -33,4 +33,8 @@ class FeatureToggle
def self.new_data_protection_confirmation?
true
end
def self.deduplication_flow_enabled?
!Rails.env.production?
end
end

26
app/views/duplicate_logs/_duplicate_log.html.erb

@ -0,0 +1,26 @@
<div class="govuk-grid-row govuk-!-padding-top-4">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-third">
<header class="app-log-summary__header">
<h2 class="app-log-summary__title">
<%= govuk_link_to "Log #{log.id}", send("#{log.class.name.underscore}_path", log) %>
</h2>
</header>
</div>
<div class="govuk-grid-column-two-thirds">
<p class="govuk-body">
Created <time datetime="<%= log.created_at.iso8601 %>"><%= log.created_at.to_formatted_s(:govuk_date) %></time>
<% if log.created_by %>
<span class="app-log-summary__footer--actor">Assigned to <%= log.created_by.name || log.created_by.email %></span>
<% end %>
</p>
</div>
</div>
</div>
<div class="govuk-grid-column-one-third app-log-summary__footer">
<p class="govuk-body govuk-!-margin-bottom-2">
<%= status_tag(log.status) %>
</p>
</div>
</div>

39
app/views/duplicate_logs/_duplicate_log_check_answers.erb

@ -0,0 +1,39 @@
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<div class="x-govuk-summary-card__body">
<%= govuk_summary_list do |summary_list| %>
<% @duplicate_check_questions.each do |question| %>
<% summary_list.row do |row| %>
<% row.key { get_question_label(question) } %>
<% row.value do %>
<%= simple_format(
get_answer_label(question, @log),
wrapper_tag: "span",
class: "govuk-!-margin-right-4",
) %>
<% extra_value = question.get_extra_check_answer_value(@log) %>
<% if extra_value && question.answer_label(@log, current_user).present? %>
<%= simple_format(
extra_value,
wrapper_tag: "span",
class: "govuk-!-font-weight-regular app-!-colour-muted",
) %>
<% end %>
<% question.get_inferred_answers(@log).each do |inferred_answer| %>
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= inferred_answer %></span>
<% end %>
<% end %>
<% row.action(
text: question.action_text(@log),
href: action_href(@log, question.page.id),
visually_hidden_text: question.check_answer_label.to_s.downcase,
) %>
<% end %>
<% end %>
<% end %>
</div>
</div>

20
app/views/duplicate_logs/show.erb

@ -0,0 +1,20 @@
<% content_for :title, "Check duplicate logs" %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= govuk_panel(
classes: "app-panel--interruption",
) do %>
<p class="govuk-heading-l">These logs are duplicates</p>
<p class="govuk-body-l">These logs have the same values for the following fields. Choose one to keep or correct the answers.</p>
<% end %>
<% @all_duplicates.each_with_index do |log, index| %>
<%= render partial: "duplicate_log", locals: { log: log } %>
<%= render partial: "duplicate_log_check_answers", locals: { log: log } %>
<%= govuk_button_link_to "Keep this log and delete duplicates", "#" %>
<% if index < @all_duplicates.count - 1 %>
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
<% end %>
<% end %>
</div>
</div>

2
config/routes.rb

@ -170,6 +170,7 @@ Rails.application.routes.draw do
resources :lettings_logs, path: "/lettings-logs" do
get "delete-confirmation", to: "lettings_logs#delete_confirmation"
get "duplicate-logs", to: "duplicate_logs#show"
collection do
post "bulk-upload", to: "bulk_upload#bulk_upload"
@ -235,6 +236,7 @@ Rails.application.routes.draw do
resources :sales_logs, path: "/sales-logs" do
get "delete-confirmation", to: "sales_logs#delete_confirmation"
get "duplicate-logs", to: "duplicate_logs#show"
collection do
get "csv-download", to: "sales_logs#download_csv"

39
spec/models/lettings_log_spec.rb

@ -2862,14 +2862,6 @@ RSpec.describe LettingsLog do
end
end
context "when there is a log with a different propcode" do
let!(:different_propcode) { create(:lettings_log, :duplicate, propcode: "different") }
it "does not return a log with a different propcode as a duplicate" do
expect(described_class.duplicate_logs(log)).not_to include(different_propcode)
end
end
context "when there is a log with a different tenancycode" do
let!(:different_tenancycode) { create(:lettings_log, :duplicate, tenancycode: "different") }
@ -2887,10 +2879,10 @@ RSpec.describe LettingsLog do
end
context "when there is a log with nil values for duplicate check fields" do
let!(:duplicate_check_fields_not_given) { create(:lettings_log, :duplicate, age1: nil, sex1: nil, ecstat1: nil, propcode: nil, postcode_known: 2, postcode_full: nil) }
let!(:duplicate_check_fields_not_given) { create(:lettings_log, :duplicate, age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil) }
it "does not return a log with nil values as a duplicate" do
log.update!(age1: nil, sex1: nil, ecstat1: nil, propcode: nil, postcode_known: 2, postcode_full: nil)
log.update!(age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil)
expect(described_class.duplicate_logs(log)).not_to include(duplicate_check_fields_not_given)
end
end
@ -2904,6 +2896,15 @@ RSpec.describe LettingsLog do
end
end
context "when there is a log with age1 not known" do
let!(:age1_not_known) { create(:lettings_log, :duplicate, age1_known: 1, age1: nil) }
it "returns the log as a duplicate if age1 is not known" do
log.update!(age1_known: 1, age1: nil)
expect(described_class.duplicate_logs(log)).to include(age1_not_known)
end
end
context "when there is a duplicate supported housing log" do
let(:scheme) { create(:scheme) }
let(:location) { create(:location, scheme:) }
@ -2919,6 +2920,24 @@ RSpec.describe LettingsLog do
duplicate_supported_housing_log.update!(location: location_2)
expect(described_class.duplicate_logs(supported_housing_log)).not_to include(duplicate_supported_housing_log)
end
it "does not compare tcharge if there are no household charges" do
supported_housing_log.update!(household_charge: 1, supcharg: nil, brent: nil, scharge: nil, pscharge: nil, tcharge: nil)
duplicate_supported_housing_log.update!(household_charge: 1, supcharg: nil, brent: nil, scharge: nil, pscharge: nil, tcharge: nil)
expect(described_class.duplicate_logs(supported_housing_log)).to include(duplicate_supported_housing_log)
end
it "compares chcharge if it's a carehome" do
supported_housing_log.update!(is_carehome: 1, chcharge: 100, supcharg: nil, brent: nil, scharge: nil, pscharge: nil, tcharge: nil)
duplicate_supported_housing_log.update!(is_carehome: 1, chcharge: 100, supcharg: nil, brent: nil, scharge: nil, pscharge: nil, tcharge: nil)
expect(described_class.duplicate_logs(supported_housing_log)).to include(duplicate_supported_housing_log)
end
it "does not return a duplicate if carehome charge is not given" do
supported_housing_log.update!(is_carehome: 1, chcharge: nil, supcharg: nil, brent: nil, scharge: nil, pscharge: nil, tcharge: nil)
duplicate_supported_housing_log.update!(is_carehome: 1, chcharge: nil, supcharg: nil, brent: nil, scharge: nil, pscharge: nil, tcharge: nil)
expect(described_class.duplicate_logs(supported_housing_log)).not_to include(duplicate_supported_housing_log)
end
end
end
end

27
spec/models/sales_log_spec.rb

@ -249,6 +249,33 @@ RSpec.describe SalesLog, type: :model do
expect(described_class.duplicate_logs(log)).to include(purchid_not_given)
end
end
context "when there is a log age not known" do
let!(:age1_not_known) { create(:sales_log, :duplicate, age1_known: 1, age1: nil) }
it "returns the log as a duplicate if age is not known" do
log.update!(age1_known: 1, age1: nil)
expect(described_class.duplicate_logs(log)).to include(age1_not_known)
end
end
context "when there is a log age pefers not to say" do
let!(:age1_prefers_not_to_say) { create(:sales_log, :duplicate, age1_known: 2, age1: nil) }
it "returns the log as a duplicate if age is prefers not to say" do
log.update!(age1_known: 2, age1: nil)
expect(described_class.duplicate_logs(log)).to include(age1_prefers_not_to_say)
end
end
context "when there is a log age pefers not to say and not known" do
let!(:age1_prefers_not_to_say) { create(:sales_log, :duplicate, age1_known: 2, age1: nil) }
it "does not return the log as a duplicate if age is prefers not to say" do
log.update!(age1_known: 1, age1: nil)
expect(described_class.duplicate_logs(log)).not_to include(age1_prefers_not_to_say)
end
end
end
describe "derived variables" do

112
spec/requests/duplicate_logs_controller_spec.rb

@ -0,0 +1,112 @@
require "rails_helper"
RSpec.describe DuplicateLogsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { create(:user) }
context "when a user is signed in" do
let(:lettings_log) do
create(
:lettings_log,
:completed,
created_by: user,
)
end
let(:sales_log) do
create(
:sales_log,
:completed,
created_by: user,
)
end
describe "GET" do
context "when user is not signed in" do
it "redirects to sign in page" do
get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
expect(response).to redirect_to("/account/sign-in")
end
end
context "when the user is from different organisation" do
let(:other_user) { create(:user) }
before do
allow(other_user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in other_user
end
it "renders page not found" do
get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
expect(response).to have_http_status(:not_found)
end
end
context "when user is signed in" do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
context "with multiple duplicate lettings logs" do
let(:duplicate_logs) { create_list(:lettings_log, 2, :completed) }
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(duplicate_logs)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/lettings-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/lettings-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
expect(page).to have_content("Q7 - Tenant code", count: 3)
expect(page).to have_content("Q12 - Postcode", count: 3)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 3)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3)
expect(page).to have_content("Household rent and charges", count: 3)
expect(page).to have_link("Change", count: 21)
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
end
end
context "with multiple duplicate sales logs" do
let(:duplicate_logs) { create_list(:sales_log, 2, :completed) }
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(duplicate_logs)
get "/sales-logs/#{sales_log.id}/duplicate-logs"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/sales-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/sales-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 3)
expect(page).to have_content("Q2 - Purchaser code", count: 3)
expect(page).to have_content("Q20 - Lead buyer’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Q15 - Postcode", count: 3)
expect(page).to have_link("Change", count: 18)
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
end
end
end
end
end
end

48
spec/requests/form_controller_spec.rb

@ -532,6 +532,54 @@ RSpec.describe FormController, type: :request do
expect(whodunnit_actor).to be_a(User)
expect(whodunnit_actor.id).to eq(user.id)
end
context "and duplicate logs" do
let(:duplicate_logs) { create_list(:lettings_log, 2) }
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(duplicate_logs)
post "/lettings-logs/#{lettings_log.id}/#{page_id.dasherize}", params:
end
it "redirects to the duplicate logs page" do
expect(response).to redirect_to("/lettings-logs/#{lettings_log.id}/duplicate-logs")
follow_redirect!
expect(page).to have_content("These logs are duplicates")
end
end
end
context "with valid sales answers" do
let(:sales_log) do
create(
:sales_log,
created_by: user,
)
end
let(:params) do
{
id: sales_log.id,
sales_log: {
page: "buyer-1-age",
age1: 20,
},
}
end
context "and duplicate logs" do
let(:duplicate_logs) { create_list(:sales_log, 2) }
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(duplicate_logs)
post "/sales-logs/#{sales_log.id}/buyer-1-age", params:
end
it "redirects to the duplicate logs page" do
expect(response).to redirect_to("/sales-logs/#{sales_log.id}/duplicate-logs")
follow_redirect!
expect(page).to have_content("These logs are duplicates")
end
end
end
context "when the question has a conditional question" do

2
spec/services/bulk_upload/lettings/validator_spec.rb

@ -305,7 +305,7 @@ RSpec.describe BulkUpload::Lettings::Validator do
end
it "creates errors" do
expect { validator.call }.to change(BulkUploadError.where(category: :setup, error: "This is a duplicate of a log in your file"), :count).by(22)
expect { validator.call }.to change(BulkUploadError.where(category: :setup, error: "This is a duplicate of a log in your file"), :count).by(20)
end
end

3
spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

@ -258,7 +258,6 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
field_96: [error_message], # startdate
field_97: [error_message], # startdate
field_98: [error_message], # startdate
field_100: [error_message], # propcode
field_108: [error_message], # postcode_full
field_109: [error_message], # postcode_full
field_111: [error_message], # owning_organisation
@ -295,7 +294,6 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
:field_96, # startdate
:field_97, # startdate
:field_98, # startdate
:field_100, # propcode
:field_111, # owning_organisation
].each do |field|
expect(parser.errors[field]).to include("This is a duplicate log")
@ -329,7 +327,6 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
:field_96, # startdate
:field_97, # startdate
:field_98, # startdate
:field_100, # propcode
:field_108, # postcode_full
:field_109, # postcode_full
:field_111, # owning_organisation

3
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -289,7 +289,6 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
:field_8, # startdate
:field_9, # startdate
:field_13, # tenancycode
:field_14, # propcode
:field_23, # postcode_full
:field_24, # postcode_full
:field_25, # postcode_full
@ -328,7 +327,6 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
:field_8, # startdate
:field_9, # startdate
:field_13, # tenancycode
:field_14, # propcode
:field_17, # location
:field_46, # age1
:field_47, # sex1
@ -363,7 +361,6 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
:field_7, # startdate
:field_8, # startdate
:field_9, # startdate
:field_14, # propcode
:field_17, # location
:field_23, # postcode_full
:field_24, # postcode_full

Loading…
Cancel
Save