From 5c0572d062fbe4a904e9fa231f6b4afc0a5abeeb Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Sun, 18 Feb 2024 11:37:55 +0100 Subject: [PATCH] Add index consent method --- .../qualification_requests_controller.rb | 9 ++++-- .../qualification_request_policy.rb | 4 +++ .../qualification_requests_view_object.rb | 28 ++++++++++------- .../index_consent_methods.html.erb | 30 +++++++++++++++++++ config/routes.rb | 2 ++ .../qualification_request_policy_spec.rb | 5 ++++ .../qualification_requests.rb | 5 +--- .../qualification_requests_consent_methods.rb | 12 ++++++++ spec/support/page_helpers.rb | 5 ++++ .../verifying_qualifications_spec.rb | 18 +++++++++-- ...qualification_requests_view_object_spec.rb | 16 ++++++++-- 11 files changed, 114 insertions(+), 20 deletions(-) create mode 100644 app/views/assessor_interface/qualification_requests/index_consent_methods.html.erb create mode 100644 spec/support/autoload/page_objects/assessor_interface/qualification_requests_consent_methods.rb diff --git a/app/controllers/assessor_interface/qualification_requests_controller.rb b/app/controllers/assessor_interface/qualification_requests_controller.rb index 49da2eb45b..74ca1a4d17 100644 --- a/app/controllers/assessor_interface/qualification_requests_controller.rb +++ b/app/controllers/assessor_interface/qualification_requests_controller.rb @@ -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 @@ -14,6 +16,9 @@ def index ) end + def index_consent_methods + end + def consent_letter send_data( ConsentLetter.new(application_form:).render_pdf, diff --git a/app/policies/assessor_interface/qualification_request_policy.rb b/app/policies/assessor_interface/qualification_request_policy.rb index 8377ee4564..cab8dd49ec 100644 --- a/app/policies/assessor_interface/qualification_request_policy.rb +++ b/app/policies/assessor_interface/qualification_request_policy.rb @@ -5,6 +5,10 @@ def index? true end + def index_consent_methods? + user.assess_permission + end + def consent_letter? user.verify_permission end diff --git a/app/view_objects/assessor_interface/qualification_requests_view_object.rb b/app/view_objects/assessor_interface/qualification_requests_view_object.rb index 1f3f7877ec..f8d14490ef 100644 --- a/app/view_objects/assessor_interface/qualification_requests_view_object.rb +++ b/app/view_objects/assessor_interface/qualification_requests_view_object.rb @@ -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? diff --git a/app/views/assessor_interface/qualification_requests/index_consent_methods.html.erb b/app/views/assessor_interface/qualification_requests/index_consent_methods.html.erb new file mode 100644 index 0000000000..fc1ee05122 --- /dev/null +++ b/app/views/assessor_interface/qualification_requests/index_consent_methods.html.erb @@ -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) %> + +

Check consent method

+ +

You need to:

+ + + +

If the consent method required is the non-signed TRA consent document you can generate that later.

+ +

<%= "Qualification".pluralize(@qualification_requests.count) %> requiring consent

+ + + +<% if (qualifications_assessor_note = @assessment.qualifications_assessor_note).present? %> +

<%= qualifications_assessor_note %>

+<% end %> + +
+ <%= govuk_link_to "Cancel", [:assessor_interface, @application_form, @assessment, :qualification_requests] %> +
diff --git a/config/routes.rb b/config/routes.rb index 2589e854a2..da6826ac0e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/policies/assessor_interface/qualification_request_policy_spec.rb b/spec/policies/assessor_interface/qualification_request_policy_spec.rb index 36e4197bf7..3f37b983d7 100644 --- a/spec/policies/assessor_interface/qualification_request_policy_spec.rb +++ b/spec/policies/assessor_interface/qualification_request_policy_spec.rb @@ -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" diff --git a/spec/support/autoload/page_objects/assessor_interface/qualification_requests.rb b/spec/support/autoload/page_objects/assessor_interface/qualification_requests.rb index 9972942a15..2cea58c95a 100644 --- a/spec/support/autoload/page_objects/assessor_interface/qualification_requests.rb +++ b/spec/support/autoload/page_objects/assessor_interface/qualification_requests.rb @@ -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 diff --git a/spec/support/autoload/page_objects/assessor_interface/qualification_requests_consent_methods.rb b/spec/support/autoload/page_objects/assessor_interface/qualification_requests_consent_methods.rb new file mode 100644 index 0000000000..2c2515d6ea --- /dev/null +++ b/spec/support/autoload/page_objects/assessor_interface/qualification_requests_consent_methods.rb @@ -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 diff --git a/spec/support/page_helpers.rb b/spec/support/page_helpers.rb index 82ef9a21f9..9c9898c622 100644 --- a/spec/support/page_helpers.rb +++ b/spec/support/page_helpers.rb @@ -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 diff --git a/spec/system/assessor_interface/verifying_qualifications_spec.rb b/spec/system/assessor_interface/verifying_qualifications_spec.rb index 78b205d8d2..5c054d9fad 100644 --- a/spec/system/assessor_interface/verifying_qualifications_spec.rb +++ b/spec/system/assessor_interface/verifying_qualifications_spec.rb @@ -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 @@ -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 diff --git a/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb b/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb index 615237b38c..de1643c51c 100644 --- a/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb @@ -32,7 +32,13 @@ [ { name: "Check and select consent method", - link: "#", + link: [ + :consent_methods, + :assessor_interface, + application_form, + assessment, + :qualification_requests, + ], status: "not_started", }, ], @@ -47,7 +53,13 @@ [ { name: "Check and select consent method", - link: "#", + link: [ + :consent_methods, + :assessor_interface, + application_form, + assessment, + :qualification_requests, + ], status: "completed", }, {