Browse Source

CLDC-3499: Remove 2020 test from location_spec

makes the current_collection_after_crossover_start_date method a bit more useful, returns the date in the current collection year that crossover will end, rather than the crossover end date of the current period (which will be next year)
CLDC-3499-remove-pre-2025-tests
samyou-softwire 2 weeks ago
parent
commit
b80fd668f6
  1. 2
      app/helpers/collection_time_helper.rb
  2. 34
      spec/models/location_spec.rb

2
app/helpers/collection_time_helper.rb

@ -30,7 +30,7 @@ module CollectionTimeHelper
end
def current_collection_after_crossover_start_date
Form::DEADLINES[current_collection_start_year][:edit_end_date] + 1.day
Form::DEADLINES[previous_collection_start_year][:edit_end_date] + 1.day
end
def collection_end_date(date)

34
spec/models/location_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Location, type: :model do
include CollectionTimeHelper
before do
LocalAuthorityLink.create(local_authority_id: LocalAuthority.find_by(code: "E07000030").id, linked_local_authority_id: LocalAuthority.find_by(code: "E06000063").id)
end
@ -1184,35 +1186,19 @@ RSpec.describe Location, type: :model do
end
context "when there is no start date" do
context "and the location was created at the start of the 2022/23 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2022, 4, 6), startdate: nil) }
it "returns the beginning of 21/22 collection window" do
expect(location.available_from).to eq(Time.zone.local(2021, 4, 1))
end
end
context "and the location was created at the end of the 2022/23 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2023, 2, 6), startdate: nil) }
it "returns the beginning of 22/23 collection window" do
expect(location.available_from).to eq(Time.zone.local(2022, 4, 1))
end
end
context "and the location was created at the start of the 2021/22 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2021, 4, 6), startdate: nil) }
context "and the location was created at the start of the collection window" do
let(:location) { FactoryBot.build(:location, created_at: current_collection_start_date, startdate: nil) }
it "returns the beginning of 20/21 collection window" do
expect(location.available_from).to eq(Time.zone.local(2020, 4, 1))
it "returns the beginning of previous collection window" do
expect(location.available_from).to eq(previous_collection_start_date)
end
end
context "and the location was created at the end of the 2021/22 collection window" do
let(:location) { FactoryBot.build(:location, created_at: Time.zone.local(2022, 2, 6), startdate: nil) }
context "and the location was created after the crossover date" do
let(:location) { FactoryBot.build(:location, created_at: current_collection_after_crossover_start_date, startdate: nil) }
it "returns the beginning of 20/21 collection window" do
expect(location.available_from).to eq(Time.zone.local(2020, 4, 1))
it "returns the beginning of current collection window" do
expect(location.available_from).to eq(current_collection_start_date)
end
end
end

Loading…
Cancel
Save