From 3a9dd9ad366d20d24df783570c50028ad3f26761 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 15 Feb 2024 10:12:50 +0100 Subject: [PATCH] Replace reference to signed_consent_document_required This column has gone now and been replaced with the consent_method column. --- app/mailers/teacher_mailer.rb | 12 ++++++++++-- app/models/document.rb | 2 +- app/models/qualification_request.rb | 10 +++++++++- .../application_form_view_object.rb | 2 +- spec/factories/qualification_requests.rb | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/mailers/teacher_mailer.rb b/app/mailers/teacher_mailer.rb index 7c83828e3a..81898ed6e4 100644 --- a/app/mailers/teacher_mailer.rb +++ b/app/mailers/teacher_mailer.rb @@ -58,7 +58,11 @@ def application_received def consent_reminder @expires_at = - assessment.qualification_requests.consent_required.map(&:expires_at).max + assessment + .qualification_requests + .signed_consent_required + .map(&:expires_at) + .max view_mail( GOVUK_NOTIFY_TEMPLATE_ID, @@ -69,7 +73,11 @@ def consent_reminder def consent_requested @expires_at = - assessment.qualification_requests.consent_required.map(&:expires_at).max + assessment + .qualification_requests + .signed_consent_required + .map(&:expires_at) + .max view_mail( GOVUK_NOTIFY_TEMPLATE_ID, diff --git a/app/models/document.rb b/app/models/document.rb index 1179fd742c..1dd7acba80 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -68,7 +68,7 @@ def allow_multiple_uploads? end def optional? - (signed_consent? && !documentable.signed_consent_document_required) || + (signed_consent? && !documentable.signed_consent_required?) || (written_statement? && application_form.written_statement_optional) end diff --git a/app/models/qualification_request.rb b/app/models/qualification_request.rb index 621ead6d8a..2cf97951be 100644 --- a/app/models/qualification_request.rb +++ b/app/models/qualification_request.rb @@ -50,7 +50,11 @@ class QualificationRequest < ApplicationRecord }, _prefix: true - scope :consent_required, -> { where(signed_consent_document_required: true) } + scope :signed_consent_required, + -> do + consent_method_signed_ecctis.or(consent_method_signed_institution) + end + scope :consent_requested, -> { where.not(consent_requested_at: nil) } scope :consent_received, -> { where.not(consent_received_at: nil) } scope :consent_respondable, @@ -70,6 +74,10 @@ def expires_after 6.weeks end + def signed_consent_required? + consent_method_signed_custom? || consent_method_signed_ecctis? + end + def consent_requested! update!(consent_requested_at: Time.zone.now) end diff --git a/app/view_objects/teacher_interface/application_form_view_object.rb b/app/view_objects/teacher_interface/application_form_view_object.rb index 46c87d7339..d826c0fb7a 100644 --- a/app/view_objects/teacher_interface/application_form_view_object.rb +++ b/app/view_objects/teacher_interface/application_form_view_object.rb @@ -156,7 +156,7 @@ def qualification_consent_submitted? return false if assessment.nil? required_qualification_requests = - qualification_requests.where(signed_consent_document_required: true) + qualification_requests.signed_consent_required return false if required_qualification_requests.empty? diff --git a/spec/factories/qualification_requests.rb b/spec/factories/qualification_requests.rb index 54dc5fa362..067f2b5d2b 100644 --- a/spec/factories/qualification_requests.rb +++ b/spec/factories/qualification_requests.rb @@ -40,7 +40,7 @@ association :qualification, :completed trait :consent_required do - signed_consent_document_required { true } + consent_method { %i[signed_ecctis signed_institution].sample } after(:create) do |qualification_request, _evaluator| create(