From 9ae7e6a7a0c53de68eb14fa2e699266f480883e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:00:24 +0000 Subject: [PATCH 1/4] Bump syntax_tree from 6.1.1 to 6.2.0 Bumps [syntax_tree](https://github.com/kddnewton/syntax_tree) from 6.1.1 to 6.2.0. - [Changelog](https://github.com/ruby-syntax-tree/syntax_tree/blob/main/CHANGELOG.md) - [Commits](https://github.com/kddnewton/syntax_tree/compare/v6.1.1...v6.2.0) --- updated-dependencies: - dependency-name: syntax_tree dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1ae55d6517..00f5748859 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -504,7 +504,7 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - syntax_tree (6.1.1) + syntax_tree (6.2.0) prettier_print (>= 1.2.0) syntax_tree-haml (4.0.3) haml (>= 5.2) From f30d564b9bd31997cb8afc0aeef4a48aafe2c77f Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Sun, 24 Sep 2023 11:39:29 +0100 Subject: [PATCH 2/4] Lint code This updates the code according to the latest linting rules. --- .../assessor_interface/assessment_section_form.rb | 4 ++-- .../assessor_interface/select_qualifications_form.rb | 4 ++-- .../assessor_interface/select_work_histories_form.rb | 4 ++-- app/forms/teacher_interface/qualification_form.rb | 4 ++-- app/models/application_form.rb | 12 ++++++------ app/models/eligibility_check.rb | 12 ++++++------ app/models/further_information_request.rb | 4 ++-- app/models/reference_request.rb | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/forms/assessor_interface/assessment_section_form.rb b/app/forms/assessor_interface/assessment_section_form.rb index eae6f1aabc..7625c367ac 100644 --- a/app/forms/assessor_interface/assessment_section_form.rb +++ b/app/forms/assessor_interface/assessment_section_form.rb @@ -17,12 +17,12 @@ class AssessorInterface::AssessmentSectionForm if: -> { passed == false } validates :work_history, presence: true, - if: -> { + if: -> do passed == false && FailureReasons.chooses_work_history?( failure_reason: selected_failure_reasons, ) - } + end def selected_failure_reasons return {} if passed diff --git a/app/forms/assessor_interface/select_qualifications_form.rb b/app/forms/assessor_interface/select_qualifications_form.rb index eb072fcfb1..369122d781 100644 --- a/app/forms/assessor_interface/select_qualifications_form.rb +++ b/app/forms/assessor_interface/select_qualifications_form.rb @@ -12,13 +12,13 @@ class AssessorInterface::SelectQualificationsForm validates :qualification_ids, presence: true, inclusion: { - in: ->(form) { + in: ->(form) do form .application_form &.qualifications &.pluck(:id) &.map(&:to_s) || [] - }, + end, } def save diff --git a/app/forms/assessor_interface/select_work_histories_form.rb b/app/forms/assessor_interface/select_work_histories_form.rb index c8720f82f9..4b2e1d00b3 100644 --- a/app/forms/assessor_interface/select_work_histories_form.rb +++ b/app/forms/assessor_interface/select_work_histories_form.rb @@ -11,13 +11,13 @@ class AssessorInterface::SelectWorkHistoriesForm attribute :work_history_ids validates :work_history_ids, inclusion: { - in: ->(form) { + in: ->(form) do form .application_form &.work_histories &.pluck(:id) &.map(&:to_s) || [] - }, + end, } validate :work_history_enough_months diff --git a/app/forms/teacher_interface/qualification_form.rb b/app/forms/teacher_interface/qualification_form.rb index abafbb6981..2f9a9bace5 100644 --- a/app/forms/teacher_interface/qualification_form.rb +++ b/app/forms/teacher_interface/qualification_form.rb @@ -19,9 +19,9 @@ class QualificationForm < BaseForm validates :institution_country_location, presence: true, inclusion: { - in: ->(form) { + in: ->(form) do [CountryCode.to_location(form.application_form.country.code)] - }, + end, }, if: -> { qualification&.is_teaching_qualification? } validates :start_date, date: true diff --git a/app/models/application_form.rb b/app/models/application_form.rb index f255a59dbd..96aecc50df 100644 --- a/app/models/application_form.rb +++ b/app/models/application_form.rb @@ -160,7 +160,7 @@ class ApplicationForm < ApplicationRecord STATUS_COLUMNS.each { |column| enum column, STATUS_VALUES, prefix: column } scope :assessable, - -> { + -> do where( status: %i[ preliminary_check @@ -171,26 +171,26 @@ class ApplicationForm < ApplicationRecord overdue ], ) - } + end scope :active, - -> { + -> do assessable .or(awarded_pending_checks) .or(potential_duplicate_in_dqt) .or(awarded.where("awarded_at >= ?", 90.days.ago)) .or(declined.where("declined_at >= ?", 90.days.ago)) .or(withdrawn.where("withdrawn_at >= ?", 90.days.ago)) - } + end scope :destroyable, - -> { + -> do draft .where("created_at < ?", 6.months.ago) .or(awarded.where("awarded_at < ?", 5.years.ago)) .or(declined.where("declined_at < ?", 5.years.ago)) .or(withdrawn.where("withdrawn_at < ?", 5.years.ago)) - } + end scope :remindable, -> { draft.where("created_at < ?", 5.months.ago) } diff --git a/app/models/eligibility_check.rb b/app/models/eligibility_check.rb index 50f85b08e8..0d2c1aa92d 100644 --- a/app/models/eligibility_check.rb +++ b/app/models/eligibility_check.rb @@ -33,31 +33,31 @@ class EligibilityCheck < ApplicationRecord scope :complete, -> { where.not(completed_at: nil) } scope :eligible, - -> { + -> do where.not(region: nil).where( degree: true, free_of_sanctions: true, qualification: true, teach_children: true, ) - } + end scope :ineligible, - -> { + -> do where(degree: false) .or(where(free_of_sanctions: false)) .or(where(qualification: false)) .or(where(region: nil)) .or(where(teach_children: false)) - } + end scope :answered_all_questions, - -> { + -> do where.not( degree: nil, free_of_sanctions: nil, qualification: nil, teach_children: nil, ) - } + end delegate :country, to: :region, allow_nil: true diff --git a/app/models/further_information_request.rb b/app/models/further_information_request.rb index 8c90349bc8..76da1017dc 100644 --- a/app/models/further_information_request.rb +++ b/app/models/further_information_request.rb @@ -29,11 +29,11 @@ class FurtherInformationRequest < ApplicationRecord dependent: :destroy scope :remindable, - -> { + -> do requested.joins(assessment: :application_form).merge( ApplicationForm.assessable, ) - } + end FOUR_WEEK_COUNTRY_CODES = %w[AU CA GI NZ US].freeze diff --git a/app/models/reference_request.rb b/app/models/reference_request.rb index 987ba182bb..4869338b21 100644 --- a/app/models/reference_request.rb +++ b/app/models/reference_request.rb @@ -55,11 +55,11 @@ class ReferenceRequest < ApplicationRecord belongs_to :work_history scope :remindable, - -> { + -> do requested.joins(assessment: :application_form).merge( ApplicationForm.assessable, ) - } + end with_options if: :received? do validates :contact_response, inclusion: [true, false] From 5186ae589fe37de3234914f3dfc60dc872775b5b Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Sun, 24 Sep 2023 11:42:09 +0100 Subject: [PATCH 3/4] Upgrade curl To ensure we're using the latest version with security updates. --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ab29433c67..04b7d3e63a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,8 @@ RUN apk add --update --no-cache tzdata && \ cp /usr/share/zoneinfo/Europe/London /etc/localtime && \ echo "Europe/London" > /etc/timezone -# Upgrade ssl and crypto libraries to latest version -RUN apk upgrade --no-cache openssl libssl3 libcrypto3 +# Upgrade ssl, crypto and curl libraries to latest version +RUN apk upgrade --no-cache openssl libssl3 libcrypto3 curl # build-base: dependencies for bundle # yarn: node package manager @@ -77,8 +77,8 @@ RUN apk add --update --no-cache tzdata && \ cp /usr/share/zoneinfo/Europe/London /etc/localtime && \ echo "Europe/London" > /etc/timezone -# Upgrade ssl and crypto libraries to latest version -RUN apk upgrade --no-cache openssl libssl3 libcrypto3 +# Upgrade ssl, crypto and curl libraries to latest version +RUN apk upgrade --no-cache openssl libssl3 libcrypto3 curl # libpq: required to run postgres # vips-dev: dependencies for ruby-vips (image processing library) From cec2b978da78d417e5177e4393d291b4a664edc8 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Sun, 24 Sep 2023 12:47:30 +0100 Subject: [PATCH 4/4] Fix "two weeks remaining" test The application form isn't configured with the correct created at date/time. --- spec/services/send_reminder_email_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/services/send_reminder_email_spec.rb b/spec/services/send_reminder_email_spec.rb index 9065afc6a0..fd84e4719b 100644 --- a/spec/services/send_reminder_email_spec.rb +++ b/spec/services/send_reminder_email_spec.rb @@ -123,7 +123,7 @@ end context "with less than two weeks remaining" do - let(:application_created_at) { (6.months - 8.days).ago } + let(:application_created_at) { (6.months - 13.days).ago } include_examples "first reminder email", "sends an application not submitted email" end