CLDC-2459 Update end date for new logs creation (#1716)
* Renme end_date to new_logs_end_date
* Display change buttons in CYA if the collection is still open for editing
* Allow navigating to question if the collection is still open for editing
* Allow logs to be edited if the date is before edit end date
* Update sales validation to allow editing existing logs
* update tests
* Update edit_end_date
* Update some test wording
* Update new logs end date
* tests
@ -13,5 +13,5 @@ Also, if incorrect data is found during QA process, data providers might be aske
To accommodate the different end dates, we will now store 3 different dates on the form definition:
- Submission deadline (submission_deadline) - this is the date displayed at the top of a completed log in lettings and sales - "You can review and make changes to this log until 9 June 2024.". Nothing happens on this date
- New logs end date (end_date) - no new logs for that collection year can be submitted, but logs can be edited
- New logs end date (new_logs_end_date) - no new logs for that collection year can be submitted, but logs can be edited
- Edit and delete logs end date (edit_end_date) - logs can no longer be edited or deleted. Completed logs can still be viewed. Materials / references to the collection year are removed.
@ -105,6 +105,52 @@ RSpec.describe Validations::Sales::SetupValidations do
expect(record.errors[:saledate]).toinclude("Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025")
end
end
context"when current time is after the new logs end date but before edit end date for the previous period"do
expect(record.errors["saledate"]).not_toinclude(match"Enter a date within the 24/25 collection year, which is between 1st April 2024 and 31st March 2025")
end
end
context"when after the new logs end date and after the edit end date for the previous period"do
@ -85,6 +85,48 @@ RSpec.describe Validations::SetupValidations do
expect(record.errors["startdate"]).toinclude(match"Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")
end
end
context"when after the new logs end date but before edit end date for the previous period"do
it"cannot create new logs for the previous collection year"do
record.update!(startdate:nil)
record.startdate=Time.zone.local(2023,1,1)
setup_validator.validate_startdate_setup(record)
expect(record.errors["startdate"]).toinclude(match"Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")
end
xit"can edit already created logs for the previous collection year"do
record.startdate=Time.zone.local(2023,1,2)
record.save!(validate:false)
record.startdate=Time.zone.local(2023,1,1)
setup_validator.validate_startdate_setup(record)
expect(record.errors["startdate"]).not_toinclude(match"Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")
end
end
context"when after the new logs end date and after the edit end date for the previous period"do
it"cannot create new logs for the previous collection year"do
record.update!(startdate:nil)
record.startdate=Time.zone.local(2023,1,1)
setup_validator.validate_startdate_setup(record)
expect(record.errors["startdate"]).toinclude(match"Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")
end
it"cannot edit already created logs for the previous collection year"do
record.startdate=Time.zone.local(2023,1,2)
record.save!(validate:false)
record.startdate=Time.zone.local(2023,1,1)
setup_validator.validate_startdate_setup(record)
expect(record.errors["startdate"]).toinclude(match"Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")