From 708689f6e35139e288c9f701eeb5502e4de58294 Mon Sep 17 00:00:00 2001 From: Stephen Dicks Date: Tue, 28 Jan 2025 17:09:54 +0000 Subject: [PATCH] faith schools: Convert religious forms to single step with 'complete later' field (#7435) --- .../job_application_review_component.rb | 4 +- .../catholic_religious_information_section.rb | 8 +- ..._catholic_religious_information_section.rb | 8 +- .../job_applications/build_controller.rb | 17 +-- .../job_application/ask_for_support_form.rb | 2 +- .../jobseekers/job_application/base_form.rb | 6 +- .../catholic_following_religion_form.rb | 4 - .../job_application/catholic_form.rb | 36 ++++++ .../catholic_religion_details_form.rb | 43 ------- .../job_application/declarations_form.rb | 2 +- .../employment_history_form.rb | 2 +- .../equal_opportunities_form.rb | 2 +- .../following_religion_form.rb | 14 --- .../non_catholic_following_religion_form.rb | 4 - .../job_application/non_catholic_form.rb | 31 +++++ .../non_catholic_religion_details_form.rb | 25 ---- .../job_application/personal_details_form.rb | 2 +- .../personal_statement_form.rb | 2 +- .../professional_status_form.rb | 18 +-- .../job_application/qualifications_form.rb | 2 +- .../job_application/references_form.rb | 3 +- .../religious_information_form.rb | 43 +++++++ .../job_application/school_ethos_form.rb | 14 --- .../job_application/training_and_cpds_form.rb | 2 +- app/models/job_application.rb | 16 +-- .../job_application_step_process.rb | 38 +----- .../job_applications/apply.html.slim | 10 +- .../job_applications/build/catholic.html.slim | 50 ++++++++ .../catholic_following_religion.html.slim | 25 ---- .../build/catholic_religion_details.html.slim | 34 ------ .../build/non_catholic.html.slim | 39 +++++++ .../non_catholic_following_religion.html.slim | 17 --- .../non_catholic_religion_details.html.slim | 26 ----- .../build/school_ethos.html.slim | 19 --- .../_catholic_religious_information.html.slim | 28 ++--- ...n_catholic_religious_information.html.slim | 26 ++--- config/locales/activerecord.yml | 22 ++-- config/locales/jobseekers.yml | 11 +- .../jobseekers/job_applications/religion.yml | 54 ++++----- db/schema.rb | 1 + ...mplete_a_religious_job_application_spec.rb | 108 +++++++++--------- 41 files changed, 367 insertions(+), 451 deletions(-) delete mode 100644 app/form_models/jobseekers/job_application/catholic_following_religion_form.rb create mode 100644 app/form_models/jobseekers/job_application/catholic_form.rb delete mode 100644 app/form_models/jobseekers/job_application/catholic_religion_details_form.rb delete mode 100644 app/form_models/jobseekers/job_application/following_religion_form.rb delete mode 100644 app/form_models/jobseekers/job_application/non_catholic_following_religion_form.rb create mode 100644 app/form_models/jobseekers/job_application/non_catholic_form.rb delete mode 100644 app/form_models/jobseekers/job_application/non_catholic_religion_details_form.rb create mode 100644 app/form_models/jobseekers/job_application/religious_information_form.rb delete mode 100644 app/form_models/jobseekers/job_application/school_ethos_form.rb create mode 100644 app/views/jobseekers/job_applications/build/catholic.html.slim delete mode 100644 app/views/jobseekers/job_applications/build/catholic_following_religion.html.slim delete mode 100644 app/views/jobseekers/job_applications/build/catholic_religion_details.html.slim create mode 100644 app/views/jobseekers/job_applications/build/non_catholic.html.slim delete mode 100644 app/views/jobseekers/job_applications/build/non_catholic_following_religion.html.slim delete mode 100644 app/views/jobseekers/job_applications/build/non_catholic_religion_details.html.slim delete mode 100644 app/views/jobseekers/job_applications/build/school_ethos.html.slim diff --git a/app/components/job_application_review_component.rb b/app/components/job_application_review_component.rb index 1674ab6b3f..da2b111c6e 100644 --- a/app/components/job_application_review_component.rb +++ b/app/components/job_application_review_component.rb @@ -8,11 +8,11 @@ class JobApplicationReviewComponent < ApplicationComponent renders_many(:sections, lambda do |section_name, **kwargs| case section_name - when :catholic_following_religion + when :catholic CatholicReligiousInformationSection.new(@job_application, name: section_name, allow_edit: @allow_edit) - when :school_ethos + when :non_catholic NonCatholicReligiousInformationSection.new(@job_application, name: section_name, allow_edit: @allow_edit) diff --git a/app/components/job_application_review_component/catholic_religious_information_section.rb b/app/components/job_application_review_component/catholic_religious_information_section.rb index 0855cb0f8c..ba30519afa 100644 --- a/app/components/job_application_review_component/catholic_religious_information_section.rb +++ b/app/components/job_application_review_component/catholic_religious_information_section.rb @@ -1,11 +1,5 @@ class JobApplicationReviewComponent::CatholicReligiousInformationSection < JobApplicationReviewComponent::Section def initialize(job_application, allow_edit:, name:) - # only include the details form if we follow a religion - forms = if job_application.following_religion - %w[CatholicFollowingReligionForm CatholicReligionDetailsForm] - else - %w[CatholicFollowingReligionForm] - end - super(job_application, forms: forms, name: name, allow_edit: allow_edit) + super(job_application, forms: %w[CatholicForm], name: name, allow_edit: allow_edit) end end diff --git a/app/components/job_application_review_component/non_catholic_religious_information_section.rb b/app/components/job_application_review_component/non_catholic_religious_information_section.rb index b7fa97197e..622a528955 100644 --- a/app/components/job_application_review_component/non_catholic_religious_information_section.rb +++ b/app/components/job_application_review_component/non_catholic_religious_information_section.rb @@ -2,12 +2,6 @@ class JobApplicationReviewComponent::NonCatholicReligiousInformationSection < JobApplicationReviewComponent::Section def initialize(job_application, allow_edit:, name:) - # only include the details form if we follow a religion - forms = if job_application.following_religion - %w[SchoolEthosForm NonCatholicFollowingReligionForm NonCatholicReligionDetailsForm] - else - %w[SchoolEthosForm NonCatholicFollowingReligionForm] - end - super(job_application, forms: forms, name: name, allow_edit: allow_edit) + super(job_application, forms: %w[NonCatholicForm], name: name, allow_edit: allow_edit) end end diff --git a/app/controllers/jobseekers/job_applications/build_controller.rb b/app/controllers/jobseekers/job_applications/build_controller.rb index 79d27239a0..59a78fd1ed 100644 --- a/app/controllers/jobseekers/job_applications/build_controller.rb +++ b/app/controllers/jobseekers/job_applications/build_controller.rb @@ -55,15 +55,12 @@ def form_attributes when "show" form_class.load_form(job_application) when "update" - form_params + form_class.load_form(job_application).merge(form_params) end case step when :professional_status - attributes.merge(jobseeker_profile_attributes) - .merge(trn_params) - when :references - attributes.merge(references: job_application.references) + attributes.merge(trn_params) when :employment_history attributes.merge(unexplained_employment_gaps: job_application.unexplained_employment_gaps) else @@ -108,7 +105,7 @@ def update_params end def update_fields - # This version doesn't work with date fields + # This version doesn't work with date fields as they are submitted in 3 parts (hence form_params doesn't contain the right key) # form_class.storable_fields.select { |f| form_params.key?(f) }.index_with { |field| form.public_send(field) } form_params.except(*form_class.unstorable_fields) end @@ -121,15 +118,7 @@ def vacancy @vacancy ||= job_application.vacancy end - def jobseeker_profile_attributes - { - jobseeker_profile: current_jobseeker.jobseeker_profile, - } - end - def trn_params - return {} unless step == :professional_status - { teacher_reference_number: form_params[:teacher_reference_number] || current_jobseeker&.jobseeker_profile&.teacher_reference_number, has_teacher_reference_number: form_params[:has_teacher_reference_number] || current_jobseeker&.jobseeker_profile&.has_teacher_reference_number, diff --git a/app/form_models/jobseekers/job_application/ask_for_support_form.rb b/app/form_models/jobseekers/job_application/ask_for_support_form.rb index 541b8bd868..1e50123523 100644 --- a/app/form_models/jobseekers/job_application/ask_for_support_form.rb +++ b/app/form_models/jobseekers/job_application/ask_for_support_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :ask_for_support))) + super.merge(completed_attrs(model, :ask_for_support)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/base_form.rb b/app/form_models/jobseekers/job_application/base_form.rb index c5b26c818a..8cd8e7c132 100644 --- a/app/form_models/jobseekers/job_application/base_form.rb +++ b/app/form_models/jobseekers/job_application/base_form.rb @@ -15,11 +15,7 @@ def storable_fields end def load_form(model) - load_form_attributes(model.attributes) - end - - def load_form_attributes(attrs) - attrs.symbolize_keys.slice(*fields) + model.slice(*storable_fields) end end end diff --git a/app/form_models/jobseekers/job_application/catholic_following_religion_form.rb b/app/form_models/jobseekers/job_application/catholic_following_religion_form.rb deleted file mode 100644 index 16904f61cb..0000000000 --- a/app/form_models/jobseekers/job_application/catholic_following_religion_form.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Jobseekers::JobApplication::CatholicFollowingReligionForm < Jobseekers::JobApplication::FollowingReligionForm -end diff --git a/app/form_models/jobseekers/job_application/catholic_form.rb b/app/form_models/jobseekers/job_application/catholic_form.rb new file mode 100644 index 0000000000..279bc80bff --- /dev/null +++ b/app/form_models/jobseekers/job_application/catholic_form.rb @@ -0,0 +1,36 @@ +module Jobseekers + module JobApplication + class CatholicForm < ReligiousInformationForm + FIELDS = %i[baptism_certificate + baptism_address].freeze + + class << self + def storable_fields + super + FIELDS + [:baptism_date] + end + + def unstorable_fields + %i[catholic_section_completed] + end + + def load_form(model) + model.slice(*storable_fields).merge(completed_attrs(model, :catholic)) + end + end + + attr_accessor(*FIELDS) + + attribute :baptism_date, :date + + validates :religious_reference_type, + inclusion: { in: ::JobApplication::RELIGIOUS_REFERENCE_TYPES.keys.map(&:to_s), nil: false }, + if: -> { catholic_section_completed && following_religion } + + completed_attribute(:catholic) + + def section_completed + catholic_section_completed + end + end + end +end diff --git a/app/form_models/jobseekers/job_application/catholic_religion_details_form.rb b/app/form_models/jobseekers/job_application/catholic_religion_details_form.rb deleted file mode 100644 index e8c8f157e0..0000000000 --- a/app/form_models/jobseekers/job_application/catholic_religion_details_form.rb +++ /dev/null @@ -1,43 +0,0 @@ -class Jobseekers::JobApplication::CatholicReligionDetailsForm < Jobseekers::JobApplication::BaseForm - include ActiveRecord::AttributeAssignment - include ActiveModel::Attributes - - FIELDS = %i[faith - place_of_worship - religious_reference_type - religious_referee_name - religious_referee_address - religious_referee_role - religious_referee_email - religious_referee_phone - baptism_certificate - baptism_address].freeze - - STORABLE_FIELDS = (FIELDS + [:baptism_date]).freeze - - class << self - def storable_fields - STORABLE_FIELDS - end - - def load_form(model) - load_form_attributes(model.attributes.merge(baptism_certificate: model.baptism_certificate)) - end - end - - attr_accessor(*FIELDS) - - attribute :baptism_date, :date - - validates :faith, presence: true - validates :religious_reference_type, inclusion: { in: JobApplication::RELIGIOUS_REFERENCE_TYPES.keys.map(&:to_s), nil: false } - - validates :religious_referee_name, :religious_referee_address, :religious_referee_role, :religious_referee_email, - presence: true, if: -> { religious_reference_type == "referee" } - validates :religious_referee_email, email: true, if: -> { religious_reference_type == "referee" } - - validates :baptism_address, :baptism_date, - presence: true, if: -> { religious_reference_type == "baptism_date" } - - validates :baptism_certificate, form_file: DOCUMENT_VALIDATION_OPTIONS, presence: true, if: -> { religious_reference_type == "baptism_certificate" } -end diff --git a/app/form_models/jobseekers/job_application/declarations_form.rb b/app/form_models/jobseekers/job_application/declarations_form.rb index 69659f55eb..6da58ff449 100644 --- a/app/form_models/jobseekers/job_application/declarations_form.rb +++ b/app/form_models/jobseekers/job_application/declarations_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :declarations))) + super.merge(completed_attrs(model, :declarations)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/employment_history_form.rb b/app/form_models/jobseekers/job_application/employment_history_form.rb index 2ed93ebc28..b7da003649 100644 --- a/app/form_models/jobseekers/job_application/employment_history_form.rb +++ b/app/form_models/jobseekers/job_application/employment_history_form.rb @@ -18,7 +18,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :employment_history))) + super.merge(completed_attrs(model, :employment_history)) end end attr_accessor(*FIELDS, :unexplained_employment_gaps) diff --git a/app/form_models/jobseekers/job_application/equal_opportunities_form.rb b/app/form_models/jobseekers/job_application/equal_opportunities_form.rb index 7cb0f0b499..114abd5e97 100644 --- a/app/form_models/jobseekers/job_application/equal_opportunities_form.rb +++ b/app/form_models/jobseekers/job_application/equal_opportunities_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :equal_opportunities))) + super.merge(completed_attrs(model, :equal_opportunities)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/following_religion_form.rb b/app/form_models/jobseekers/job_application/following_religion_form.rb deleted file mode 100644 index d605e61894..0000000000 --- a/app/form_models/jobseekers/job_application/following_religion_form.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Jobseekers::JobApplication::FollowingReligionForm < Jobseekers::JobApplication::BaseForm - include ActiveModel::Model - include ActiveModel::Attributes - - class << self - def storable_fields - %i[following_religion] - end - end - - attribute :following_religion, :boolean - - validates :following_religion, inclusion: { in: [true, false], allow_nil: false } -end diff --git a/app/form_models/jobseekers/job_application/non_catholic_following_religion_form.rb b/app/form_models/jobseekers/job_application/non_catholic_following_religion_form.rb deleted file mode 100644 index 680b58c201..0000000000 --- a/app/form_models/jobseekers/job_application/non_catholic_following_religion_form.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Jobseekers::JobApplication::NonCatholicFollowingReligionForm < Jobseekers::JobApplication::FollowingReligionForm -end diff --git a/app/form_models/jobseekers/job_application/non_catholic_form.rb b/app/form_models/jobseekers/job_application/non_catholic_form.rb new file mode 100644 index 0000000000..197772b482 --- /dev/null +++ b/app/form_models/jobseekers/job_application/non_catholic_form.rb @@ -0,0 +1,31 @@ +module Jobseekers + module JobApplication + class NonCatholicForm < ReligiousInformationForm + class << self + def storable_fields + super + [:ethos_and_aims] + end + + def unstorable_fields + %i[non_catholic_section_completed] + end + + def load_form(model) + super.merge(completed_attrs(model, :non_catholic)) + end + end + + attr_accessor(:ethos_and_aims) + + validates_presence_of :ethos_and_aims + + validates :religious_reference_type, inclusion: { in: %w[referee no_referee], nil: false }, if: -> { non_catholic_section_completed && following_religion } + + completed_attribute(:non_catholic) + + def section_completed + non_catholic_section_completed + end + end + end +end diff --git a/app/form_models/jobseekers/job_application/non_catholic_religion_details_form.rb b/app/form_models/jobseekers/job_application/non_catholic_religion_details_form.rb deleted file mode 100644 index afe042b689..0000000000 --- a/app/form_models/jobseekers/job_application/non_catholic_religion_details_form.rb +++ /dev/null @@ -1,25 +0,0 @@ -class Jobseekers::JobApplication::NonCatholicReligionDetailsForm < Jobseekers::JobApplication::BaseForm - FIELDS = %i[faith - place_of_worship - religious_reference_type - religious_referee_name - religious_referee_address - religious_referee_role - religious_referee_email - religious_referee_phone].freeze - - class << self - def storable_fields - FIELDS - end - end - - attr_accessor(*FIELDS) - - validates :faith, presence: true - validates :religious_reference_type, inclusion: { in: %w[referee no_referee], nil: false } - - validates :religious_referee_name, :religious_referee_address, :religious_referee_role, :religious_referee_email, - presence: true, if: -> { religious_reference_type == "referee" } - validates :religious_referee_email, email: true, if: -> { religious_reference_type == "referee" } -end diff --git a/app/form_models/jobseekers/job_application/personal_details_form.rb b/app/form_models/jobseekers/job_application/personal_details_form.rb index d6b2449bc7..b66a40030b 100644 --- a/app/form_models/jobseekers/job_application/personal_details_form.rb +++ b/app/form_models/jobseekers/job_application/personal_details_form.rb @@ -37,7 +37,7 @@ def load_form(model) new_attrs = { has_ni_number: model.national_insurance_number.present? ? "yes" : "no", }.merge(completed_attrs(model, :personal_details)) - load_form_attributes(model.attributes.merge(new_attrs)) + super.merge(new_attrs) end end diff --git a/app/form_models/jobseekers/job_application/personal_statement_form.rb b/app/form_models/jobseekers/job_application/personal_statement_form.rb index 76c4f2f4d1..b719425af5 100644 --- a/app/form_models/jobseekers/job_application/personal_statement_form.rb +++ b/app/form_models/jobseekers/job_application/personal_statement_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :personal_statement))) + super.merge(completed_attrs(model, :personal_statement)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/professional_status_form.rb b/app/form_models/jobseekers/job_application/professional_status_form.rb index 1b2ecdd5a6..e52f393032 100644 --- a/app/form_models/jobseekers/job_application/professional_status_form.rb +++ b/app/form_models/jobseekers/job_application/professional_status_form.rb @@ -11,11 +11,10 @@ class ProfessionalStatusForm < BaseForm qualified_teacher_status_details statutory_induction_complete teacher_reference_number - has_teacher_reference_number statutory_induction_complete_details ].freeze - attr_accessor(*FIELDS) + attr_accessor(*FIELDS, :has_teacher_reference_number) class << self def storable_fields @@ -27,18 +26,11 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :professional_status))) + super.merge(completed_attrs(model, :professional_status)) + .merge(has_teacher_reference_number: model[:teacher_reference_number].present? ? "yes" : "no") end end - def statutory_induction_complete_options - [ - ["yes", I18n.t("helpers.label.jobseekers_job_application_professional_status_form.statutory_induction_complete_options.yes")], - ["no", I18n.t("helpers.label.jobseekers_job_application_professional_status_form.statutory_induction_complete_options.no")], - - ] - end - def initialize(attributes = {}) jobseeker_profile = attributes.delete(:jobseeker_profile) super @@ -65,9 +57,5 @@ def initialize(attributes = {}) completed_attribute(:professional_status) end - - def load(attrs) - super(attrs.merge(has_teacher_reference_number: attrs[:teacher_reference_number].present? ? "yes" : "no")) - end end end diff --git a/app/form_models/jobseekers/job_application/qualifications_form.rb b/app/form_models/jobseekers/job_application/qualifications_form.rb index 7527ce2a1e..bb1c5412ae 100644 --- a/app/form_models/jobseekers/job_application/qualifications_form.rb +++ b/app/form_models/jobseekers/job_application/qualifications_form.rb @@ -11,7 +11,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :qualifications))) + super.merge(completed_attrs(model, :qualifications)) end end diff --git a/app/form_models/jobseekers/job_application/references_form.rb b/app/form_models/jobseekers/job_application/references_form.rb index 8a6a267cb8..5d80c729fa 100644 --- a/app/form_models/jobseekers/job_application/references_form.rb +++ b/app/form_models/jobseekers/job_application/references_form.rb @@ -15,7 +15,8 @@ def optional? end def load_form(model) - load_form_attributes(model.attributes.merge(references: model.references).merge(completed_attrs(model, :references))) + super.merge(references: model.references) + .merge(completed_attrs(model, :references)) end end diff --git a/app/form_models/jobseekers/job_application/religious_information_form.rb b/app/form_models/jobseekers/job_application/religious_information_form.rb new file mode 100644 index 0000000000..c774d7bb40 --- /dev/null +++ b/app/form_models/jobseekers/job_application/religious_information_form.rb @@ -0,0 +1,43 @@ +module Jobseekers + module JobApplication + class ReligiousInformationForm < BaseForm + include ActiveRecord::AttributeAssignment + include ActiveModel::Attributes + include CompletedFormAttribute + + FIELDS = %i[faith + place_of_worship + religious_reference_type + religious_referee_name + religious_referee_address + religious_referee_role + religious_referee_email + religious_referee_phone].freeze + + STORABLE_FIELDS = (FIELDS + %i[following_religion]).freeze + + class << self + def storable_fields + STORABLE_FIELDS + end + end + + attr_accessor(*FIELDS) + + attribute :following_religion, :boolean + + validates :following_religion, inclusion: { in: [true, false], allow_nil: false }, if: -> { section_completed } + + validates :faith, presence: true, if: -> { section_completed && following_religion } + + validates :religious_referee_name, :religious_referee_address, :religious_referee_role, :religious_referee_email, + presence: true, if: -> { section_completed && following_religion && religious_reference_type == "referee" } + validates :religious_referee_email, email: true, if: -> { section_completed && following_religion && religious_reference_type == "referee" } + + validates :baptism_address, :baptism_date, + presence: true, if: -> { section_completed && following_religion && religious_reference_type == "baptism_date" } + + validates :baptism_certificate, form_file: DOCUMENT_VALIDATION_OPTIONS, presence: true, if: -> { section_completed && following_religion && religious_reference_type == "baptism_certificate" } + end + end +end diff --git a/app/form_models/jobseekers/job_application/school_ethos_form.rb b/app/form_models/jobseekers/job_application/school_ethos_form.rb deleted file mode 100644 index a64a08e5bc..0000000000 --- a/app/form_models/jobseekers/job_application/school_ethos_form.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class Jobseekers::JobApplication::SchoolEthosForm < Jobseekers::JobApplication::BaseForm - FIELDS = %i[ethos_and_aims].freeze - - class << self - def storable_fields - FIELDS - end - end - attr_accessor(*FIELDS) - - validates_presence_of :ethos_and_aims -end diff --git a/app/form_models/jobseekers/job_application/training_and_cpds_form.rb b/app/form_models/jobseekers/job_application/training_and_cpds_form.rb index e7a45900fd..41584f6392 100644 --- a/app/form_models/jobseekers/job_application/training_and_cpds_form.rb +++ b/app/form_models/jobseekers/job_application/training_and_cpds_form.rb @@ -11,7 +11,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :training_and_cpds))) + super.merge(completed_attrs(model, :training_and_cpds)) end end diff --git a/app/models/job_application.rb b/app/models/job_application.rb index 039f1eb3b2..1312c532e7 100644 --- a/app/models/job_application.rb +++ b/app/models/job_application.rb @@ -12,11 +12,8 @@ class JobApplication < ApplicationRecord training_and_cpds: 9, employment_history: 3, personal_statement: 4, - catholic_following_religion: 10, - catholic_religion_details: 11, - school_ethos: 12, - non_catholic_following_religion: 13, - non_catholic_religion_details: 14, + catholic: 10, + non_catholic: 11, references: 5, equal_opportunities: 6, ask_for_support: 7, @@ -30,11 +27,8 @@ class JobApplication < ApplicationRecord training_and_cpds: 9, employment_history: 3, personal_statement: 4, - catholic_following_religion: 10, - catholic_religion_details: 11, - school_ethos: 12, - non_catholic_following_religion: 13, - non_catholic_religion_details: 14, + catholic: 10, + non_catholic: 11, references: 5, equal_opportunities: 6, ask_for_support: 7, @@ -52,6 +46,8 @@ class JobApplication < ApplicationRecord personal_statement: 7, declarations: 8, ask_for_support: 9, + catholic: 10, + non_catholic: 11, } # If you want to add a status, be sure to add a `status_at` column to the `job_applications` table 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 c91eb4b283..d14433f710 100644 --- a/app/services/jobseekers/job_applications/job_application_step_process.rb +++ b/app/services/jobseekers/job_applications/job_application_step_process.rb @@ -16,27 +16,19 @@ class Jobseekers::JobApplications::JobApplicationStepProcess review: %i[review], }.freeze - ALL_CATHOLIC_STEPS = %i[catholic_following_religion catholic_religion_details].freeze - - ALL_NON_CATHOLIC_STEPS = %i[school_ethos non_catholic_following_religion non_catholic_religion_details].freeze - def initialize(job_application:) @job_application = job_application religious_steps = case job_application.vacancy.religion_type when "catholic" - catholic_steps job_application + { catholic: [:catholic] } when "other_religion" - other_religion_steps job_application + { non_catholic: [:non_catholic] } else - [] + {} end - @step_groups = if religious_steps.any? - PRE_RELIGION_STEPS.merge(religious_information: religious_steps).merge(POST_RELIGION_STEPS) - else - PRE_RELIGION_STEPS.merge(POST_RELIGION_STEPS) - end + @step_groups = PRE_RELIGION_STEPS.merge(religious_steps).merge(POST_RELIGION_STEPS) end # Returns the keys of all individual steps in order @@ -56,30 +48,12 @@ def last_of_group?(step) def all_possible_steps steps = case job_application.vacancy.religion_type when "catholic" - PRE_RELIGION_STEPS.merge(religious_information: ALL_CATHOLIC_STEPS).merge(POST_RELIGION_STEPS) + PRE_RELIGION_STEPS.merge(religious_information: [:religious_information]).merge(POST_RELIGION_STEPS) when "other_religion" - PRE_RELIGION_STEPS.merge(religious_information: ALL_NON_CATHOLIC_STEPS).merge(POST_RELIGION_STEPS) + PRE_RELIGION_STEPS.merge(non_catholic: [:non_catholic]).merge(POST_RELIGION_STEPS) else PRE_RELIGION_STEPS.merge(POST_RELIGION_STEPS) end steps.values.flatten end - - private - - def catholic_steps(job_application) - if job_application.following_religion || job_application.following_religion.nil? - ALL_CATHOLIC_STEPS - else - ALL_CATHOLIC_STEPS - [:catholic_religion_details] - end - end - - def other_religion_steps(job_application) - if job_application.following_religion || job_application.following_religion.nil? - ALL_NON_CATHOLIC_STEPS - else - ALL_NON_CATHOLIC_STEPS - [:non_catholic_religion_details] - end - end end diff --git a/app/views/jobseekers/job_applications/apply.html.slim b/app/views/jobseekers/job_applications/apply.html.slim index 3666366adf..fc486fc3ce 100644 --- a/app/views/jobseekers/job_applications/apply.html.slim +++ b/app/views/jobseekers/job_applications/apply.html.slim @@ -1,6 +1,6 @@ - content_for :page_title_prefix, job_application_page_title_prefix(review_form, t(".title")) -= job_application_review(@job_application) do |r| += job_application_review(@job_applicationm, show_sidebar: false) do |r| - r.with_header do = render "banner" @@ -41,13 +41,13 @@ - case job_application.vacancy.religion_type - when "catholic" - - task_list.with_item(title: t("jobseekers.job_applications.build.religious_information.step_title"), href: jobseekers_job_application_build_path(job_application, :catholic_following_religion), + - task_list.with_item(title: t("jobseekers.job_applications.build.catholic.step_title"), href: jobseekers_job_application_build_path(job_application, :catholic), html_attributes: { id: :religious_information }, - status: review_section_tag(job_application, [Jobseekers::JobApplication::FollowingReligionForm])) + status: review_section_tag(job_application, [Jobseekers::JobApplication::CatholicForm])) - when "other_religion" - - task_list.with_item(title: t("jobseekers.job_applications.build.religious_information.step_title"), href: jobseekers_job_application_build_path(job_application, :school_ethos), + - task_list.with_item(title: t("jobseekers.job_applications.build.catholic.step_title"), href: jobseekers_job_application_build_path(job_application, :non_catholic), html_attributes: { id: :religious_information }, - status: review_section_tag(job_application, [Jobseekers::JobApplication::FollowingReligionForm])) + status: review_section_tag(job_application, [Jobseekers::JobApplication::NonCatholicForm])) - task_list.with_item(title: t("jobseekers.job_applications.build.references.heading"), href: jobseekers_job_application_build_path(job_application, :references), html_attributes: { id: :references }, diff --git a/app/views/jobseekers/job_applications/build/catholic.html.slim b/app/views/jobseekers/job_applications/build/catholic.html.slim new file mode 100644 index 0000000000..d991c8e06b --- /dev/null +++ b/app/views/jobseekers/job_applications/build/catholic.html.slim @@ -0,0 +1,50 @@ +- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) + += render "banner", vacancy: vacancy, back_path: back_path + +.govuk-grid-row + div + h2.govuk-heading-l = t(".heading") + + p.govuk-body = t(".is_a_catholic_school", name: vacancy.organisation.name) + + p.govuk-body = t(".preference_to_catholics") + + p.govuk-body = t(".preference_for_support_staff") + + p.govuk-body = t(".non_catholics_apply") + + = form_for form, url: jobseekers_job_application_build_path(job_application, :catholic), method: :patch, multipart: true do |f| + = f.govuk_error_summary + + = f.govuk_radio_buttons_fieldset :following_religion do + = f.govuk_radio_button :following_religion, true, link_errors: true do + = f.govuk_text_field :faith, label: { size: "s" } + + = f.govuk_text_area :place_of_worship, label: { size: "s" }, rows: 6 + + = f.govuk_radio_buttons_fieldset :religious_reference_type do + = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true do + = f.govuk_text_field :religious_referee_name + = f.govuk_text_area :religious_referee_address, rows: 6 + = f.govuk_text_field :religious_referee_role + = f.govuk_text_field :religious_referee_email + = f.govuk_text_field :religious_referee_phone + = f.govuk_radio_button :religious_reference_type, :baptism_certificate do + - if f.object.baptism_certificate.attached? + p.govuk-body + = govuk_link_to("#{f.object.baptism_certificate.filename} (#{number_to_human_size(f.object.baptism_certificate.byte_size)})", f.object.baptism_certificate, download: "true") + = f.govuk_file_field :baptism_certificate, + label: { size: "s" }, + accept: BaseForm::VALID_DOCUMENT_TYPES.map(&:downcase).join(",") + = f.govuk_radio_button :religious_reference_type, :baptism_date do + = f.govuk_text_area :baptism_address, rows: 6 + = f.govuk_date_field :baptism_date + = f.govuk_radio_button :religious_reference_type, :no_referee + + = f.govuk_radio_button :following_religion, "false" + + = f.govuk_collection_radio_buttons :catholic_section_completed, %w[true false], :to_s + + = f.govuk_submit job_application_build_submit_button_text do + = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/build/catholic_following_religion.html.slim b/app/views/jobseekers/job_applications/build/catholic_following_religion.html.slim deleted file mode 100644 index 6445fbbd79..0000000000 --- a/app/views/jobseekers/job_applications/build/catholic_following_religion.html.slim +++ /dev/null @@ -1,25 +0,0 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) - -= render "banner", vacancy: vacancy, back_path: back_path - -.govuk-grid-row - div - h2.govuk-heading-l = t(".heading") - - p.govuk-body = t(".is_a_catholic_school", name: vacancy.organisation.name) - - p.govuk-body = t(".preference_to_catholics") - - p.govuk-body = t(".preference_for_support_staff") - - p.govuk-body = t(".non_catholics_apply") - - = form_for form, url: jobseekers_job_application_build_path(job_application, :catholic_following_religion), method: :patch do |f| - = f.govuk_error_summary - - = f.govuk_radio_buttons_fieldset :following_religion do - = f.govuk_radio_button :following_religion, true, link_errors: true - = f.govuk_radio_button :following_religion, "false" - - = f.govuk_submit job_application_build_submit_button_text do - = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/build/catholic_religion_details.html.slim b/app/views/jobseekers/job_applications/build/catholic_religion_details.html.slim deleted file mode 100644 index 20dc4d14a3..0000000000 --- a/app/views/jobseekers/job_applications/build/catholic_religion_details.html.slim +++ /dev/null @@ -1,34 +0,0 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) - -= render "banner", vacancy: vacancy, back_path: back_path - -.govuk-grid-row - div - h2.govuk-heading-l = t(".heading") - - = form_for form, url: jobseekers_job_application_build_path(job_application, :catholic_religion_details), method: :patch do |f| - = f.govuk_error_summary - - = f.govuk_text_field :faith, label: { size: "s" } - - = f.govuk_text_area :place_of_worship, label: { size: "s" }, rows: 6 - - = f.govuk_radio_buttons_fieldset :religious_reference_type do - = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true do - = f.govuk_text_field :religious_referee_name - = f.govuk_text_area :religious_referee_address, rows: 6 - = f.govuk_text_field :religious_referee_role - = f.govuk_text_field :religious_referee_email - = f.govuk_text_field :religious_referee_phone - = f.govuk_radio_button :religious_reference_type, :baptism_certificate do - = f.govuk_file_field :baptism_certificate, - label: { size: "s" }, - accept: BaseForm::VALID_DOCUMENT_TYPES.map(&:downcase).join(","), - enctype: "multipart/form-data" - = f.govuk_radio_button :religious_reference_type, :baptism_date do - = f.govuk_text_area :baptism_address, rows: 6 - = f.govuk_date_field :baptism_date - = f.govuk_radio_button :religious_reference_type, :no_referee - - = f.govuk_submit job_application_build_submit_button_text do - = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/build/non_catholic.html.slim b/app/views/jobseekers/job_applications/build/non_catholic.html.slim new file mode 100644 index 0000000000..0155d84e57 --- /dev/null +++ b/app/views/jobseekers/job_applications/build/non_catholic.html.slim @@ -0,0 +1,39 @@ +- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) + += render "banner", vacancy: vacancy, back_path: back_path + +.govuk-grid-row + div + h2.govuk-heading-l = t(".heading") + + p.govuk-body = t(".has_a_religious_character", name: vacancy.organisation.name) + + p.govuk-body = t(".preference_to_religious_applicants") + + = form_for form, url: jobseekers_job_application_build_path(job_application, :non_catholic), method: :patch do |f| + = f.govuk_error_summary + + = f.govuk_text_area :ethos_and_aims, rows: 6, label: { size: "s" } + + = f.govuk_radio_buttons_fieldset :following_religion do + = f.govuk_radio_button :following_religion, true, link_errors: true do + + = f.govuk_text_field :faith, label: { size: "s" } + + = f.govuk_text_area :place_of_worship, label: { size: "s" }, rows: 6 + + = f.govuk_radio_buttons_fieldset :religious_reference_type do + = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true do + = f.govuk_text_field :religious_referee_name + = f.govuk_text_area :religious_referee_address, rows: 6 + = f.govuk_text_field :religious_referee_role + = f.govuk_text_field :religious_referee_email + = f.govuk_text_field :religious_referee_phone + = f.govuk_radio_button :religious_reference_type, :no_referee + + = f.govuk_radio_button :following_religion, "false" + + = f.govuk_collection_radio_buttons :non_catholic_section_completed, %w[true false], :to_s + + = f.govuk_submit job_application_build_submit_button_text do + = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/build/non_catholic_following_religion.html.slim b/app/views/jobseekers/job_applications/build/non_catholic_following_religion.html.slim deleted file mode 100644 index 3392726734..0000000000 --- a/app/views/jobseekers/job_applications/build/non_catholic_following_religion.html.slim +++ /dev/null @@ -1,17 +0,0 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) - -= render "banner", vacancy: vacancy, back_path: back_path - -.govuk-grid-row - div - h2.govuk-heading-l = t(".heading") - - = form_for form, url: jobseekers_job_application_build_path(job_application, :non_catholic_following_religion), method: :patch do |f| - = f.govuk_error_summary - - = f.govuk_radio_buttons_fieldset :following_religion do - = f.govuk_radio_button :following_religion, "true", link_errors: true - = f.govuk_radio_button :following_religion, "false" - - = f.govuk_submit job_application_build_submit_button_text do - = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/build/non_catholic_religion_details.html.slim b/app/views/jobseekers/job_applications/build/non_catholic_religion_details.html.slim deleted file mode 100644 index 2e50f447c9..0000000000 --- a/app/views/jobseekers/job_applications/build/non_catholic_religion_details.html.slim +++ /dev/null @@ -1,26 +0,0 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) - -= render "banner", vacancy: vacancy, back_path: back_path - -.govuk-grid-row - div - h2.govuk-heading-l = t(".heading") - - = form_for form, url: jobseekers_job_application_build_path(job_application, :non_catholic_religion_details), method: :patch do |f| - = f.govuk_error_summary - - = f.govuk_text_field :faith, label: { size: "s" } - - = f.govuk_text_area :place_of_worship, label: { size: "s" }, rows: 6 - - = f.govuk_radio_buttons_fieldset :religious_reference_type do - = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true do - = f.govuk_text_field :religious_referee_name - = f.govuk_text_area :religious_referee_address, rows: 6 - = f.govuk_text_field :religious_referee_role - = f.govuk_text_field :religious_referee_email - = f.govuk_text_field :religious_referee_phone - = f.govuk_radio_button :religious_reference_type, :no_referee - - = f.govuk_submit job_application_build_submit_button_text do - = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/build/school_ethos.html.slim b/app/views/jobseekers/job_applications/build/school_ethos.html.slim deleted file mode 100644 index a9cb858cc7..0000000000 --- a/app/views/jobseekers/job_applications/build/school_ethos.html.slim +++ /dev/null @@ -1,19 +0,0 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) - -= render "banner", vacancy: vacancy, back_path: back_path - -.govuk-grid-row - div - h2.govuk-heading-l = t(".heading") - - p.govuk-body = t(".has_a_religious_character", name: vacancy.organisation.name) - - p.govuk-body = t(".preference_to_religious_applicants") - - = form_for form, url: jobseekers_job_application_build_path(job_application, :school_ethos), method: :patch do |f| - = f.govuk_error_summary - - = f.govuk_text_area :ethos_and_aims, rows: 6, label: { size: "s" } - - = f.govuk_submit job_application_build_submit_button_text do - = govuk_link_to t("buttons.cancel_and_return_to_account"), jobseekers_job_applications_path, class: "govuk-link--no-visited-state" diff --git a/app/views/jobseekers/job_applications/review/_catholic_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_catholic_religious_information.html.slim index 9d2dcdaf92..443e1ad1d4 100644 --- a/app/views/jobseekers/job_applications/review/_catholic_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_catholic_religious_information.html.slim @@ -1,48 +1,48 @@ -- r.with_section :catholic_following_religion +- r.with_section :catholic p.govuk-body = t("jobseekers.job_applications.review.religious_information.heading") = govuk_summary_list do |summary_list| - if job_application.following_religion.in? [true, false] - summary_list.with_row do |row| - - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_following_religion_form.following_religion") - - row.with_value text: t("helpers.label.jobseekers_job_application_catholic_following_religion_form.following_religion_options.#{job_application.following_religion}") + - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_form.following_religion") + - row.with_value text: t("helpers.label.jobseekers_job_application_catholic_form.following_religion_options.#{job_application.following_religion}") - if job_application.following_religion - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.faith") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.faith") - row.with_value text: job_application.faith - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.place_of_worship") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.place_of_worship") - row.with_value text: job_application.place_of_worship - summary_list.with_row do |row| - - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_religion_details_form.religious_reference_type") + - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_form.religious_reference_type") - if job_application.religious_reference_type.present? - - row.with_value text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.#{job_application.religious_reference_type}") + - row.with_value text: t("helpers.label.jobseekers_job_application_catholic_form.religious_reference_type_options.#{job_application.religious_reference_type}") - else - row.with_value text: "" - case job_application.religious_reference_type - when "referee" - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_name") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_name") - row.with_value text: job_application.religious_referee_name - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_address") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_address") - row.with_value text: job_application.religious_referee_address - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_role") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_role") - row.with_value text: job_application.religious_referee_role - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_email") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_email") - row.with_value text: job_application.religious_referee_email - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_phone") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_phone") - row.with_value text: job_application.religious_referee_phone - when "baptism_certificate" @@ -52,9 +52,9 @@ - when "baptism_date" - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.baptism_address") + - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_form.baptism_address") - row.with_value text: job_application.baptism_address - summary_list.with_row do |row| - - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_religion_details_form.baptism_date") + - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_form.baptism_date") - row.with_value text: job_application.baptism_date.to_formatted_s(:day_month_year) diff --git a/app/views/jobseekers/job_applications/review/_non_catholic_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_non_catholic_religious_information.html.slim index 4b5e80eece..73cb8e9f07 100644 --- a/app/views/jobseekers/job_applications/review/_non_catholic_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_non_catholic_religious_information.html.slim @@ -1,46 +1,46 @@ -- r.with_section :school_ethos +- r.with_section :non_catholic p.govuk-body = t("jobseekers.job_applications.review.religious_information.heading") = govuk_summary_list do |summary_list| - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_school_ethos_form.ethos_and_aims") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.ethos_and_aims") - row.with_value text: job_application.ethos_and_aims - if job_application.following_religion.in? [true, false] - summary_list.with_row do |row| - - row.with_key text: t("helpers.legend.jobseekers_job_application_non_catholic_following_religion_form.following_religion") - - row.with_value text: t("helpers.label.jobseekers_job_application_non_catholic_following_religion_form.following_religion_options.#{job_application.following_religion}") + - row.with_key text: t("helpers.legend.jobseekers_job_application_non_catholic_form.following_religion") + - row.with_value text: t("helpers.label.jobseekers_job_application_non_catholic_form.following_religion_options.#{job_application.following_religion}") - if job_application.following_religion - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.faith") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.faith") - row.with_value text: job_application.faith - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.place_of_worship") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.place_of_worship") - row.with_value text: job_application.place_of_worship - summary_list.with_row do |row| - - row.with_key text: t("helpers.legend.jobseekers_job_application_catholic_religion_details_form.religious_reference_type") - - row.with_value text: t("helpers.label.jobseekers_job_application_non_catholic_following_religion_form.following_religion_options.#{job_application.religious_reference_type == 'referee'}") + - row.with_key text: t("helpers.legend.jobseekers_job_application_non_catholic_form.religious_reference_type") + - row.with_value text: t("helpers.label.jobseekers_job_application_non_catholic_form.following_religion_options.#{job_application.religious_reference_type == 'referee'}") - if job_application.religious_reference_type == "referee" - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_name") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_name") - row.with_value text: job_application.religious_referee_name - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_address") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_address") - row.with_value text: job_application.religious_referee_address - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_role") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_role") - row.with_value text: job_application.religious_referee_role - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_email") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_email") - row.with_value text: job_application.religious_referee_email - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_phone") + - row.with_key text: t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_phone") - row.with_value text: job_application.religious_referee_phone diff --git a/config/locales/activerecord.yml b/config/locales/activerecord.yml index 8dfe3f4fa2..9860454a01 100644 --- a/config/locales/activerecord.yml +++ b/config/locales/activerecord.yml @@ -482,16 +482,10 @@ en: attributes: training_and_cpds_section_completed: blank: Select yes if you have completed this section - jobseekers/job_application/catholic_following_religion_form: + jobseekers/job_application/religious_information_form: attributes: following_religion: inclusion: Select yes if you follow a specific religion or faith - jobseekers/job_application/non_catholic_following_religion_form: - attributes: - following_religion: - inclusion: Select yes if you follow a specific religion or faith - jobseekers/job_application/catholic_religion_details_form: - attributes: faith: blank: Enter your religious denomination or faith religious_referee_name: @@ -511,8 +505,16 @@ en: blank: Enter the baptism date baptism_certificate: blank: Upload your baptism certificate - jobseekers/job_application/non_catholic_religion_details_form: + jobseekers/job_application/catholic_form: + attributes: + catholic_section_completed: + inclusion: Select yes if you have completed this section + jobseekers/job_application/non_catholic_form: attributes: + non_catholic_section_completed: + inclusion: Select yes if you have completed this section + following_religion: + inclusion: Select yes if you follow a specific religion or faith faith: blank: Enter your religious denomination or faith religious_referee_name: @@ -526,8 +528,6 @@ en: invalid: Enter a valid email address religious_reference_type: inclusion: Select yes if you can provide a religious referee - jobseekers/job_application/school_ethos_form: - attributes: ethos_and_aims: blank: Enter how you will support the ethos and aims of the school jobseekers/job_application/pre_submit_form: @@ -561,6 +561,8 @@ en: incomplete: Complete your religious information training_and_cpds: incomplete: Complete your training and CPD + religious: + incomplete: Complete your religious information jobseekers/job_application/review_form: attributes: confirm_data_accurate: diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 98d82b7fe4..17bfc5cd1d 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -184,13 +184,16 @@ en: optional: You can select ‘prefer not to say’ if you would rather not answer any question. step_title: Equal opportunities title: Equal opportunities — Application - catholic_following_religion: - heading: Religious information + catholic: + step_title: Religious Information title: Religious information — Application + heading: Religious information is_a_catholic_school: "%{name} is a Catholic school." preference_to_catholics: Schools, academies and colleges of a religious character can give preference to Catholic applicants when recruiting for teaching roles. preference_for_support_staff: They can also give preference to Catholic applicants for support staff roles where there is a genuine occupational requirement. non_catholics_apply: Applicants who do not follow a faith or religion are still encouraged to apply. + catholic_following_religion: + heading: Religious information non_catholic_following_religion: heading: Religious information title: Religious information — Application @@ -200,7 +203,7 @@ en: non_catholic_religion_details: heading: Religious information title: Religious information — Application - school_ethos: + non_catholic: heading: Religious information title: Religious information — Application has_a_religious_character: "%{name} has a religious character." @@ -252,8 +255,6 @@ en: no_references: No referees specified step_title: References title: References — Application - religious_information: - step_title: Religious Information review: step_title: Review your application cancel_caption: If you select cancel you will lose any unsaved information from this step. Completed details from previous steps will be saved in your draft applications. diff --git a/config/locales/jobseekers/job_applications/religion.yml b/config/locales/jobseekers/job_applications/religion.yml index af8affc794..7786aa79f5 100644 --- a/config/locales/jobseekers/job_applications/religion.yml +++ b/config/locales/jobseekers/job_applications/religion.yml @@ -1,40 +1,41 @@ en: helpers: legend: - jobseekers_job_application_catholic_following_religion_form: + jobseekers_job_application_catholic_form: + catholic_section_completed: Have you completed this section? + baptism_date: What was the date of your baptism? + religious_reference_type: Can you provide a religious referee? following_religion: Are you currently following a religion or faith? - jobseekers_job_application_non_catholic_following_religion_form: + jobseekers_job_application_non_catholic_form: + non_catholic_section_completed: Have you completed this section? following_religion: Are you currently following a religion or faith? - jobseekers_job_application_catholic_religion_details_form: - religious_reference_type: Can you provide a religious referee? - baptism_date: What was the date of your baptism? - jobseekers_job_application_non_catholic_religion_details_form: religious_reference_type: Can you provide a religious referee? label: - jobseekers_job_application_catholic_following_religion_form: - following_religion_options: - "true": "Yes" - "false": "No" - jobseekers_job_application_non_catholic_following_religion_form: - following_religion_options: - "true": "Yes" - "false": "No" - jobseekers_job_application_catholic_religion_details_form: + jobseekers_job_application_catholic_form: + catholic_section_completed_options: + false: No, I'll come back to it later + true: Yes, I've completed this section religious_reference_type_options: referee: "Yes" baptism_certificate: No, but I can provide a baptism certificate baptism_date: No, but I can provide the date and address of my baptism no_referee: "No" + baptism_certificate: Upload a file + baptism_address: Address of baptism location + following_religion_options: + "true": "Yes" + "false": "No" + faith: What is your religious denomination or faith? + place_of_worship: Address of place of worship (optional) religious_referee_name: Religious referee name religious_referee_address: Religious referee address religious_referee_role: Religious referee role religious_referee_email: Religious referee email religious_referee_phone: Religious referee phone number (optional) - baptism_certificate: Upload a file - baptism_address: Address of baptism location - faith: What is your religious denomination or faith? - place_of_worship: Address of place of worship (optional) - jobseekers_job_application_non_catholic_religion_details_form: + jobseekers_job_application_non_catholic_form: + following_religion_options: + "true": "Yes" + "false": "No" religious_reference_type_options: "referee": "Yes" "no_referee": "No" @@ -45,17 +46,18 @@ en: religious_referee_phone: Religious referee phone number (optional) faith: What is your religious denomination or faith? place_of_worship: Address of place of worship (optional) - jobseekers_job_application_school_ethos_form: ethos_and_aims: How will you support the school's ethos and aims? + non_catholic_section_completed_options: + false: No, I'll come back to it later + true: Yes, I've completed this section hint: - jobseekers_job_application_catholic_religion_details_form: - baptism_date: For example 27 3 2007 + jobseekers_job_application_religious_information_form: faith: For example, Christian. religious_reference_type_html: >-

If you are a practising Catholic, you should nominate your Parish Priest where you regularly worship as your referee.

If you are not a practising Catholic, you can provide a copy of your baptism certificate, or the date and address of your baptism.

Make sure your referee has consented to providing a reference.

- jobseekers_job_application_non_catholic_religion_details_form: - faith: For example, Christian. - jobseekers_job_application_school_ethos_form: + jobseekers_job_application_non_catholic_form: ethos_and_aims: For example, through running after school clubs or supporting the school's local community. + jobseekers_job_application_catholic_form: + baptism_date: For example 27 3 2007 diff --git a/db/schema.rb b/db/schema.rb index 9a6a2446b9..e28fee820c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,6 +9,7 @@ # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. + ActiveRecord::Schema[7.2].define(version: 2025_01_17_112840) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_religious_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_religious_job_application_spec.rb index a711763d3e..8f2d1e4e4e 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_religious_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_religious_job_application_spec.rb @@ -21,18 +21,19 @@ before do fill_in_past_personal_statement - click_on I18n.t("jobseekers.job_applications.build.religious_information.step_title") + click_on I18n.t("jobseekers.job_applications.build.catholic.step_title") + choose "Yes, I've completed this section" end it "validates first religion step" do - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.catholic_following_religion.preference_to_catholics")) + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.catholic.preference_to_catholics")) validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_following_religion_form.attributes.following_religion.inclusion")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.following_religion.inclusion")) end context "without a religion" do before do - choose "No" + find("label[for='jobseekers-job-application-catholic-form-following-religion-false-field']").click click_on I18n.t("buttons.save_and_continue") end @@ -44,42 +45,44 @@ context "with a religion" do before do - choose "Yes" - click_on I18n.t("buttons.save_and_continue") + find("label[for='jobseekers-job-application-catholic-form-following-religion-true-field']").click + choose "Yes, I've completed this section" end it "produces the correct errors" do validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.faith.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.religious_reference_type.inclusion")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.faith.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.religious_reference_type.inclusion")) end context "with a denomination" do before do - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.faith"), with: "follower of #{Faker::Religion::Bible.character}" - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.place_of_worship"), with: "#{Faker::Address.city} Church" + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.faith"), with: "follower of #{Faker::Religion::Bible.character}" + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.place_of_worship"), with: "#{Faker::Address.city} Church" end context "with a referee" do before do - choose I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.referee") + find("label[for='jobseekers-job-application-catholic-form-religious-reference-type-referee-field']").click end it "produces the correct error messages" do validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.religious_referee_name.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.religious_referee_role.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.religious_referee_address.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.religious_referee_email.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.religious_referee_name.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.religious_referee_role.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.religious_referee_address.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.religious_referee_email.blank")) end context "when on review page" do before do - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_name"), with: referee_name - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_address"), with: referee_address - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_role"), with: referee_role - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_email"), with: referee_email - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_referee_phone"), with: referee_phone + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_name"), with: referee_name + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_address"), with: referee_address + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_role"), with: referee_role + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_email"), with: referee_email + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_referee_phone"), with: referee_phone + + choose "Yes, I've completed this section" click_on I18n.t("buttons.save_and_continue") complete_from_references_page end @@ -110,17 +113,17 @@ context "with a baptism certificate" do before do - choose I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.baptism_certificate") + choose I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_reference_type_options.baptism_certificate") end it "produces the correct errors" do validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.baptism_certificate.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.baptism_certificate.blank")) end context "with an uploaded baptism cerificate" do before do - page.attach_file("jobseekers-job-application-catholic-religion-details-form-baptism-certificate-field", Rails.root.join("spec/fixtures/files/blank_baptism_cert.pdf")) + page.attach_file("jobseekers-job-application-catholic-form-baptism-certificate-field", Rails.root.join("spec/fixtures/files/blank_baptism_cert.pdf")) allow_any_instance_of(FormFileValidator).to receive(:virus_free?).and_return(true) click_on I18n.t("buttons.save_and_continue") @@ -132,7 +135,7 @@ expect(page).to have_content("blank_baptism_cert.pdf") end - it "can be submitted as an application", :js do + it "can be submitted as an application" do complete_from_references_page check I18n.t("helpers.label.jobseekers_job_application_review_form.confirm_data_accurate_options.1") check I18n.t("helpers.label.jobseekers_job_application_review_form.confirm_data_usage_options.1") @@ -145,19 +148,19 @@ context "with an address and date of baptism" do before do - choose I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.baptism_date") + choose I18n.t("helpers.label.jobseekers_job_application_catholic_form.religious_reference_type_options.baptism_date") end let(:baptism_address) { Faker::Address.full_address } it "produces the correct errors" do validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.baptism_address.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/catholic_religion_details_form.attributes.baptism_date.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.baptism_address.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religious_information_form.attributes.baptism_date.blank")) end it "allows jobseekers to specify a baptism address and date" do - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.baptism_address"), with: baptism_address + fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_form.baptism_address"), with: baptism_address fill_in "Day", with: 7 fill_in "Month", with: 3 fill_in "Year", with: 2007 @@ -172,7 +175,7 @@ context "without a referee" do before do - choose I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.religious_reference_type_options.no_referee") + find("label[for='jobseekers-job-application-catholic-form-religious-reference-type-no-referee-field']").click end it "allows jobseeker to not specify a religious referee" do @@ -189,36 +192,37 @@ before do fill_in_past_personal_statement - click_on I18n.t("jobseekers.job_applications.build.religious_information.step_title") + click_on I18n.t("jobseekers.job_applications.build.catholic.step_title") + choose "Yes, I've completed this section" end it "validates ethos and aims step" do - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.school_ethos.preference_to_religious_applicants")) + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.non_catholic.preference_to_religious_applicants")) validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/school_ethos_form.attributes.ethos_and_aims.blank")) + sleep 20 + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_form.attributes.ethos_and_aims.blank")) end context "when on page 2" do before do - fill_in I18n.t("helpers.label.jobseekers_job_application_school_ethos_form.ethos_and_aims"), with: Faker::Lorem.sentence - click_on I18n.t("buttons.save_and_continue") + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.ethos_and_aims"), with: Faker::Lorem.sentence end it "show the correct error" do validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_following_religion_form.attributes.following_religion.inclusion")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_form.attributes.following_religion.inclusion")) end context "when completing following religion question" do before do - choose following_religion - click_on I18n.t("buttons.save_and_continue") + find("label[for='jobseekers-job-application-non-catholic-form-following-religion-#{following_religion}-field']").click end context "when not following a religion" do - let(:following_religion) { "No" } + let(:following_religion) { false } it "completes the religious journey" do + click_on I18n.t("buttons.save_and_continue") expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) complete_from_references_page submit_application_from_review @@ -227,27 +231,28 @@ end context "when following a religion" do - let(:following_religion) { "Yes" } + let(:following_religion) { true } it "displays the non catholic details form" do - expect(page).to have_content(I18n.t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.faith")) + expect(page).to have_content(I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.faith")) end it "errors correctly" do validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_religion_details_form.attributes.faith.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_religion_details_form.attributes.religious_reference_type.inclusion")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_form.attributes.faith.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/non_catholic_form.attributes.religious_reference_type.inclusion")) end context "with a faith" do before do - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.faith"), with: "follower of #{Faker::Religion::Bible.character}" - fill_in I18n.t("helpers.label.jobseekers_job_application_catholic_religion_details_form.place_of_worship"), with: "#{Faker::Address.city} Church" + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.faith"), with: "follower of #{Faker::Religion::Bible.character}" + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.place_of_worship"), with: "#{Faker::Address.city} Church" end context "without a referee" do before do - choose "No" + sleep 5 + find("label[for='jobseekers-job-application-non-catholic-form-religious-reference-type-no-referee-field']").click end it "completes the journey" do @@ -261,20 +266,19 @@ context "when entering a referee" do before do - choose "Yes" + find("label[for='jobseekers-job-application-non-catholic-form-religious-reference-type-referee-field']").click end it "errors when not entered" do - click_on I18n.t("buttons.save_and_continue") validates_step_complete end it "can complete the journey" do - fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.religious_referee_name"), with: referee_name - fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.religious_referee_address"), with: referee_address - fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.religious_referee_role"), with: referee_role - fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.religious_referee_email"), with: referee_email - fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_religion_details_form.religious_referee_phone"), with: referee_phone + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_name"), with: referee_name + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_address"), with: referee_address + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_role"), with: referee_role + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_email"), with: referee_email + fill_in I18n.t("helpers.label.jobseekers_job_application_non_catholic_form.religious_referee_phone"), with: referee_phone click_on I18n.t("buttons.save_and_continue") complete_from_references_page submit_application_from_review