From c6ece5a94ecb34d89be21135616943a0fc275175 Mon Sep 17 00:00:00 2001 From: Aaron Spencer Date: Mon, 19 Jun 2023 17:39:48 +0100 Subject: [PATCH] CLDC-2075: date clarification in tests --- .../form/sales/pages/discounted_ownership_type_spec.rb | 8 ++++---- .../form/sales/pages/outright_ownership_type_spec.rb | 8 ++++---- .../form/sales/pages/shared_ownership_type_spec.rb | 10 +++++----- .../sales/questions/discounted_ownership_type_spec.rb | 8 ++++---- .../sales/questions/outright_ownership_type_spec.rb | 8 ++++---- .../form/sales/questions/shared_ownership_type_spec.rb | 9 +++++---- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/spec/models/form/sales/pages/discounted_ownership_type_spec.rb b/spec/models/form/sales/pages/discounted_ownership_type_spec.rb index d46114b65..708090420 100644 --- a/spec/models/form/sales/pages/discounted_ownership_type_spec.rb +++ b/spec/models/form/sales/pages/discounted_ownership_type_spec.rb @@ -9,16 +9,16 @@ RSpec.describe Form::Sales::Pages::DiscountedOwnershipType, type: :model do let(:start_date) { Time.zone.today } describe "headers" do - context "when form year is for 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } + context "when form year is for 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 8) } it "has the correct header" do expect(page.header).to eq("Type of discounted ownership sale") end end - context "when form year is for before 2023" do - let(:start_date) { Time.utc(2022, 2, 8) } + context "when form year is for before 2023/24" do + let(:start_date) { Time.zone.local(2022, 2, 8) } it "does not have a page header" do expect(page.header).to eq(nil) diff --git a/spec/models/form/sales/pages/outright_ownership_type_spec.rb b/spec/models/form/sales/pages/outright_ownership_type_spec.rb index b00094a7d..a080d148d 100644 --- a/spec/models/form/sales/pages/outright_ownership_type_spec.rb +++ b/spec/models/form/sales/pages/outright_ownership_type_spec.rb @@ -31,16 +31,16 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do end describe "headers" do - context "when the form year is 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } + context "when the form year is 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 8) } it "has the correct header" do expect(page.header).to eq("Type of outright sale") end end - context "when the form is before the year 2023" do - let(:start_date) { Time.utc(2022, 2, 8) } + context "when the form is before the year 2023/24" do + let(:start_date) { Time.zone.local(2022, 4, 8) } it "does not have a page header" do expect(page.header).to eq(nil) diff --git a/spec/models/form/sales/pages/shared_ownership_type_spec.rb b/spec/models/form/sales/pages/shared_ownership_type_spec.rb index 5877586bd..dfed74fb3 100644 --- a/spec/models/form/sales/pages/shared_ownership_type_spec.rb +++ b/spec/models/form/sales/pages/shared_ownership_type_spec.rb @@ -1,4 +1,4 @@ -require "rails_hel\per" +require "rails_helper" RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } @@ -9,16 +9,16 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do let(:start_date) { Time.utc(2022, 4, 1) } describe "headers" do - context "when 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } + context "when form is after the year 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 8) } it "has the correct header" do expect(page.header).to eq("Type of shared ownership sale") end end - context "when before 2023" do - let(:start_date) { Time.utc(2022, 2, 8) } + context "when form is before the year 2023/24" do + let(:start_date) { Time.zone.local(2022, 2, 8) } it "has the correct header" do expect(page.header).to eq(nil) diff --git a/spec/models/form/sales/questions/discounted_ownership_type_spec.rb b/spec/models/form/sales/questions/discounted_ownership_type_spec.rb index 02e7c1eed..766466e74 100644 --- a/spec/models/form/sales/questions/discounted_ownership_type_spec.rb +++ b/spec/models/form/sales/questions/discounted_ownership_type_spec.rb @@ -46,8 +46,8 @@ RSpec.describe Form::Sales::Questions::DiscountedOwnershipType, type: :model do end describe "partial guidance" do - context "when the form is for 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } + context "when the form is for 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 8) } it "shows shows correct guidance_partial" do expect(question.guidance_partial).to eq("discounted_ownership_type_definitions") @@ -59,8 +59,8 @@ RSpec.describe Form::Sales::Questions::DiscountedOwnershipType, type: :model do end end - context "when the form is for before 2023" do - let(:start_date) { Time.utc(2022, 2, 8) } + context "when the form is for before 2023/24" do + let(:start_date) { Time.zone.local(2022, 4, 8) } it "does not show a guidance_partial" do expect(question.guidance_partial).to eq(nil) diff --git a/spec/models/form/sales/questions/outright_ownership_type_spec.rb b/spec/models/form/sales/questions/outright_ownership_type_spec.rb index cad27f3d8..42804f938 100644 --- a/spec/models/form/sales/questions/outright_ownership_type_spec.rb +++ b/spec/models/form/sales/questions/outright_ownership_type_spec.rb @@ -47,8 +47,8 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do end describe "partial guidance" do - context "when the form is for year 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } + context "when the form is for year 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 8) } it "has the correct guidance_partial" do expect(question.guidance_partial).to eq("outright_sale_type_definitions") @@ -60,8 +60,8 @@ RSpec.describe Form::Sales::Questions::OutrightOwnershipType, type: :model do end end - context "when the form is for before year 2023" do - let(:start_date) { Time.utc(2022, 2, 8) } + context "when the form is for before year 2023/24" do + let(:start_date) { Time.zone.local(2022, 4, 8) } it "does not display a guidance partial" do expect(question.guidance_partial).to eq(nil) diff --git a/spec/models/form/sales/questions/shared_ownership_type_spec.rb b/spec/models/form/sales/questions/shared_ownership_type_spec.rb index a00c552f7..ce8a73842 100644 --- a/spec/models/form/sales/questions/shared_ownership_type_spec.rb +++ b/spec/models/form/sales/questions/shared_ownership_type_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:start_date) { Time.utc(2022, 4, 1) } + let(:start_date) { Time.zone.local(2022, 4, 1) } let(:form) { instance_double(Form, start_date:) } let(:subsection) { instance_double(Form::Subsection, form:) } let(:page) { instance_double(Form::Page, subsection:) } @@ -38,7 +38,8 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do expect(question.hint_text).to eq("A shared ownership sale is when the purchaser buys up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion") end - context "when form start date is 2022" do + context "when form start date is 2022/23" do + let(:start_date) { Time.zone.local(2022, 4, 1) } it "has the correct answer_options" do expect(question.answer_options).to eq({ "2" => { "value" => "Shared Ownership" }, @@ -56,8 +57,8 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do end end - context "when form start date is 2023" do - let(:start_date) { Time.utc(2023, 4, 2) } + context "when form start date is 2023/24" do + let(:start_date) { Time.zone.local(2023, 4, 2) } it "has the correct answer_options" do expect(question.answer_options).to eq({