diff --git a/app/controllers/jobseekers/job_applications/base_controller.rb b/app/controllers/jobseekers/job_applications/base_controller.rb index 6344c82742..4f505e7c76 100644 --- a/app/controllers/jobseekers/job_applications/base_controller.rb +++ b/app/controllers/jobseekers/job_applications/base_controller.rb @@ -5,7 +5,6 @@ class Jobseekers::JobApplications::BaseController < Jobseekers::BaseController def step_process Jobseekers::JobApplications::JobApplicationStepProcess.new( - current_step || :review, job_application: job_application, ) end diff --git a/app/services/jobseekers/job_applications/job_application_step_process.rb b/app/services/jobseekers/job_applications/job_application_step_process.rb index 302fc1b89f..1ccd5667c9 100644 --- a/app/services/jobseekers/job_applications/job_application_step_process.rb +++ b/app/services/jobseekers/job_applications/job_application_step_process.rb @@ -1,21 +1,28 @@ -class Jobseekers::JobApplications::JobApplicationStepProcess < StepProcess - attr_reader :job_application +module Jobseekers + module JobApplications + class JobApplicationStepProcess + def initialize(job_application:) + @job_application = job_application - def initialize(current_step, job_application:) - @job_application = job_application + @step_groups = { + personal_details: %i[personal_details], + professional_status: %i[professional_status], + qualifications: %i[qualifications], + training_and_cpds: %i[training_and_cpds], + employment_history: %i[employment_history], + personal_statement: %i[personal_statement], + references: %i[references], + equal_opportunities: %i[equal_opportunities], + ask_for_support: %i[ask_for_support], + declarations: %i[declarations], + review: %i[review], + } + end - super(current_step, { - personal_details: %i[personal_details], - professional_status: %i[professional_status], - qualifications: %i[qualifications], - training_and_cpds: %i[training_and_cpds], - employment_history: %i[employment_history], - personal_statement: %i[personal_statement], - references: %i[references], - equal_opportunities: %i[equal_opportunities], - ask_for_support: %i[ask_for_support], - declarations: %i[declarations], - review: %i[review], - }) + # Returns the keys of all individual steps in order + def steps + @step_groups.values.flatten + end + end end end diff --git a/app/services/jobseekers/job_applications/prefill_job_application_from_previous_application.rb b/app/services/jobseekers/job_applications/prefill_job_application_from_previous_application.rb index d63ff24148..89f7800868 100644 --- a/app/services/jobseekers/job_applications/prefill_job_application_from_previous_application.rb +++ b/app/services/jobseekers/job_applications/prefill_job_application_from_previous_application.rb @@ -83,7 +83,7 @@ def relevant_steps # The step process is needed in order to filter out the steps that are not relevant to the new job application, # for eg. professional status - see https://github.com/DFE-Digital/teaching-vacancies/blob/75cec792d9e229fb866bdafc017f82501bd01001/app/services/jobseekers/job_applications/job_application_step_process.rb#L23 # The review step is used as a current step is required. - Jobseekers::JobApplications::JobApplicationStepProcess.new(:review, job_application: new_job_application).steps + Jobseekers::JobApplications::JobApplicationStepProcess.new(job_application: new_job_application).steps end def completed_steps diff --git a/spec/services/jobseekers/job_applications/job_application_step_process_spec.rb b/spec/services/jobseekers/job_applications/job_application_step_process_spec.rb deleted file mode 100644 index a4123fcbc0..0000000000 --- a/spec/services/jobseekers/job_applications/job_application_step_process_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require "rails_helper" - -RSpec.describe Jobseekers::JobApplications::JobApplicationStepProcess do - subject { described_class.new(current_step, job_application: job_application) } - - let(:current_step) { :personal_details } - - let(:job_application) { build_stubbed(:job_application, vacancy: vacancy) } - - describe "#step_groups" do - let(:all_possible_step_groups) do - %i[ - personal_details professional_status qualifications training_and_cpds employment_history personal_statement - references equal_opportunities ask_for_support declarations review - ] - end - - context "when vacancy job role is teacher" do - let(:vacancy) { build_stubbed(:vacancy, :ect_suitable, job_roles: ["teacher"]) } - - it "has the expected step groups" do - expect(subject.step_groups.keys).to eq(all_possible_step_groups) - end - end - - context "when vacancy job role is education_support" do - let(:vacancy) { build_stubbed(:vacancy, job_roles: ["education_support"]) } - - it "has the expected step groups" do - expect(subject.steps).to eq(all_possible_step_groups) - end - end - end -end