diff --git a/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb index b631875c7a..67ea98b968 100644 --- a/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb +++ b/app/controllers/assessor_interface/assessment_recommendation_verify_controller.rb @@ -36,6 +36,7 @@ def update application_form.qualifications.where( id: session[:qualification_ids], ), + qualifications_assessor_note: session[:qualifications_assessor_note], work_histories: application_form.work_histories.where(id: session[:work_history_ids]), ) @@ -94,8 +95,9 @@ def edit_qualification_requests @form = SelectQualificationsForm.new( application_form:, - session:, qualification_ids: application_form.qualifications.pluck(:id), + qualifications_assessor_note: assessment.qualifications_assessor_note, + session:, ) end @@ -108,11 +110,18 @@ def update_qualification_requests :qualification_ids, ).compact_blank + qualifications_assessor_note = + params.dig( + :assessor_interface_select_qualifications_form, + :qualifications_assessor_note, + ) || "" + @form = SelectQualificationsForm.new( application_form:, - session:, qualification_ids:, + qualifications_assessor_note:, + session:, ) if @form.save diff --git a/app/forms/assessor_interface/select_qualifications_form.rb b/app/forms/assessor_interface/select_qualifications_form.rb index 369122d781..51501794d9 100644 --- a/app/forms/assessor_interface/select_qualifications_form.rb +++ b/app/forms/assessor_interface/select_qualifications_form.rb @@ -21,9 +21,12 @@ class AssessorInterface::SelectQualificationsForm end, } + attribute :qualifications_assessor_note + def save return false unless valid? session[:qualification_ids] = qualification_ids + session[:qualifications_assessor_note] = qualifications_assessor_note true end end diff --git a/app/services/verify_assessment.rb b/app/services/verify_assessment.rb index c743540578..b5ed5ea040 100644 --- a/app/services/verify_assessment.rb +++ b/app/services/verify_assessment.rb @@ -8,12 +8,14 @@ def initialize( user:, professional_standing:, qualifications:, + qualifications_assessor_note:, work_histories: ) @assessment = assessment @user = user @professional_standing = professional_standing @qualifications = qualifications + @qualifications_assessor_note = qualifications_assessor_note @work_histories = work_histories end @@ -22,6 +24,7 @@ def call reference_requests = ActiveRecord::Base.transaction do + assessment.qualifications_assessor_note = qualifications_assessor_note assessment.verify! create_professional_standing_request @@ -49,6 +52,7 @@ class AlreadyVerified < StandardError :user, :professional_standing, :qualifications, + :qualifications_assessor_note, :work_histories delegate :application_form, to: :assessment diff --git a/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb b/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb index 981fcaf2f8..7e407677e6 100644 --- a/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb +++ b/app/views/assessor_interface/assessment_recommendation_verify/edit_qualification_requests.html.erb @@ -17,6 +17,8 @@ small: true, legend: nil %> + <%= f.govuk_text_area :qualifications_assessor_note %> + <%= govuk_inset_text do %>

You can deselect 1 or more qualifications from the list if you do not want to verify them. diff --git a/config/locales/helpers.en.yml b/config/locales/helpers.en.yml index a2476c2488..a4abf79220 100644 --- a/config/locales/helpers.en.yml +++ b/config/locales/helpers.en.yml @@ -126,6 +126,8 @@ en: received_options: true: Response received and not valid false: Response not received + assessor_interface_select_qualifications_form: + qualifications_assessor_note: "Internal note: Add any explanatory notes for admins." assessor_interface_verify_professional_standing_form: verify_professional_standing_options: true: Yes, verify LoPS diff --git a/spec/forms/assessor_interface/select_qualifications_form_spec.rb b/spec/forms/assessor_interface/select_qualifications_form_spec.rb index 9697d9975a..e260f58141 100644 --- a/spec/forms/assessor_interface/select_qualifications_form_spec.rb +++ b/spec/forms/assessor_interface/select_qualifications_form_spec.rb @@ -12,9 +12,15 @@ end let(:session) { {} } let(:qualification_ids) { "" } + let(:qualifications_assessor_note) { "A note." } subject(:form) do - described_class.new(application_form:, session:, qualification_ids:) + described_class.new( + application_form:, + session:, + qualification_ids:, + qualifications_assessor_note:, + ) end describe "validations" do @@ -26,6 +32,9 @@ [qualification_1.id.to_s, qualification_2.id.to_s], ) end + it do + is_expected.to_not validate_presence_of(:qualifications_assessor_note) + end end describe "#save" do @@ -37,10 +46,16 @@ it { is_expected.to be true } - it "changes the session" do + it "sets the qualification IDs" do expect { save }.to change { session[:qualification_ids] }.to( [qualification_1.id.to_s, qualification_2.id.to_s], ) end + + it "sets the qualifications assessor note" do + expect { save }.to change { session[:qualifications_assessor_note] }.to( + "A note.", + ) + end end end diff --git a/spec/services/verify_assessment_spec.rb b/spec/services/verify_assessment_spec.rb index 68ab2f311b..4309b9f84f 100644 --- a/spec/services/verify_assessment_spec.rb +++ b/spec/services/verify_assessment_spec.rb @@ -8,6 +8,7 @@ let(:user) { create(:staff, :confirmed) } let(:professional_standing) { true } let(:qualification) { create(:qualification, :completed, application_form:) } + let(:qualifications_assessor_note) { "A note." } let(:work_history) { create(:work_history, :completed, application_form:) } subject(:call) do @@ -16,6 +17,7 @@ user:, professional_standing:, qualifications: [qualification], + qualifications_assessor_note:, work_histories: [work_history], ) end @@ -101,6 +103,12 @@ end end + it "changes the assessment qualifications assessor note" do + expect { call }.to change(assessment, :qualifications_assessor_note).to( + "A note.", + ) + end + it "changes the application form stage" do expect { call }.to change(application_form, :stage).to("verification") end diff --git a/spec/support/autoload/page_objects/assessor_interface/qualification_requests_assessment_recommendation_verify.rb b/spec/support/autoload/page_objects/assessor_interface/qualification_requests_assessment_recommendation_verify.rb index e1ed3d7e4e..2175f7fd78 100644 --- a/spec/support/autoload/page_objects/assessor_interface/qualification_requests_assessment_recommendation_verify.rb +++ b/spec/support/autoload/page_objects/assessor_interface/qualification_requests_assessment_recommendation_verify.rb @@ -12,6 +12,7 @@ class QualificationRequestsAssessmentRecommendationVerify < SitePrism::Page sections :qualification_checkboxes, GovukCheckboxItem, ".govuk-checkboxes__item" + element :qualifications_assessor_note_textarea, ".govuk-textarea" element :submit_button, ".govuk-button" end end diff --git a/spec/system/assessor_interface/completing_assessment_spec.rb b/spec/system/assessor_interface/completing_assessment_spec.rb index 45d68b8511..179654b085 100644 --- a/spec/system/assessor_interface/completing_assessment_spec.rb +++ b/spec/system/assessor_interface/completing_assessment_spec.rb @@ -331,10 +331,11 @@ def when_i_select_yes_verify_qualifications end def when_i_select_the_qualifications - assessor_qualification_requests_assessment_recommendation_verify_page - .form - .submit_button - .click + form = + assessor_qualification_requests_assessment_recommendation_verify_page.form + + form.qualifications_assessor_note_textarea.fill_in with: "A note." + form.submit_button.click end def when_i_select_yes_verify_professional_standing