Skip to content

Commit

Permalink
Add consent submission page
Browse files Browse the repository at this point in the history
This adds the final page of the consent flow allowing assessors to
submit the consent and send emails.
  • Loading branch information
thomasleese committed Feb 19, 2024
1 parent f69de51 commit df91dc1
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
module AssessorInterface
class QualificationRequestsController < BaseController
before_action :set_collection_variables,
only: %i[index index_consent_methods consent_letter]
only: %i[
index
index_consent_methods
check_consent_methods
submit_consent_methods
consent_letter
]
before_action :set_member_variables,
only: %i[
edit
Expand All @@ -15,6 +21,7 @@ class QualificationRequestsController < BaseController
]

define_history_origin :index
define_history_check :check_consent_methods

def index
@view_object =
Expand All @@ -26,6 +33,30 @@ def index
def index_consent_methods
end

def check_consent_methods
end

def submit_consent_methods
requested_qualification_requests =
ActiveRecord::Base.transaction do
qualification_requests
.reject(&:consent_requested?)
.select(&:signed_consent_required?)
.each(&:consent_requested!)
end

if requested_qualification_requests.present?
TeacherMailer.with(application_form:).consent_requested.deliver_later
end

redirect_to [
:assessor_interface,
application_form,
assessment,
:qualification_requests,
]
end

def consent_letter
send_data(
ConsentLetter.new(application_form:).render_pdf,
Expand Down Expand Up @@ -116,7 +147,7 @@ def update_consent_method
]
else
redirect_to [
:check_consent_method,
:check_consent_methods,
:assessor_interface,
application_form,
assessment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ def index_consent_methods?
user.assess_permission
end

def check_consent_methods?
user.assess_permission
end

def submit_consent_methods?
user.assess_permission
end

def consent_letter?
user.verify_permission
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<% title = "Consent methods selected" %>

<% content_for :page_title, title %>
<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_assessment_qualification_requests_path) %>

<h1 class="govuk-heading-l"><%= title %></h1>

<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Qualification
</dt>

<dt class="govuk-summary-list__key">
Consent method
</dt>

<dd class="govuk-summary-list__actions"></dd>
</div>

<% @qualification_requests.each do |qualification_request| %>
<div class="govuk-summary-list__row">
<dd class="govuk-summary-list__value">
<%= qualification_title(qualification_request.qualification) %>
</dd>
<dd class="govuk-summary-list__value">
<%= t(qualification_request.consent_method, scope: %i[helpers label assessor_interface_consent_method_form consent_method_options]) %>
</dd>
<dd class="govuk-summary-list__actions" style="vertical-align: middle;">
<a class="govuk-link" href="<%= consent_method_assessor_interface_application_form_assessment_qualification_request_path(@application_form, @assessment, qualification_request) %>">
Change<span class="govuk-visually-hidden"> name</span>
</a>
</dd>
</div>
<% end %>
</dl>

<%= form_with model: @form, url: [:submit_consent_methods, :assessor_interface, @application_form, @assessment, :qualification_requests] do |f| %>
<%= render "shared/assessor_interface/continue_cancel_button", f: %>
<% end %>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
get "consent-letter", to: "qualification_requests#consent_letter"
get "consent-methods",
to: "qualification_requests#index_consent_methods"
get "check-consent-methods",
to: "qualification_requests#check_consent_methods"
post "submit-consent-methods",
to: "qualification_requests#submit_consent_methods"
end

member do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
it_behaves_like "a policy method requiring the assess permission"
end

describe "#check_consent_methods?" do
subject(:index?) { policy.check_consent_methods? }
it_behaves_like "a policy method requiring the assess permission"
end

describe "#submit_consent_methods?" do
subject(:index?) { policy.submit_consent_methods? }
it_behaves_like "a policy method requiring the assess permission"
end

describe "#show?" do
subject(:show?) { policy.show? }
it_behaves_like "a policy method without permission"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module PageObjects
module AssessorInterface
class QualificationRequestsCheckConsentMethods < SitePrism::Page
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \
"/qualification-requests/check-consent-methods"

element :continue_button, ".govuk-button:not(.govuk-button--secondary)"
end
end
end
5 changes: 5 additions & 0 deletions spec/support/page_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ def assessor_qualification_requests_assessment_recommendation_verify_page
PageObjects::AssessorInterface::QualificationRequestsAssessmentRecommendationVerify.new
end

def assessor_qualification_requests_check_consent_methods_page
@assessor_qualification_requests_check_consent_methods_page ||=
PageObjects::AssessorInterface::QualificationRequestsCheckConsentMethods.new
end

def assessor_qualification_requests_consent_methods_page
@assessor_qualification_requests_consent_methods_page ||=
PageObjects::AssessorInterface::QualificationRequestsConsentMethods.new
Expand Down
19 changes: 14 additions & 5 deletions spec/system/assessor_interface/verifying_qualifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
then_i_see_the(:assessor_consent_qualification_request_page)

when_i_choose_the_consent_method
then_i_see_the(:assessor_qualification_requests_check_consent_methods_page)

when_i_visit_the(
:assessor_qualification_requests_page,
reference:,
assessment_id: application_form.assessment.id,
)
when_i_confirm_the_consent_methods
then_i_see_the(:assessor_qualification_requests_page, reference:)
and_the_check_and_select_consent_method_task_is_completed
and_i_go_back_to_overview
then_i_see_the(:assessor_application_page, reference:)
end
Expand Down Expand Up @@ -62,6 +61,16 @@ def when_i_choose_the_consent_method
form.submit_button.click
end

def when_i_confirm_the_consent_methods
assessor_qualification_requests_check_consent_methods_page.continue_button.click
end

def and_the_check_and_select_consent_method_task_is_completed
expect(check_and_select_consent_method_task_item.status_tag.text).to eq(
"COMPLETED",
)
end

def and_i_go_back_to_overview
assessor_qualification_requests_page.continue_button.click
end
Expand Down

0 comments on commit df91dc1

Please sign in to comment.