|
|
|
require "rails_helper"
|
|
|
|
|
|
|
|
RSpec.describe Csv::SalesLogCsvService do
|
|
|
|
subject(:task) { Rake::Task["data_import:add_variable_definitions"] }
|
|
|
|
|
|
|
|
let(:form_handler_mock) { instance_double(FormHandler) }
|
|
|
|
let(:organisation) { create(:organisation, name: "MHCLG") }
|
|
|
|
let(:fixed_time) { now }
|
|
|
|
let(:now) { Time.zone.now }
|
|
|
|
let(:user) { create(:user, :support, email: "billyboy@eyeKLAUD.com") }
|
|
|
|
let(:log) do
|
|
|
|
create(
|
|
|
|
:sales_log,
|
|
|
|
:completed,
|
|
|
|
assigned_to: user,
|
|
|
|
saledate: fixed_time,
|
|
|
|
created_at: fixed_time,
|
|
|
|
updated_at: now,
|
|
|
|
owning_organisation: organisation,
|
|
|
|
managing_organisation: organisation,
|
|
|
|
purchid: nil,
|
|
|
|
hholdcount: 3,
|
|
|
|
age1: 30,
|
|
|
|
sex1: "X",
|
|
|
|
age2: 35,
|
|
|
|
sex2: "X",
|
|
|
|
sex3: "X",
|
|
|
|
age4_known: 1,
|
|
|
|
sex4: "X",
|
|
|
|
details_known_5: 2,
|
|
|
|
age6_known: nil,
|
|
|
|
age6: nil,
|
|
|
|
ecstat6: nil,
|
|
|
|
relat6: nil,
|
|
|
|
sex6: nil,
|
|
|
|
town_or_city: "Town or city",
|
|
|
|
address_line1_as_entered: "address line 1 as entered",
|
|
|
|
address_line2_as_entered: "address line 2 as entered",
|
|
|
|
town_or_city_as_entered: "town or city as entered",
|
|
|
|
county_as_entered: "county as entered",
|
|
|
|
postcode_full_as_entered: "AB1 2CD",
|
|
|
|
la_as_entered: "la as entered",
|
|
|
|
hhregres: 1,
|
|
|
|
hhregresstill: 4,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
let(:service) { described_class.new(user:, export_type: "labels", year:) }
|
|
|
|
let(:csv) { CSV.parse(service.prepare_csv(SalesLog.all)) }
|
|
|
|
let(:year) { 2024 }
|
|
|
|
let(:definition_line) { csv.first }
|
|
|
|
let(:attribute_line) { csv.second }
|
|
|
|
let(:content_line) { csv.third }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Timecop.freeze(now)
|
|
|
|
Singleton.__init__(FormHandler)
|
|
|
|
log
|
|
|
|
Rake.application.rake_require("tasks/log_variable_definitions")
|
|
|
|
Rake::Task.define_task(:environment)
|
|
|
|
task.reenable
|
|
|
|
task.invoke("spec/fixtures/variable_definitions")
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
Timecop.return
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a string" do
|
|
|
|
result = service.prepare_csv(SalesLog.all)
|
|
|
|
expect(result).to be_a String
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a csv with definition headers on first line" do
|
|
|
|
expect(definition_line.first).to eq "Log ID"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a csv with attribute headers on second line" do
|
|
|
|
expect(attribute_line.first).to eq "ID"
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when stubbing :ordered_questions_for_year" do
|
|
|
|
let(:sales_form) do
|
|
|
|
FormFactory.new(year: 1936, type: "sales")
|
|
|
|
.with_sections([build(:section, :with_questions, question_ids:, questions:)])
|
|
|
|
.build
|
|
|
|
end
|
|
|
|
let(:question_ids) { [] }
|
|
|
|
let(:questions) { nil }
|
|
|
|
let(:year) { 1936 }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
|
|
|
|
allow(form_handler_mock).to receive(:form_name_from_start_year)
|
|
|
|
allow(form_handler_mock).to receive(:get_form).and_return(sales_form)
|
|
|
|
allow(form_handler_mock).to receive(:ordered_questions_for_year).and_return(sales_form.questions)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "calls the form handler to get all questions in order when initialized" do
|
|
|
|
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
|
|
|
|
allow(form_handler_mock).to receive(:ordered_questions_for_year).and_return([])
|
|
|
|
service
|
|
|
|
expect(form_handler_mock).to have_received(:ordered_questions_for_year).with(1936, "sales")
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when it returns questions with particular ids" do
|
|
|
|
let(:question_ids) { %w[type age1 buy1livein exdate] }
|
|
|
|
|
|
|
|
it "includes log attributes related to questions to the headers" do
|
|
|
|
attribute_line_before_2023 = csv.first
|
|
|
|
expect(attribute_line_before_2023).to include(*%w[TYPE AGE1 LIVEINBUYER1])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "removes some log attributes related to questions from the headers and replaces them with their derived values in the correct order" do
|
|
|
|
attribute_line_before_2023 = csv.first
|
|
|
|
expect(attribute_line_before_2023).not_to include "EXDATE"
|
|
|
|
expect(attribute_line_before_2023.last(4)).to eq %w[LIVEINBUYER1 EXDAY EXMONTH EXYEAR]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when it returns questions with particular features" do
|
|
|
|
let(:questions) do
|
|
|
|
[
|
|
|
|
build(:question, id: "attribute_value_check", type: "interruption_screen"),
|
|
|
|
build(:question, id: "something_or_other_known", type: "radio"),
|
|
|
|
build(:question, id: "whatchamacallit_asked", type: "radio"),
|
|
|
|
build(:question, id: "ownershipsch"),
|
|
|
|
build(:question, id: "checkbox_question", type: "checkbox", answer_options: { "pregyrha" => {}, "pregother" => {} }),
|
|
|
|
build(:question, id: "type"),
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not add questions for checks, whether some other attribute is known or whether something else was asked" do
|
|
|
|
attribute_line_before_2023 = csv.first
|
|
|
|
expect(attribute_line_before_2023).not_to include "attribute_value_check"
|
|
|
|
expect(attribute_line_before_2023).not_to include "something_or_other_known"
|
|
|
|
expect(attribute_line_before_2023).not_to include "whatchamacallit_asked"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not add the id of checkbox questions, but adds the related attributes of the log in the correct order" do
|
|
|
|
attribute_line_before_2023 = csv.first
|
|
|
|
expect(attribute_line_before_2023.last(4)).to eq %w[OWNERSHIP PREGYRHA PREGOTHER TYPE]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "includes attributes not related to questions to the headers" do
|
|
|
|
expect(attribute_line).to include(*%w[ID STATUS CREATEDDATE UPLOADDATE])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a csv with the correct number of logs" do
|
|
|
|
create_list(:sales_log, 15)
|
|
|
|
log_count = SalesLog.count
|
|
|
|
expected_row_count_with_headers = log_count + 2
|
|
|
|
expect(csv.size).to be expected_row_count_with_headers
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when exporting with human readable labels" do
|
|
|
|
let(:year) { 2023 }
|
|
|
|
let(:fixed_time) { Time.zone.local(2023, 12, 8) }
|
|
|
|
let(:now) { fixed_time }
|
|
|
|
|
|
|
|
it "gives answers to radio questions as their labels" do
|
|
|
|
national_column_index = attribute_line.index("NATIONAL")
|
|
|
|
national_value = content_line[national_column_index]
|
|
|
|
expect(national_value).to eq "United Kingdom"
|
|
|
|
relat2_column_index = attribute_line.index("RELAT2")
|
|
|
|
relat2_value = content_line[relat2_column_index]
|
|
|
|
expect(relat2_value).to eq "Partner"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gives answers to free input questions as the user input" do
|
|
|
|
age1_column_index = attribute_line.index("AGE1")
|
|
|
|
age1_value = content_line[age1_column_index]
|
|
|
|
expect(age1_value).to eq 30.to_s
|
|
|
|
postcode_part1, postcode_part2 = log.postcode_full.split
|
|
|
|
postcode_part1_column_index = attribute_line.index("PCODE1")
|
|
|
|
postcode_part1_value = content_line[postcode_part1_column_index]
|
|
|
|
expect(postcode_part1_value).to eq postcode_part1
|
|
|
|
postcode_part2_column_index = attribute_line.index("PCODE2")
|
|
|
|
postcode_part2_value = content_line[postcode_part2_column_index]
|
|
|
|
expect(postcode_part2_value).to eq postcode_part2
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the code for the local authority under the heading 'la'" do
|
|
|
|
la_column_index = attribute_line.index("LA")
|
|
|
|
la_value = content_line[la_column_index]
|
|
|
|
expect(la_value).to eq "E09000033"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the label for the local authority under the heading 'la_label'" do
|
|
|
|
la_label_column_index = attribute_line.index("LANAME")
|
|
|
|
la_label_value = content_line[la_label_column_index]
|
|
|
|
expect(la_label_value).to eq "Westminster"
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the requested form is 2024" do
|
|
|
|
let(:now) { Time.zone.local(2024, 5, 1) }
|
|
|
|
let(:year) { 2024 }
|
|
|
|
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
|
|
|
|
|
|
|
|
before do
|
CLDC-3787 Autocomplete address search (#2924)
* Prototype
* Remove git from dockerfile
* UPRN search too
* Revert address client and use uprn client
* Add address search to lettings too
* Updates with lettings logs
* Update copy
* Move guidance to partial
* Fix uprn return
* Delete new db file, restore old
* Lint
* Remove old db file
* Lint
* Add new db file, remove old
* JS lint
* Update schema
* Add manual entry option
* Update derived variables
* Comment out old version of find address in 2024
* Remove db column
* Add new db columns
* Update guidance partial
* Add unless to migration
* Add migration files to remove and readd
* authenticate user
* Remove file
* Delete migration files
* Add search url
* Add search url
* Fix onConfirm
* Add manual entry button instead of change skip link
* Revert "Add manual entry button instead of change skip link"
This reverts commit 22577c801aca940acfc16caf94d3159071ea8258.
* Revert "Revert "Add manual entry button instead of change skip link""
This reverts commit 9f0a2111a58e933a28105e54aba6ca08c2d043b7.
* Replace uprn question
* Update question copy
* Allow changing the address search value
* Rename address autocomplete to address search
* Add buttons to switch between address questions
* Fix controller logic
* Enable adding question numbers to page headers
* Update skip links
* Add js disabled message to select
* Alternative way to handle js disabled users
* Revert "Alternative way to handle js disabled users"
This reverts commit 10da3d61e2f89ec29ef9f9071c63eb99aa2bb482.
* Fix typo
* Fix address options for address search question
* Reuse AddressDataPresenter where appropriate
* Lint
* Remove uprn selection question tests
* Reuse UprnDataPresenter where appropriate
* CSV export, exclude address_search
* Add address search to sales and lettings factory bots
* Exclude old address questions from routing, keep as exported values
* lint
* Update uprn value
* Add address search input boolean and switch between questions
* Reword copy, remove "Find" and "Search by"
* Align address questions, add question number and question text
* Remove old wip depends on
* Update some tests
* Update migration, move default value from db to model
* Update test
* Remove binding pry
* Lint
* Update test
* Lint
* Update test
* Update routes with underscores
* Remove debugging
* Limit visible logs to user
* Add manual address entry selected variable
* Change address search min length to 3chars
* Remove binding.pry
* Update factory bots, manual_address_entry_selected to true for preexisting tests
* Update model tests
* Update sales model tests excl E-code tests
* Update address search request test
* Reuse uprn id instead of address_search
* Set manual address entry selected as false when creating test logs
* Update model test
* Update request tests and remove old questions
* Add back test
* Update services
* Update more tests
Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
* Update request tests
* update model tests
* Also update sales log
* Update service csv uprn_selection values to 1
* Add tests for pages and questions
* Update test
* Update uprn_known
* Lint
* Add feature test
* Update test
* Update tests
* Remove test
* pre-consolidate migration files
* Indentation
* Controller method improvements
* Update question numbers for 2025/26
* Update question numbers tests
* consolidate and delete old migration files
* undo changes to schema.rb
* Update 2025 property information translation files
* Update answer options to show singular previously selected result if present
* Move buttons to bottom guidance partials
* Small improvements, make address search and existing search more similar
* Validate entered addresses as within England
* Update test
* Revert "Validate entered addresses as within England"
This reverts commit 2dbfbcc8a5188cde7fb0ac0dcdbc5919eefd6a12.
* Add missing button to sales address page
* Change error code
* Clear invalid options
* Edit no results message method
* Keep no result logic just change text
* Display uprn value with address value
* Still show no results message when characters entered is less than 3 rather than nothing
* Fix uprn result when query is ambiguous
* Reduce min match for address search
* Hide no result found message just before results are populated
* Prevent changing logs to 2025 with invalid addresses
* Correct attribute name
* Handle nil
* Remove custom error message
* Remove unused variables from factory
* Update tests, remove address and postcode from old find address
* Fix bug clearing uprn from see all answers
* Revert "Fix bug clearing uprn from see all answers"
This reverts commit a66c47a1abf7a429f25e0a016fedb0b92e92f15c.
* Undo changes to validation method
* Fix unchanged uprn_selection when clearing or changing uprn
* Undo a change
* Update bulk upload 2025
* Fix typo
* Remove redundant line
---------
Co-authored-by: Kat <54268893+kosiakkatrina@users.noreply.github.com>
Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
2 weeks ago
|
|
|
log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the CSV with the 2024 ordering and all values correct" do
|
|
|
|
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_24.csv")
|
|
|
|
values_to_delete = %w[ID]
|
|
|
|
values_to_delete.each do |attribute|
|
|
|
|
index = attribute_line.index(attribute)
|
|
|
|
content_line[index] = nil
|
|
|
|
end
|
|
|
|
expect(csv).to eq expected_content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the requested form is 2023" do
|
|
|
|
let(:now) { Time.zone.local(2024, 1, 1) }
|
|
|
|
let(:year) { 2023 }
|
|
|
|
|
|
|
|
it "exports the CSV with the 2023 ordering and all values correct" do
|
|
|
|
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_23.csv")
|
|
|
|
values_to_delete = %w[ID]
|
|
|
|
values_to_delete.each do |attribute|
|
|
|
|
index = attribute_line.index(attribute)
|
|
|
|
content_line[index] = nil
|
|
|
|
end
|
|
|
|
expect(csv).to eq expected_content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the log has a duplicate log reference" do
|
|
|
|
before do
|
|
|
|
log.update!(duplicate_set_id: 12_312)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the id for under the heading 'duplicate_set_id'" do
|
|
|
|
duplicate_set_id_column_index = attribute_line.index("DUPLICATESET")
|
|
|
|
duplicate_set_id_value = content_line[duplicate_set_id_column_index]
|
|
|
|
expect(duplicate_set_id_value).to eq "12312"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when exporting values as codes" do
|
|
|
|
let(:service) { described_class.new(user:, export_type: "codes", year:) }
|
|
|
|
let(:year) { 2023 }
|
|
|
|
let(:fixed_time) { Time.zone.local(2023, 12, 8) }
|
|
|
|
let(:now) { fixed_time }
|
|
|
|
|
|
|
|
it "gives answers to radio questions as their codes" do
|
|
|
|
national_column_index = attribute_line.index("NATIONAL")
|
|
|
|
national_value = content_line[national_column_index]
|
|
|
|
expect(national_value).to eq 18.to_s
|
|
|
|
relat2_column_index = attribute_line.index("RELAT2")
|
|
|
|
relat2_value = content_line[relat2_column_index]
|
|
|
|
expect(relat2_value).to eq "P"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gives answers to free input questions as the user input" do
|
|
|
|
age1_column_index = attribute_line.index("AGE1")
|
|
|
|
age1_value = content_line[age1_column_index]
|
|
|
|
expect(age1_value).to eq 30.to_s
|
|
|
|
postcode_part1, postcode_part2 = log.postcode_full.split
|
|
|
|
postcode_part1_column_index = attribute_line.index("PCODE1")
|
|
|
|
postcode_part1_value = content_line[postcode_part1_column_index]
|
|
|
|
expect(postcode_part1_value).to eq postcode_part1
|
|
|
|
postcode_part2_column_index = attribute_line.index("PCODE2")
|
|
|
|
postcode_part2_value = content_line[postcode_part2_column_index]
|
|
|
|
expect(postcode_part2_value).to eq postcode_part2
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the code for the local authority under the heading 'la'" do
|
|
|
|
la_column_index = attribute_line.index("LA")
|
|
|
|
la_value = content_line[la_column_index]
|
|
|
|
expect(la_value).to eq "E09000033"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the label for the local authority under the heading 'la_label'" do
|
|
|
|
la_label_column_index = attribute_line.index("LANAME")
|
|
|
|
la_label_value = content_line[la_label_column_index]
|
|
|
|
expect(la_label_value).to eq "Westminster"
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the requested form is 2024" do
|
|
|
|
let(:now) { Time.zone.local(2024, 5, 1) }
|
|
|
|
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
|
|
|
|
let(:year) { 2024 }
|
|
|
|
|
CLDC-3787 Autocomplete address search (#2924)
* Prototype
* Remove git from dockerfile
* UPRN search too
* Revert address client and use uprn client
* Add address search to lettings too
* Updates with lettings logs
* Update copy
* Move guidance to partial
* Fix uprn return
* Delete new db file, restore old
* Lint
* Remove old db file
* Lint
* Add new db file, remove old
* JS lint
* Update schema
* Add manual entry option
* Update derived variables
* Comment out old version of find address in 2024
* Remove db column
* Add new db columns
* Update guidance partial
* Add unless to migration
* Add migration files to remove and readd
* authenticate user
* Remove file
* Delete migration files
* Add search url
* Add search url
* Fix onConfirm
* Add manual entry button instead of change skip link
* Revert "Add manual entry button instead of change skip link"
This reverts commit 22577c801aca940acfc16caf94d3159071ea8258.
* Revert "Revert "Add manual entry button instead of change skip link""
This reverts commit 9f0a2111a58e933a28105e54aba6ca08c2d043b7.
* Replace uprn question
* Update question copy
* Allow changing the address search value
* Rename address autocomplete to address search
* Add buttons to switch between address questions
* Fix controller logic
* Enable adding question numbers to page headers
* Update skip links
* Add js disabled message to select
* Alternative way to handle js disabled users
* Revert "Alternative way to handle js disabled users"
This reverts commit 10da3d61e2f89ec29ef9f9071c63eb99aa2bb482.
* Fix typo
* Fix address options for address search question
* Reuse AddressDataPresenter where appropriate
* Lint
* Remove uprn selection question tests
* Reuse UprnDataPresenter where appropriate
* CSV export, exclude address_search
* Add address search to sales and lettings factory bots
* Exclude old address questions from routing, keep as exported values
* lint
* Update uprn value
* Add address search input boolean and switch between questions
* Reword copy, remove "Find" and "Search by"
* Align address questions, add question number and question text
* Remove old wip depends on
* Update some tests
* Update migration, move default value from db to model
* Update test
* Remove binding pry
* Lint
* Update test
* Lint
* Update test
* Update routes with underscores
* Remove debugging
* Limit visible logs to user
* Add manual address entry selected variable
* Change address search min length to 3chars
* Remove binding.pry
* Update factory bots, manual_address_entry_selected to true for preexisting tests
* Update model tests
* Update sales model tests excl E-code tests
* Update address search request test
* Reuse uprn id instead of address_search
* Set manual address entry selected as false when creating test logs
* Update model test
* Update request tests and remove old questions
* Add back test
* Update services
* Update more tests
Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
* Update request tests
* update model tests
* Also update sales log
* Update service csv uprn_selection values to 1
* Add tests for pages and questions
* Update test
* Update uprn_known
* Lint
* Add feature test
* Update test
* Update tests
* Remove test
* pre-consolidate migration files
* Indentation
* Controller method improvements
* Update question numbers for 2025/26
* Update question numbers tests
* consolidate and delete old migration files
* undo changes to schema.rb
* Update 2025 property information translation files
* Update answer options to show singular previously selected result if present
* Move buttons to bottom guidance partials
* Small improvements, make address search and existing search more similar
* Validate entered addresses as within England
* Update test
* Revert "Validate entered addresses as within England"
This reverts commit 2dbfbcc8a5188cde7fb0ac0dcdbc5919eefd6a12.
* Add missing button to sales address page
* Change error code
* Clear invalid options
* Edit no results message method
* Keep no result logic just change text
* Display uprn value with address value
* Still show no results message when characters entered is less than 3 rather than nothing
* Fix uprn result when query is ambiguous
* Reduce min match for address search
* Hide no result found message just before results are populated
* Prevent changing logs to 2025 with invalid addresses
* Correct attribute name
* Handle nil
* Remove custom error message
* Remove unused variables from factory
* Update tests, remove address and postcode from old find address
* Fix bug clearing uprn from see all answers
* Revert "Fix bug clearing uprn from see all answers"
This reverts commit a66c47a1abf7a429f25e0a016fedb0b92e92f15c.
* Undo changes to validation method
* Fix unchanged uprn_selection when clearing or changing uprn
* Undo a change
* Update bulk upload 2025
* Fix typo
* Remove redundant line
---------
Co-authored-by: Kat <54268893+kosiakkatrina@users.noreply.github.com>
Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
2 weeks ago
|
|
|
before do
|
|
|
|
log.update!(manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the CSV with all values correct" do
|
|
|
|
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_24.csv")
|
|
|
|
values_to_delete = %w[ID]
|
|
|
|
values_to_delete.each do |attribute|
|
|
|
|
index = attribute_line.index(attribute)
|
|
|
|
content_line[index] = nil
|
|
|
|
end
|
|
|
|
expect(csv).to eq expected_content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the requested form is 2023" do
|
|
|
|
let(:now) { Time.zone.local(2024, 1, 1) }
|
|
|
|
let(:year) { 2023 }
|
|
|
|
|
|
|
|
it "exports the CSV with all values correct" do
|
|
|
|
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_23.csv")
|
|
|
|
values_to_delete = %w[ID]
|
|
|
|
values_to_delete.each do |attribute|
|
|
|
|
index = attribute_line.index(attribute)
|
|
|
|
content_line[index] = nil
|
|
|
|
end
|
|
|
|
expect(csv).to eq expected_content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the log has a duplicate log reference" do
|
|
|
|
before do
|
|
|
|
log.update!(duplicate_set_id: 12_312)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "exports the id for under the heading 'duplicate_set_id'" do
|
|
|
|
duplicate_set_id_column_index = attribute_line.index("DUPLICATESET")
|
|
|
|
duplicate_set_id_value = content_line[duplicate_set_id_column_index]
|
|
|
|
expect(duplicate_set_id_value).to eq "12312"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the user is not a support user" do
|
|
|
|
let(:user) { create(:user, email: "billyboy@eyeklaud.com") }
|
|
|
|
|
|
|
|
it "does not include certain attributes in the headers" do
|
|
|
|
expect(attribute_line).not_to include(*%w[address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by value_value_check monthly_charges_value_check])
|
|
|
|
end
|
|
|
|
|
|
|
|
context "and the requested form is 2024" do
|
|
|
|
let(:year) { 2024 }
|
|
|
|
let(:now) { Time.zone.local(2024, 5, 1) }
|
|
|
|
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
|
|
|
|
|
|
|
|
before do
|
CLDC-3787 Autocomplete address search (#2924)
* Prototype
* Remove git from dockerfile
* UPRN search too
* Revert address client and use uprn client
* Add address search to lettings too
* Updates with lettings logs
* Update copy
* Move guidance to partial
* Fix uprn return
* Delete new db file, restore old
* Lint
* Remove old db file
* Lint
* Add new db file, remove old
* JS lint
* Update schema
* Add manual entry option
* Update derived variables
* Comment out old version of find address in 2024
* Remove db column
* Add new db columns
* Update guidance partial
* Add unless to migration
* Add migration files to remove and readd
* authenticate user
* Remove file
* Delete migration files
* Add search url
* Add search url
* Fix onConfirm
* Add manual entry button instead of change skip link
* Revert "Add manual entry button instead of change skip link"
This reverts commit 22577c801aca940acfc16caf94d3159071ea8258.
* Revert "Revert "Add manual entry button instead of change skip link""
This reverts commit 9f0a2111a58e933a28105e54aba6ca08c2d043b7.
* Replace uprn question
* Update question copy
* Allow changing the address search value
* Rename address autocomplete to address search
* Add buttons to switch between address questions
* Fix controller logic
* Enable adding question numbers to page headers
* Update skip links
* Add js disabled message to select
* Alternative way to handle js disabled users
* Revert "Alternative way to handle js disabled users"
This reverts commit 10da3d61e2f89ec29ef9f9071c63eb99aa2bb482.
* Fix typo
* Fix address options for address search question
* Reuse AddressDataPresenter where appropriate
* Lint
* Remove uprn selection question tests
* Reuse UprnDataPresenter where appropriate
* CSV export, exclude address_search
* Add address search to sales and lettings factory bots
* Exclude old address questions from routing, keep as exported values
* lint
* Update uprn value
* Add address search input boolean and switch between questions
* Reword copy, remove "Find" and "Search by"
* Align address questions, add question number and question text
* Remove old wip depends on
* Update some tests
* Update migration, move default value from db to model
* Update test
* Remove binding pry
* Lint
* Update test
* Lint
* Update test
* Update routes with underscores
* Remove debugging
* Limit visible logs to user
* Add manual address entry selected variable
* Change address search min length to 3chars
* Remove binding.pry
* Update factory bots, manual_address_entry_selected to true for preexisting tests
* Update model tests
* Update sales model tests excl E-code tests
* Update address search request test
* Reuse uprn id instead of address_search
* Set manual address entry selected as false when creating test logs
* Update model test
* Update request tests and remove old questions
* Add back test
* Update services
* Update more tests
Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
* Update request tests
* update model tests
* Also update sales log
* Update service csv uprn_selection values to 1
* Add tests for pages and questions
* Update test
* Update uprn_known
* Lint
* Add feature test
* Update test
* Update tests
* Remove test
* pre-consolidate migration files
* Indentation
* Controller method improvements
* Update question numbers for 2025/26
* Update question numbers tests
* consolidate and delete old migration files
* undo changes to schema.rb
* Update 2025 property information translation files
* Update answer options to show singular previously selected result if present
* Move buttons to bottom guidance partials
* Small improvements, make address search and existing search more similar
* Validate entered addresses as within England
* Update test
* Revert "Validate entered addresses as within England"
This reverts commit 2dbfbcc8a5188cde7fb0ac0dcdbc5919eefd6a12.
* Add missing button to sales address page
* Change error code
* Clear invalid options
* Edit no results message method
* Keep no result logic just change text
* Display uprn value with address value
* Still show no results message when characters entered is less than 3 rather than nothing
* Fix uprn result when query is ambiguous
* Reduce min match for address search
* Hide no result found message just before results are populated
* Prevent changing logs to 2025 with invalid addresses
* Correct attribute name
* Handle nil
* Remove custom error message
* Remove unused variables from factory
* Update tests, remove address and postcode from old find address
* Fix bug clearing uprn from see all answers
* Revert "Fix bug clearing uprn from see all answers"
This reverts commit a66c47a1abf7a429f25e0a016fedb0b92e92f15c.
* Undo changes to validation method
* Fix unchanged uprn_selection when clearing or changing uprn
* Undo a change
* Update bulk upload 2025
* Fix typo
* Remove redundant line
---------
Co-authored-by: Kat <54268893+kosiakkatrina@users.noreply.github.com>
Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
2 weeks ago
|
|
|
log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "and exporting with labels" do
|
|
|
|
let(:export_type) { "labels" }
|
|
|
|
|
|
|
|
it "exports the CSV with all values correct" do
|
|
|
|
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv")
|
|
|
|
values_to_delete = %w[id]
|
|
|
|
values_to_delete.each do |attribute|
|
|
|
|
index = attribute_line.index(attribute)
|
|
|
|
content_line[index] = nil
|
|
|
|
end
|
|
|
|
expect(csv).to eq expected_content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|