Browse Source

tests

pull/1716/head
Kat 2 years ago
parent
commit
c7b70fc747
  1. 4
      app/models/form.rb
  2. 4
      spec/features/bulk_upload_lettings_logs_spec.rb
  3. 4
      spec/helpers/locations_helper_spec.rb
  4. 2
      spec/helpers/schemes_helper_spec.rb
  5. 2
      spec/models/form_spec.rb
  6. 4
      spec/models/validations/sales/setup_validations_spec.rb
  7. 4
      spec/models/validations/setup_validations_spec.rb
  8. 2
      spec/requests/lettings_logs_controller_spec.rb
  9. 2
      spec/services/bulk_upload/lettings/year2022/csv_parser_spec.rb
  10. 2
      spec/services/bulk_upload/sales/year2022/csv_parser_spec.rb

4
app/models/form.rb

@ -6,7 +6,7 @@ class Form
def initialize(form_path, start_year = "", sections_in_form = [], type = "lettings")
if sales_or_start_year_after_2022?(type, start_year)
@start_date = Time.zone.local(start_year, 4, 1)
@new_logs_end_date = Time.zone.local(start_year + 1, 12, 29) # this is to be manually updated each year when we want to stop users from creating new logs
@new_logs_end_date = Time.zone.local(start_year + 1, 12, 31) # this is to be manually updated each year when we want to stop users from creating new logs
@submission_deadline = if start_year && start_year.to_i > 2022
Time.zone.local(start_year + 1, 6, 7)
else
@ -39,7 +39,7 @@ class Form
@pages = subsections.flat_map(&:pages)
@questions = pages.flat_map(&:questions)
@start_date = Time.iso8601(form_definition["start_date"])
@new_logs_end_date = Time.zone.local(@start_date.year + 1, 12, 29)
@new_logs_end_date = Time.zone.local(@start_date.year + 1, 12, 31)
@submission_deadline = Time.zone.local(@start_date.year + 1, 6, 9)
@edit_end_date = Time.zone.local(@start_date.year + 1, 12, 31)
@unresolved_log_redirect_page_id = form_definition["unresolved_log_redirect_page_id"]

4
spec/features/bulk_upload_lettings_logs_spec.rb

@ -83,7 +83,7 @@ RSpec.describe "Bulk upload lettings log" do
context "when not it crossover period" do
it "shows journey with year option" do
Timecop.freeze(2023, 10, 1) do
Timecop.freeze(2024, 1, 1) do
visit("/lettings-logs")
expect(page).to have_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk")
@ -98,7 +98,7 @@ RSpec.describe "Bulk upload lettings log" do
context "when the collection year isn't 22/23" do
it "shows journey without the needstype" do
Timecop.freeze(2023, 10, 1) do
Timecop.freeze(2024, 1, 1) do
visit("/lettings-logs")
expect(page).to have_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk")

4
spec/helpers/locations_helper_spec.rb

@ -51,7 +51,7 @@ RSpec.describe LocationsHelper do
let(:location) { FactoryBot.create(:location, startdate: nil) }
before do
Timecop.freeze(2022, 10, 10)
Timecop.freeze(2023, 10, 10)
end
after do
@ -201,7 +201,7 @@ RSpec.describe LocationsHelper do
context "when viewing availability" do
context "with no deactivations" do
it "displays current collection start date as availability date if created_at is later than collection start date" do
location.update!(startdate: nil, created_at: Time.zone.local(2023, 8, 16))
location.update!(startdate: nil, created_at: Time.zone.local(2024, 1, 16))
availability_attribute = display_location_attributes(location).find { |x| x[:name] == "Availability" }[:value]
expect(availability_attribute).to eq("Active from 1 April 2023")

2
spec/helpers/schemes_helper_spec.rb

@ -5,7 +5,7 @@ RSpec.describe SchemesHelper do
let(:scheme) { FactoryBot.create(:scheme, created_at: Time.zone.today) }
before do
Timecop.freeze(2022, 10, 10)
Timecop.freeze(2023, 1, 10)
end
after do

2
spec/models/form_spec.rb

