Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we use the correct requires_preliminary_check #2167

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions app/services/submit_application_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def call

ActiveRecord::Base.transaction do
application_form.update!(
requires_preliminary_check:,
requires_preliminary_check: region.requires_preliminary_check,
subjects: application_form.subjects.compact_blank,
submitted_at: Time.zone.now,
working_days_since_submission: 0,
)

assessment = AssessmentFactory.call(application_form:)

if reduced_evidence_accepted
if application_form.reduced_evidence_accepted
UpdateAssessmentInductionRequired.call(assessment:)
end

Expand All @@ -38,7 +38,7 @@ def call
action: :application_received,
)

if teaching_authority_requires_submission_email
if region.teaching_authority_requires_submission_email
DeliverEmail.call(
application_form:,
mailer: TeachingAuthorityMailer,
Expand All @@ -53,20 +53,14 @@ def call

attr_reader :application_form, :user

delegate :reduced_evidence_accepted,
:region,
:requires_preliminary_check,
:teaching_authority_provides_written_statement,
to: :application_form

delegate :teaching_authority_requires_submission_email, to: :region
delegate :region, to: :application_form

def create_professional_standing_request(assessment)
return unless teaching_authority_provides_written_statement
return unless application_form.teaching_authority_provides_written_statement

requestable = ProfessionalStandingRequest.create!(assessment:)

unless requires_preliminary_check
unless application_form.requires_preliminary_check
RequestRequestable.call(requestable:, user:)
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/services/submit_application_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:with_personal_information,
:with_teaching_qualification,
region:,
requires_preliminary_check: false,
subjects: ["Maths", "", ""],
)
end
Expand All @@ -29,6 +30,13 @@
"pre_assessment",
)
end

it "sets requires preliminary check on the application form" do
expect { call }.to change(
application_form,
:requires_preliminary_check,
).from(false).to(true)
end
end

describe "compacting blank subjects" do
Expand Down
Loading