Skip to content

Commit

Permalink
Add index consent method
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese committed Feb 19, 2024
1 parent 40d2c3b commit 9ed1b9a
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

module AssessorInterface
class QualificationRequestsController < BaseController
before_action :set_collection_variables, only: %i[index consent_letter]
before_action :set_member_variables, except: %i[index consent_letter]
before_action :set_collection_variables,
only: %i[index index_consent_methods consent_letter]
before_action :set_member_variables,
only: %i[edit update edit_review update_review]

define_history_origin :index

Expand All @@ -14,6 +16,9 @@ def index
)
end

def index_consent_methods
end

def consent_letter
send_data(
ConsentLetter.new(application_form:).render_pdf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def index?
true
end

def index_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
Expand Up @@ -59,16 +59,24 @@ def all_consent_methods_selected?
end

def check_consent_method_task_item
status =
if qualification_requests.all?(&:consent_method_unknown?)
"not_started"
elsif all_consent_methods_selected?
"completed"
else
"in_progress"
end

{ name: "Check and select consent method", link: "#", status: }
{
name: "Check and select consent method",
link: [
:consent_methods,
:assessor_interface,
application_form,
assessment,
:qualification_requests,
],
status:
if qualification_requests.all?(&:consent_method_unknown?)
"not_started"
elsif all_consent_methods_selected?
"completed"
else
"in_progress"
end,
}
end

def generate_consent_document_in_all_qualifications?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<% content_for :page_title, "Check consent method" %>
<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_assessment_qualification_requests_path) %>

<h1 class="govuk-heading-l">Check consent method</h1>

<p class="govuk-body">You need to:</p>

<ul class="govuk-list govuk-list--bullet">
<li>go to the <%= govuk_link_to "Ecctis portal", "https://www.ecctis.com/login.aspx" %> to check the method of consent for each qualification</li>
<li>download any documents you may need</li>
<li>return to this page to continue</li>
</ul>

<p class="govuk-body">If the consent method required is the non-signed TRA consent document you can generate that later.</p>

<h2 class="govuk-heading-m"><%= "Qualification".pluralize(@qualification_requests.count) %> requiring consent</h2>

<ul class="govuk-list govuk-list--bullet">
<% @qualification_requests.each do |qualification_request| %>
<li><%= qualification_title(qualification_request.qualification) %></li>
<% end %>
</ul>

<% if (qualifications_assessor_note = @assessment.qualifications_assessor_note).present? %>
<p class="govuk-inset-text"><%= qualifications_assessor_note %></p>
<% end %>

<div class="govuk-button-group">
<%= govuk_link_to "Cancel", [:assessor_interface, @application_form, @assessment, :qualification_requests] %>
</div>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
only: %i[index edit update] do
collection do
get "consent-letter", to: "qualification_requests#consent_letter"
get "consent-methods",
to: "qualification_requests#index_consent_methods"
end

member do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
it_behaves_like "a policy method with permission"
end

describe "#index_consent_methods?" do
subject(:index?) { policy.index_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
Expand Up @@ -6,10 +6,7 @@ class QualificationRequests < SitePrism::Page
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \
"/qualification-requests"

section :task_list, ".app-task-list__item" do
elements :qualification_requests, ".app-task-list__task-name a"
elements :status_tags, ".app-task-list__tag"
end
section :task_list, TaskList, ".app-task-list"

element :continue_button, ".govuk-button:not(.govuk-button--secondary)"
end
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 QualificationRequestsConsentMethods < SitePrism::Page
set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \
"/qualification-requests/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 @@ -156,6 +156,11 @@ def assessor_qualification_requests_assessment_recommendation_verify_page
PageObjects::AssessorInterface::QualificationRequestsAssessmentRecommendationVerify.new
end

def assessor_qualification_requests_consent_methods_page
@assessor_qualification_requests_consent_methods_page ||=
PageObjects::AssessorInterface::QualificationRequestsConsentMethods.new
end

def assessor_qualification_requests_page
@assessor_qualification_requests_page ||=
PageObjects::AssessorInterface::QualificationRequests.new
Expand Down
18 changes: 16 additions & 2 deletions spec/system/assessor_interface/verifying_qualifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
and_i_click_the_verify_qualifications_task
then_i_see_the(:assessor_qualification_requests_page, reference:)

when_i_go_back_to_overview
when_i_click_the_check_and_select_consent_method_task
then_i_see_the(:assessor_qualification_requests_consent_methods_page)

when_i_visit_the(
:assessor_qualification_requests_page,
reference:,
assessment_id: application_form.assessment.id,
)
and_i_go_back_to_overview
then_i_see_the(:assessor_application_page, reference:)
end

Expand All @@ -28,7 +36,13 @@ def and_i_click_the_verify_qualifications_task
assessor_application_page.verify_qualifications_task.link.click
end

def when_i_go_back_to_overview
def when_i_click_the_check_and_select_consent_method_task
assessor_qualification_requests_page.task_list.click_item(
"Check and select consent method",
)
end

def and_i_go_back_to_overview
assessor_qualification_requests_page.continue_button.click
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
[
{
name: "Check and select consent method",
link: "#",
link: [
:consent_methods,
:assessor_interface,
application_form,
assessment,
:qualification_requests,
],
status: "not_started",
},
],
Expand All @@ -47,7 +53,13 @@
[
{
name: "Check and select consent method",
link: "#",
link: [
:consent_methods,
:assessor_interface,
application_form,
assessment,
:qualification_requests,
],
status: "completed",
},
{
Expand Down

0 comments on commit 9ed1b9a

Please sign in to comment.