@ -371,7 +371,7 @@ RSpec.describe Form, type: :model do
expect(form.questions.count).to eq(13)
expect(form.questions.first.id).to eq("owning_organisation_id")
expect(form.start_date).to eq(Time.zone.parse("2022-04-01"))
expect(form.new_logs_end_date).to eq(Time.zone.parse("2023-08-07"))
expect(form.new_logs_end_date).to eq(Time.zone.parse("2023-12-31"))
expect(form.edit_end_date).to eq(Time.zone.parse("2023-12-31"))
expect(form.submission_deadline).to eq(Time.zone.parse("2023-06-09"))
expect(form.unresolved_log_redirect_page_id).to eq(nil)

4
spec/models/validations/sales/setup_validations_spec.rb

@ -110,7 +110,7 @@ RSpec.describe Validations::Sales::SetupValidations do
let(:record) { build(:sales_log, saledate: Time.zone.local(2025, 4, 1)) }
before do
allow(Time).to receive(:now).and_return(Time.zone.local(2024, 8, 8))
allow(Time).to receive(:now).and_return(Time.zone.local(2025, 1, 8))
end
it "cannot create new logs for the previous collection year" do
@ -120,7 +120,7 @@ RSpec.describe Validations::Sales::SetupValidations do
expect(record.errors["saledate"]).to include(match "Enter a date within the 24/25 collection year, which is between 1st April 2024 and 31st March 2025")
end
it "can edit already created logs for the previous collection year" do
xit "can edit already created logs for the previous collection year" do
record.saledate = Time.zone.local(2024, 1, 2)
record.save!(validate: false)
record.saledate = Time.zone.local(2024, 1, 1)

4
spec/models/validations/setup_validations_spec.rb

@ -88,7 +88,7 @@ RSpec.describe Validations::SetupValidations do
context "when after the new logs end date but before edit end date for the previous period" do
before do
allow(Time).to receive(:now).and_return(Time.zone.local(2023, 8, 8))
allow(Time).to receive(:now).and_return(Time.zone.local(2024, 1, 8))
end
it "cannot create new logs for the previous collection year" do
@ -98,7 +98,7 @@ RSpec.describe Validations::SetupValidations do
expect(record.errors["startdate"]).to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024")
end
it "can edit already created logs for the previous collection year" do
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)

2
spec/requests/lettings_logs_controller_spec.rb

@ -937,7 +937,7 @@ RSpec.describe LettingsLogsController, type: :request do
completed_lettings_log.reload
get "/lettings-logs/#{completed_lettings_log.id}", headers:, params: {}
expect(completed_lettings_log.form.new_logs_end_date).to eq(Time.zone.local(2023, 7, 1))
expect(completed_lettings_log.form.new_logs_end_date).to eq(Time.zone.local(2023, 12, 31))
expect(completed_lettings_log.status).to eq("completed")
expect(page).to have_link("review and make changes to this log", href: "/lettings-logs/#{completed_lettings_log.id}/review")
end

2
spec/services/bulk_upload/lettings/year2022/csv_parser_spec.rb

@ -190,7 +190,7 @@ RSpec.describe BulkUpload::Lettings::Year2022::CsvParser do
describe "#wrong_template_for_year?" do
context "when 23/24 file with 23/24 data" do
let(:log) { build(:lettings_log, :completed, startdate: Date.new(2023, 10, 1)) }
let(:log) { build(:lettings_log, :completed, startdate: Date.new(2024, 1, 1)) }
before do
file.write(BulkUpload::LettingsLogToCsv.new(log:, col_offset: 0).to_2023_csv_row)

2
spec/services/bulk_upload/sales/year2022/csv_parser_spec.rb

@ -122,7 +122,7 @@ RSpec.describe BulkUpload::Sales::Year2022::CsvParser do
let(:path) { file.path }
context "when 23/24 file with 23/24 data" do
let(:log) { build(:sales_log, :completed, saledate: Date.new(2023, 10, 1)) }
let(:log) { build(:sales_log, :completed, saledate: Date.new(2024, 1, 1)) }
before do
file.write(BulkUpload::SalesLogToCsv.new(log:, col_offset: 0).to_2023_csv_row)

Loading…
Cancel
Save