expect(record.errors[:saledate]).toinclude("Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.")
expect(record.errors[:saledate]).toinclude("Enter a date within the #{previous_year} to #{previous_year+1} or #{current_year} to #{current_year+1} collection years, which is between 1st April #{previous_year} and 31st March #{current_year+1}.")
end
end
context"when saledate is after an open collection year"do
expect(record.errors[:saledate]).toinclude("Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.")
expect(record.errors[:saledate]).toinclude("Enter a date within the #{previous_year} to #{previous_year+1} or #{current_year} to #{current_year+1} collection years, which is between 1st April #{previous_year} and 31st March #{current_year+1}.")
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"]).toinclude(match"Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.")
expect(record.errors["saledate"]).toinclude(match"Enter a date within the #{previous_year} to #{previous_year+1} or #{current_year} to #{current_year+1} collection years, which is between 1st April #{previous_year} and 31st March #{current_year+1}.")
end
it"can edit already created logs for the previous collection year"do
@ -127,7 +125,7 @@ RSpec.describe Validations::Sales::SetupValidations do
expect(record.errors["saledate"]).not_toinclude(match"Enter a date within the 2024 to 2025 collection year, which is between 1st April 2024 and 31st March 2025.")
expect(record.errors["saledate"]).not_toinclude(match"Enter a date within the #{current_year} to #{current_year+1} collection year, which is between 1st April #{current_year} and 31st March #{current_year+1}.")