Skip to content

Commit

Permalink
Don't request professional standing
Browse files Browse the repository at this point in the history
When verifying the assessment we shouldn't request the professional
standing as that happens at a separate stage now.
  • Loading branch information
thomasleese committed Sep 27, 2023
1 parent 15493e3 commit 5f8145c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
13 changes: 6 additions & 7 deletions app/services/verify_assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 29 additions & 10 deletions spec/services/verify_assessment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,47 @@
)
end

describe "when already verified" do
context "when already verified" do
let(:assessment) { create(:assessment, :verify, application_form:) }

it "raises an error" do
expect { call }.to raise_error(VerifyAssessment::AlreadyVerified)
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
Expand Down

0 comments on commit 5f8145c

Please sign in to comment.