Skip to content

Commit

Permalink
Replace reference to signed_consent_document_required
Browse files Browse the repository at this point in the history
This column has gone now and been replaced with the consent_method
column.
  • Loading branch information
thomasleese committed Feb 15, 2024
1 parent 8715d12 commit 3a9dd9a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
12 changes: 10 additions & 2 deletions app/mailers/teacher_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion app/models/qualification_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/qualification_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 3a9dd9a

Please sign in to comment.