From 5f8145c452fd40fc4626bed4c6d15e058c374cd0 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 27 Sep 2023 09:57:03 +0100 Subject: [PATCH] Don't request professional standing When verifying the assessment we shouldn't request the professional standing as that happens at a separate stage now. --- app/services/verify_assessment.rb | 13 ++++----- spec/services/verify_assessment_spec.rb | 39 ++++++++++++++++++------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/services/verify_assessment.rb b/app/services/verify_assessment.rb index 1b54c15c9d..2f7c9ef008 100644 --- a/app/services/verify_assessment.rb +++ b/app/services/verify_assessment.rb @@ -50,15 +50,14 @@ class AlreadyVerified < StandardError :work_histories delegate :application_form, to: :assessment - delegate :teacher, to: :application_form + delegate :teacher, + :teaching_authority_provides_written_statement, + to: :application_form def create_professional_standing_request - return unless professional_standing - return if application_form.teaching_authority_provides_written_statement - - ProfessionalStandingRequest - .create!(assessment:) - .tap { |requestable| RequestRequestable.call(requestable:, user:) } + if professional_standing && !teaching_authority_provides_written_statement + ProfessionalStandingRequest.create!(assessment:) + end end def create_qualification_requests diff --git a/spec/services/verify_assessment_spec.rb b/spec/services/verify_assessment_spec.rb index ffed134355..3ac03dc8ca 100644 --- a/spec/services/verify_assessment_spec.rb +++ b/spec/services/verify_assessment_spec.rb @@ -20,7 +20,7 @@ ) end - describe "when already verified" do + context "when already verified" do let(:assessment) { create(:assessment, :verify, application_form:) } it "raises an error" do @@ -28,20 +28,39 @@ end end - describe "creating professional standing request" do - subject(:professional_standing_request) do - ProfessionalStandingRequest.find_by(assessment:) + describe "professional standing request" do + context "when professional standing is true" do + let(:professional_standing) { true } + + it "creates a professional standing request" do + expect { call }.to change(ProfessionalStandingRequest, :count).by(1) + end + + it "doesn't request the professional standing" do + call + expect(assessment.professional_standing_request).to_not be_requested + end end - it { is_expected.to be_nil } + context "when professional standing is false" do + let(:professional_standing) { false } - context "after calling the service" do - before { call } + it "doesn't create a professional standing request" do + expect { call }.to_not change(ProfessionalStandingRequest, :count) + end + end - it { is_expected.to_not be_nil } + context "when the teaching authority provides the professional standing" do + let(:application_form) do + create( + :application_form, + :submitted, + :teaching_authority_provides_written_statement, + ) + end - it "sets the attributes correctly" do - expect(professional_standing_request.requested?).to be true + it "doesn't create a professional standing request" do + expect { call }.to_not change(ProfessionalStandingRequest, :count) end end end