From 5054ea9cdaa74dd52f357f2509c2fa43c26ce930 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 25 Oct 2024 15:48:39 +0100 Subject: [PATCH 01/16] Faith schools part 1 - publisher questions --- app/models/vacancy.rb | 2 ++ config/locales/publishers.yml | 7 +++++++ db/migrate/20241025154606_add_religion_type_to_vacancy.rb | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 db/migrate/20241025154606_add_religion_type_to_vacancy.rb diff --git a/app/models/vacancy.rb b/app/models/vacancy.rb index e91d203458..7ed204f0d1 100644 --- a/app/models/vacancy.rb +++ b/app/models/vacancy.rb @@ -57,6 +57,8 @@ class Vacancy < ApplicationRecord enum religion_type: { no_religion: 0, other_religion: 1, catholic: 2 } + enum religion_type: { no_religion: 0, other_religion: 1, catholic: 2 } + belongs_to :publisher, optional: true belongs_to :publisher_organisation, class_name: "Organisation", optional: true diff --git a/config/locales/publishers.yml b/config/locales/publishers.yml index d42813e71f..e8c99b46c2 100644 --- a/config/locales/publishers.yml +++ b/config/locales/publishers.yml @@ -449,6 +449,13 @@ en: edit: Change job listing - [Section %{section_number} of 4] - Teaching Vacancies - GOV.UK pay_package: step_title: Salary and allowances + religious_information: + catholic: + label: Their religion, place of worship and religious referee or baptism information + hint: This form has been approved by the Catholic Education Service. + other_religion: If they have a religious denomination or faith, how they'll meet your school's ethos and aims, and if they want to provide an optional religious referee or place of worship + no_religion: Do not ask applicants about their religion + what_would_you_like_to_ask: What would you like to ask applicants about their religion? review: step_title: Review the job listing working_patterns: diff --git a/db/migrate/20241025154606_add_religion_type_to_vacancy.rb b/db/migrate/20241025154606_add_religion_type_to_vacancy.rb new file mode 100644 index 0000000000..1469760526 --- /dev/null +++ b/db/migrate/20241025154606_add_religion_type_to_vacancy.rb @@ -0,0 +1,5 @@ +class AddReligionTypeToVacancy < ActiveRecord::Migration[7.1] + def change + add_column :vacancies, :religion_type, :integer + end +end From 172a2babb22c8c4daf16f4a299bdd2e5e8c079aa Mon Sep 17 00:00:00 2001 From: starswan Date: Wed, 30 Oct 2024 14:19:34 +0000 Subject: [PATCH 02/16] Standard locations for labels and hints --- config/locales/publishers.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/locales/publishers.yml b/config/locales/publishers.yml index e8c99b46c2..d42813e71f 100644 --- a/config/locales/publishers.yml +++ b/config/locales/publishers.yml @@ -449,13 +449,6 @@ en: edit: Change job listing - [Section %{section_number} of 4] - Teaching Vacancies - GOV.UK pay_package: step_title: Salary and allowances - religious_information: - catholic: - label: Their religion, place of worship and religious referee or baptism information - hint: This form has been approved by the Catholic Education Service. - other_religion: If they have a religious denomination or faith, how they'll meet your school's ethos and aims, and if they want to provide an optional religious referee or place of worship - no_religion: Do not ask applicants about their religion - what_would_you_like_to_ask: What would you like to ask applicants about their religion? review: step_title: Review the job listing working_patterns: From 18de0d02674527da8e3da57bf48cd7937c1f2b83 Mon Sep 17 00:00:00 2001 From: starswan Date: Tue, 29 Oct 2024 16:15:51 +0000 Subject: [PATCH 03/16] wip --- .../job_applications/base_controller.rb | 15 +- .../job_applications/build_controller.rb | 8 +- .../following_religion_form.rb | 10 + .../job_application/religion_details_form.rb | 28 ++ app/models/job_application.rb | 6 + .../religious_job_application_step_process.rb | 24 ++ app/services/step_process.rb | 4 +- .../build/following_religion.html.slim | 31 ++ .../build/religion_details.html.slim | 40 +++ config/analytics.yml | 11 + config/locales/activerecord.yml | 19 ++ config/locales/forms.yml | 17 +- config/locales/jobseekers.yml | 24 ++ ...d_following_religion_to_job_application.rb | 15 + spec/rails_helper.rb | 4 +- ...ers_can_complete_a_job_application_spec.rb | 295 +++++++++++++----- 16 files changed, 455 insertions(+), 96 deletions(-) create mode 100644 app/form_models/jobseekers/job_application/following_religion_form.rb create mode 100644 app/form_models/jobseekers/job_application/religion_details_form.rb create mode 100644 app/services/jobseekers/job_applications/religious_job_application_step_process.rb create mode 100644 app/views/jobseekers/job_applications/build/following_religion.html.slim create mode 100644 app/views/jobseekers/job_applications/build/religion_details.html.slim create mode 100644 db/migrate/20241028134844_add_following_religion_to_job_application.rb diff --git a/app/controllers/jobseekers/job_applications/base_controller.rb b/app/controllers/jobseekers/job_applications/base_controller.rb index 33c616f327..14c64992e3 100644 --- a/app/controllers/jobseekers/job_applications/base_controller.rb +++ b/app/controllers/jobseekers/job_applications/base_controller.rb @@ -4,10 +4,17 @@ class Jobseekers::JobApplications::BaseController < Jobseekers::BaseController helper_method :current_step, :step_process, :job_application def step_process - Jobseekers::JobApplications::JobApplicationStepProcess.new( - current_step || :review, - job_application: job_application, - ) + if vacancy.religion_type.present? + Jobseekers::JobApplications::ReligiousJobApplicationStepProcess.new( + current_step || :review, + job_application: job_application, + ) + else + Jobseekers::JobApplications::JobApplicationStepProcess.new( + current_step || :review, + job_application: job_application, + ) + end end def job_application diff --git a/app/controllers/jobseekers/job_applications/build_controller.rb b/app/controllers/jobseekers/job_applications/build_controller.rb index 4568e73af4..403dd2f22a 100644 --- a/app/controllers/jobseekers/job_applications/build_controller.rb +++ b/app/controllers/jobseekers/job_applications/build_controller.rb @@ -2,8 +2,8 @@ class Jobseekers::JobApplications::BuildController < Jobseekers::JobApplications include Wicked::Wizard include Jobseekers::QualificationFormConcerns - steps :personal_details, :professional_status, :qualifications, :training_and_cpds, :employment_history, :personal_statement, :references, - :equal_opportunities, :ask_for_support, :declarations + before_action :set_steps + before_action :setup_wizard helper_method :back_path, :employments, :form, :job_application, :qualification_form_param_key, :redirect_to_review?, :vacancy @@ -147,4 +147,8 @@ def update_or_create_jobseeker_profile! ) end end + + def set_steps + self.steps = step_process.steps - [:review] + end end diff --git a/app/form_models/jobseekers/job_application/following_religion_form.rb b/app/form_models/jobseekers/job_application/following_religion_form.rb new file mode 100644 index 0000000000..dbcf72b232 --- /dev/null +++ b/app/form_models/jobseekers/job_application/following_religion_form.rb @@ -0,0 +1,10 @@ +class Jobseekers::JobApplication::FollowingReligionForm < Jobseekers::JobApplication::BaseForm + include ActiveModel::Model + + def self.fields + %i[following_religion] + end + attr_accessor(*fields) + + validates :following_religion, inclusion: { in: %w[yes no] } +end diff --git a/app/form_models/jobseekers/job_application/religion_details_form.rb b/app/form_models/jobseekers/job_application/religion_details_form.rb new file mode 100644 index 0000000000..67da59c1b3 --- /dev/null +++ b/app/form_models/jobseekers/job_application/religion_details_form.rb @@ -0,0 +1,28 @@ +class Jobseekers::JobApplication::ReligionDetailsForm < Jobseekers::JobApplication::BaseForm + include ActiveRecord::AttributeAssignment + include DateAttributeAssignment + + def self.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_address + baptism_date] + end + attr_accessor(*fields) + + 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" } +end diff --git a/app/models/job_application.rb b/app/models/job_application.rb index 1e2ccdeb58..ecacc2259f 100644 --- a/app/models/job_application.rb +++ b/app/models/job_application.rb @@ -12,6 +12,8 @@ class JobApplication < ApplicationRecord training_and_cpds: 9, employment_history: 3, personal_statement: 4, + following_religion: 10, + religion_details: 11, references: 5, equal_opportunities: 6, ask_for_support: 7, @@ -42,6 +44,10 @@ class JobApplication < ApplicationRecord # If you want to add a status, be sure to add a `status_at` column to the `job_applications` table enum :status, { draft: 0, submitted: 1, reviewed: 2, shortlisted: 3, unsuccessful: 4, withdrawn: 5 }, default: 0 + RELIGIOUS_REFERENCE_TYPES = { referee: 1, baptism_certificate: 2, baptism_date: 3, no_referee: 4 }.freeze + + enum religious_reference_type: RELIGIOUS_REFERENCE_TYPES + has_encrypted :first_name, :last_name, :previous_names, :street_address, :city, :postcode, :phone_number, :teacher_reference_number, :national_insurance_number, :personal_statement, :support_needed_details, :close_relationships_details, diff --git a/app/services/jobseekers/job_applications/religious_job_application_step_process.rb b/app/services/jobseekers/job_applications/religious_job_application_step_process.rb new file mode 100644 index 0000000000..be7386cdd3 --- /dev/null +++ b/app/services/jobseekers/job_applications/religious_job_application_step_process.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class Jobseekers::JobApplications::ReligiousJobApplicationStepProcess < StepProcess + attr_reader :job_application + + def initialize(current_step, job_application:) + @job_application = job_application + + 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], + religious_information: %i[following_religion religion_details], + references: %i[references], + equal_opportunities: %i[equal_opportunities], + ask_for_support: %i[ask_for_support], + declarations: %i[declarations], + review: %i[review], + }) + end +end diff --git a/app/services/step_process.rb b/app/services/step_process.rb index bffac7c3ba..06b5e0f69c 100644 --- a/app/services/step_process.rb +++ b/app/services/step_process.rb @@ -7,7 +7,9 @@ def initialize(current_step, step_groups = {}) @current_step = current_step.to_sym @step_groups = step_groups.compact_blank - raise MissingStepError, "Current step `#{current_step}` missing from steps (#{steps.join(', ')})" unless current_step.in?(steps) + unless current_step.in?(steps) + raise MissingStepError, "Current step `#{current_step}` missing from steps (#{steps.join(', ')})" + end end # Returns the keys of all individual steps in order diff --git a/app/views/jobseekers/job_applications/build/following_religion.html.slim b/app/views/jobseekers/job_applications/build/following_religion.html.slim new file mode 100644 index 0000000000..b7ee903573 --- /dev/null +++ b/app/views/jobseekers/job_applications/build/following_religion.html.slim @@ -0,0 +1,31 @@ +- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) + += render "banner", vacancy: vacancy, back_path: back_path + +.govuk-grid-row + .govuk-grid-column-two-thirds + - if current_jobseeker.job_applications.not_draft.none? + = render "caption" + 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: wizard_path, method: :patch do |f| + = f.govuk_error_summary + + = f.govuk_radio_buttons_fieldset :following_religion do + = f.govuk_radio_button :following_religion, :yes, link_errors: true, label: { text: t("helpers.legend.jobseekers_job_application_following_religion_form.yes") } + = f.govuk_radio_button :following_religion, :no, label: { text: t("helpers.legend.jobseekers_job_application_following_religion_form.no") } + + = 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" + + - if current_jobseeker.job_applications.not_draft.none? + .govuk-grid-column-one-third + = render "steps" diff --git a/app/views/jobseekers/job_applications/build/religion_details.html.slim b/app/views/jobseekers/job_applications/build/religion_details.html.slim new file mode 100644 index 0000000000..b277d55fbc --- /dev/null +++ b/app/views/jobseekers/job_applications/build/religion_details.html.slim @@ -0,0 +1,40 @@ +- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) + += render "banner", vacancy: vacancy, back_path: back_path + +.govuk-grid-row + .govuk-grid-column-two-thirds + - if current_jobseeker.job_applications.not_draft.none? + = render "caption" + h2.govuk-heading-l = t(".heading") + + = form_for form, url: wizard_path, method: :patch do |f| + = f.govuk_error_summary + + = f.govuk_text_field :faith, label: { size: "s", text: t(".faith.text") }, hint: { text: t(".faith.hint") } + + = f.govuk_text_area :place_of_worship, label: { size: "s", text: t(".place_of_worship.text") }, rows: 6, hint: { text: t(".place_of_worship.hint") } + + = f.govuk_radio_buttons_fieldset :religious_reference_type, hint: -> { t(".referee_type.hints_html") } do + = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.referee") } 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, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_certificate") } do + = f.govuk_file_field :baptism_certificate, + label: { size: "m" }, + accept: ".doc, .docx, .pdf", + enctype: "multipart/form-data" + = f.govuk_radio_button :religious_reference_type, :baptism_date, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.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, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.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" + + - if current_jobseeker.job_applications.not_draft.none? + .govuk-grid-column-one-third + = render "steps" diff --git a/config/analytics.yml b/config/analytics.yml index a920722142..4a7f2cd993 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -145,6 +145,17 @@ shared: - safeguarding_issue_details - training_and_cpds_section_completed - imported_steps + - following_religion + - religious_reference_type + - faith + - place_of_worship + - religious_referee_name + - religious_referee_address + - religious_referee_role + - religious_referee_email + - religious_referee_phone + - baptism_address + - baptism_date job_preferences_locations: - id - job_preferences_id diff --git a/config/locales/activerecord.yml b/config/locales/activerecord.yml index 0c18d08cdb..df03197a3d 100644 --- a/config/locales/activerecord.yml +++ b/config/locales/activerecord.yml @@ -550,6 +550,25 @@ en: attributes: personal_statement: blank: Enter your personal statement + jobseekers/job_application/following_religion_form: + attributes: + following_religion: + inclusion: Select yes if you follow a specific religion or faith + jobseekers/job_application/religion_details_form: + attributes: + faith: + blank: Enter your religious denomination or faith + religious_referee_name: + blank: Enter your referee name + religious_referee_address: + blank: Enter your referee address + religious_referee_role: + blank: Enter your referee role + religious_referee_email: + blank: Enter your referee email address + email: Enter a valid email address + religious_reference_type: + inclusion: Select if you can provide a religious referee jobseekers/job_application/professional_status_form: attributes: qualified_teacher_status: diff --git a/config/locales/forms.yml b/config/locales/forms.yml index eac3d0da1e..d40917ed6a 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -934,6 +934,22 @@ en: gender: How would you describe your gender? orientation: How would you describe your sexual orientation? religion: What is your religion or belief? + jobseekers_job_application_following_religion_form: + following_religion: Are you currently following a religion or faith? + "yes": "Yes" + "no": "No" + jobseekers_job_application_religion_details_form: + religious_reference_type: Can you provide a religious referee? + 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" + 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) jobseekers_break_form: ended_on: End of gap started_on: Start of gap @@ -976,7 +992,6 @@ en: jobseekers_profile_qualified_teacher_status_form: qualified_teacher_status: Do you have qualified teacher status (QTS)? has_teacher_reference_number: Do you have a teacher reference number (TRN)? - jobseekers_profile_employment_form: current_role: Are you still working in this role? ended_on: End date diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index b20bd35dc0..532cd8493d 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -176,6 +176,28 @@ 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 + following_religion: + heading: Religious information + title: Religious information — Application + 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: Non-Catholics are still encouraged to apply. + religion_details: + heading: Religious information + title: Religious information — Application + faith: + text: What is your religious denomination or faith? + hint: For example, Christian. + place_of_worship: + text: Address of place of worship (optional) + hint: For example, Westminster Abbey, Dean's Yard, London. + referee_type: + text: Can you provide a religious referee? + hints_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.

personal_details: description: Provide some basic details about yourself, like how to contact you about this application. heading: Personal details @@ -226,6 +248,8 @@ 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 click 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/db/migrate/20241028134844_add_following_religion_to_job_application.rb b/db/migrate/20241028134844_add_following_religion_to_job_application.rb new file mode 100644 index 0000000000..97a35aade6 --- /dev/null +++ b/db/migrate/20241028134844_add_following_religion_to_job_application.rb @@ -0,0 +1,15 @@ +class AddFollowingReligionToJobApplication < ActiveRecord::Migration[7.1] + def change + add_column :job_applications, :following_religion, :boolean, null: false, default: false + add_column :job_applications, :religious_reference_type, :integer + add_column :job_applications, :faith, :string + add_column :job_applications, :place_of_worship, :string + add_column :job_applications, :religious_referee_name, :string + add_column :job_applications, :religious_referee_address, :string + add_column :job_applications, :religious_referee_role, :string + add_column :job_applications, :religious_referee_email, :string + add_column :job_applications, :religious_referee_phone, :string + add_column :job_applications, :baptism_address, :string + add_column :job_applications, :baptism_date, :date + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index d02c0ba101..ad672e84eb 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,4 +1,4 @@ -require "spec_helper" +# require "spec_helper" ENV["RAILS_ENV"] ||= "test" require File.expand_path("../config/environment", __dir__) abort("The Rails environment is running in production mode!") if Rails.env.production? @@ -33,7 +33,7 @@ end end Capybara.register_driver :chrome do |app| - options = Selenium::WebDriver::Chrome::Options.new(args: %w[no-sandbox disable-gpu window-size=1400,1400]) + options = Selenium::WebDriver::Chrome::Options.new(args: %w[no-sandbox disable-gpu window-size=1400,1800]) if ENV["SELENIUM_HUB_URL"] Capybara::Selenium::Driver.new(app, browser: :remote, url: ENV.fetch("SELENIUM_HUB_URL", nil), options:) diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index 20ac980bf3..74586b4d1c 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -3,97 +3,220 @@ RSpec.describe "Jobseekers can complete a job application" do let(:jobseeker) { create(:jobseeker, jobseeker_profile: jobseeker_profile) } let(:jobseeker_profile) { create(:jobseeker_profile, :with_trn) } - let(:vacancy) { create(:vacancy, job_roles: ["teacher"], organisations: [organisation]) } let(:organisation) { create(:school) } let(:job_application) { create(:job_application, :status_draft, jobseeker: jobseeker, vacancy: vacancy) } before { login_as(jobseeker, scope: :jobseeker) } - after { logout } - it "allows jobseekers to complete an application and go to review page" do - visit jobseekers_job_application_build_path(job_application, :personal_details) - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_details.heading")) - expect(page).to have_field("Email address", with: jobseeker.email) - validates_step_complete - fill_in_personal_details - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.professional_status.heading")) - validates_step_complete - fill_in_professional_status - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.qualifications.heading")) - validates_step_complete - choose I18n.t("helpers.label.jobseekers_job_application_qualifications_form.qualifications_section_completed_options.true") - click_on I18n.t("buttons.save_and_continue") - expect(page).not_to have_content("There is a problem") - click_on I18n.t("buttons.back") - click_on I18n.t("buttons.add_qualification") - validates_step_complete(button: I18n.t("buttons.continue")) - select_qualification_category("Undergraduate degree") - expect(page).to have_content(I18n.t("jobseekers.job_applications.qualifications.new.heading.undergraduate")) - validates_step_complete(button: I18n.t("buttons.save_qualification.one")) - fill_in_undergraduate_degree - click_on I18n.t("buttons.save_qualification.one") - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content("Training and continuing professional development (CPD)") - validates_step_complete - click_on "Add training" - click_on "Save and continue" - expect(page).to have_content("There is a problem") - fill_in_training_and_cpds - click_on "Save and continue" - choose "Yes, I've completed this section" - click_on "Save and continue" - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.employment_history.heading")) - validates_step_complete - click_on I18n.t("buttons.add_work_history") - click_on I18n.t("buttons.save_employment") - expect(page).to have_content("There is a problem") - fill_in_employment_history - click_on I18n.t("buttons.save_employment") - click_on I18n.t("buttons.add_reason_for_break") - fill_in_break_in_employment(end_year: Date.today.year.to_s, end_month: Date.today.month.to_s.rjust(2, "0")) - click_on I18n.t("buttons.continue") - choose I18n.t("helpers.label.jobseekers_job_application_employment_history_form.employment_history_section_completed_options.true") - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_statement.heading")) - validates_step_complete - fill_in_personal_statement - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) - expect(page).not_to have_content(I18n.t("buttons.save_and_continue")) - click_on I18n.t("buttons.add_reference") - click_on I18n.t("buttons.save_reference") - expect(page).to have_content("There is a problem") - fill_in_reference - click_on I18n.t("buttons.save_reference") - click_on I18n.t("buttons.add_another_reference") - fill_in_reference - click_on I18n.t("buttons.save_reference") - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.equal_opportunities.heading")) - validates_step_complete - fill_in_equal_opportunities - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.ask_for_support.heading")) - validates_step_complete - fill_in_ask_for_support - click_on I18n.t("buttons.save_and_continue") - - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.declarations.heading")) - validates_step_complete - fill_in_declarations - click_on I18n.t("buttons.save_and_continue") - - expect(current_path).to eq(jobseekers_job_application_review_path(job_application)) + context "without religion information" do + let(:vacancy) { create(:vacancy, job_roles: ["teacher"], organisations: [organisation]) } + + it "allows jobseekers to complete an application and go to review page" do + visit jobseekers_job_application_build_path(job_application, :personal_details) + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_details.heading")) + expect(page).to have_field("Email address", with: jobseeker.email) + validates_step_complete + fill_in_personal_details + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.professional_status.heading")) + validates_step_complete + fill_in_professional_status + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.qualifications.heading")) + validates_step_complete + choose I18n.t("helpers.label.jobseekers_job_application_qualifications_form.qualifications_section_completed_options.true") + click_on I18n.t("buttons.save_and_continue") + expect(page).not_to have_content("There is a problem") + click_on I18n.t("buttons.back") + click_on I18n.t("buttons.add_qualification") + validates_step_complete(button: I18n.t("buttons.continue")) + select_qualification_category("Undergraduate degree") + expect(page).to have_content(I18n.t("jobseekers.job_applications.qualifications.new.heading.undergraduate")) + validates_step_complete(button: I18n.t("buttons.save_qualification.one")) + fill_in_undergraduate_degree + click_on I18n.t("buttons.save_qualification.one") + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content("Training and continuing professional development (CPD)") + validates_step_complete + click_on "Add training" + click_on "Save and continue" + expect(page).to have_content("There is a problem") + fill_in_training_and_cpds + click_on "Save and continue" + choose "Yes, I've completed this section" + click_on "Save and continue" + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.employment_history.heading")) + validates_step_complete + click_on I18n.t("buttons.add_work_history") + click_on I18n.t("buttons.save_employment") + expect(page).to have_content("There is a problem") + fill_in_employment_history + click_on I18n.t("buttons.save_employment") + click_on I18n.t("buttons.add_reason_for_break") + fill_in_break_in_employment(end_year: Date.today.year.to_s, end_month: Date.today.month.to_s.rjust(2, "0")) + click_on I18n.t("buttons.continue") + choose I18n.t("helpers.label.jobseekers_job_application_employment_history_form.employment_history_section_completed_options.true") + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_statement.heading")) + validates_step_complete + fill_in_personal_statement + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) + expect(page).not_to have_content(I18n.t("buttons.save_and_continue")) + click_on I18n.t("buttons.add_reference") + click_on I18n.t("buttons.save_reference") + expect(page).to have_content("There is a problem") + fill_in_reference + click_on I18n.t("buttons.save_reference") + click_on I18n.t("buttons.add_another_reference") + fill_in_reference + click_on I18n.t("buttons.save_reference") + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.equal_opportunities.heading")) + validates_step_complete + fill_in_equal_opportunities + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.ask_for_support.heading")) + validates_step_complete + fill_in_ask_for_support + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.declarations.heading")) + validates_step_complete + fill_in_declarations + click_on I18n.t("buttons.save_and_continue") + + expect(current_path).to eq(jobseekers_job_application_review_path(job_application)) + end + end + + context "with a catholic vacancy" do + let(:vacancy) { create(:vacancy, job_roles: ["teacher"], organisations: [organisation], religion_type: :catholic) } + + it "allows jobseekers to complete an application and go to review page", :js do + visit jobseekers_job_application_build_path(job_application, :personal_details) + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_details.heading")) + expect(page).to have_field("Email address", with: jobseeker.email) + validates_step_complete + fill_in_personal_details + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.professional_status.heading")) + validates_step_complete + fill_in_professional_status + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.qualifications.heading")) + validates_step_complete + choose I18n.t("helpers.label.jobseekers_job_application_qualifications_form.qualifications_section_completed_options.true") + click_on I18n.t("buttons.save_and_continue") + expect(page).not_to have_content("There is a problem") + click_on I18n.t("buttons.back") + click_on I18n.t("buttons.add_qualification") + validates_step_complete(button: I18n.t("buttons.continue")) + select_qualification_category("Undergraduate degree") + expect(page).to have_content(I18n.t("jobseekers.job_applications.qualifications.new.heading.undergraduate")) + validates_step_complete(button: I18n.t("buttons.save_qualification.one")) + fill_in_undergraduate_degree + click_on I18n.t("buttons.save_qualification.one") + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content("Training and continuing professional development (CPD)") + validates_step_complete + click_on "Add training" + click_on "Save and continue" + expect(page).to have_content("There is a problem") + fill_in_training_and_cpds + click_on "Save and continue" + choose "Yes, I've completed this section" + click_on "Save and continue" + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.employment_history.heading")) + validates_step_complete + click_on I18n.t("buttons.add_work_history") + click_on I18n.t("buttons.save_employment") + expect(page).to have_content("There is a problem") + fill_in_employment_history + click_on I18n.t("buttons.save_employment") + click_on I18n.t("buttons.add_reason_for_break") + fill_in_break_in_employment(end_year: Date.today.year.to_s, end_month: Date.today.month.to_s.rjust(2, "0")) + click_on I18n.t("buttons.continue") + choose I18n.t("helpers.label.jobseekers_job_application_employment_history_form.employment_history_section_completed_options.true") + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_statement.heading")) + validates_step_complete + fill_in_personal_statement + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.following_religion.heading")) + validates_step_complete + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/following_religion_form.attributes.following_religion.inclusion")) + choose "Yes" + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.religion_details.faith.hint")) + validates_step_complete + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.faith.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_reference_type.inclusion")) + fill_in "What is your religious denomination or faith?", with: "Catholic" + choose I18n.t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.no_referee") + click_on I18n.t("buttons.save_and_continue") + # validates_step_complete + sleep 20 + + # choose "Yes" + # validates_step_complete + # sleep 20 + # + # choose I18n.t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_certificate") + # validates_step_complete + # sleep 20 + # + # choose I18n.t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_date") + # validates_step_complete + # sleep 20 + # + # click_on I18n.t("buttons.save_and_continue") + # sleep 200 + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) + expect(page).not_to have_content(I18n.t("buttons.save_and_continue")) + click_on I18n.t("buttons.add_reference") + click_on I18n.t("buttons.save_reference") + expect(page).to have_content("There is a problem") + fill_in_reference + click_on I18n.t("buttons.save_reference") + click_on I18n.t("buttons.add_another_reference") + fill_in_reference + click_on I18n.t("buttons.save_reference") + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.equal_opportunities.heading")) + validates_step_complete + fill_in_equal_opportunities + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.ask_for_support.heading")) + validates_step_complete + fill_in_ask_for_support + click_on I18n.t("buttons.save_and_continue") + + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.declarations.heading")) + validates_step_complete + fill_in_declarations + click_on I18n.t("buttons.save_and_continue") + + expect(current_path).to eq(jobseekers_job_application_review_path(job_application)) + end end end From 2b24fa2e2c893b4ae8581a355e1923d0d7cc8a31 Mon Sep 17 00:00:00 2001 From: starswan Date: Wed, 30 Oct 2024 13:48:06 +0000 Subject: [PATCH 04/16] religious info on review page --- .rubocop.yml | 4 + .../job_application/religion_details_form.rb | 15 ++ app/models/job_application.rb | 2 + ..._job_application_review_sections.html.slim | 2 + .../build/religion_details.html.slim | 14 +- .../review/_religious_information.html.slim | 54 +++++ config/locales/activerecord.yml | 6 + config/locales/forms.yml | 34 ++- config/locales/jobseekers.yml | 3 - ...ers_can_complete_a_job_application_spec.rb | 206 ++++++++++++------ 10 files changed, 249 insertions(+), 91 deletions(-) create mode 100644 app/views/jobseekers/job_applications/review/_religious_information.html.slim diff --git a/.rubocop.yml b/.rubocop.yml index 7aa7e92b7e..382dfffd1a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -186,3 +186,7 @@ Metrics/PerceivedComplexity: Max: 18 # Default 8 Exclude: - "spec/**/*" + +# We have lots of these, not easily avoidable in a lot of cases +RSpec/AnyInstance: + Enabled: false diff --git a/app/form_models/jobseekers/job_application/religion_details_form.rb b/app/form_models/jobseekers/job_application/religion_details_form.rb index 67da59c1b3..e86acaf407 100644 --- a/app/form_models/jobseekers/job_application/religion_details_form.rb +++ b/app/form_models/jobseekers/job_application/religion_details_form.rb @@ -11,6 +11,7 @@ def self.fields religious_referee_role religious_referee_email religious_referee_phone + baptism_certificate baptism_address baptism_date] end @@ -25,4 +26,18 @@ def self.fields validates :baptism_address, :baptism_date, presence: true, if: -> { religious_reference_type == "baptism_date" } + + validates :baptism_certificate, form_file: true, presence: true, if: -> { religious_reference_type == "baptism_certificate" } + + def file_type + :document + end + + def file_size_limit + 5.megabytes + end + + def content_types_allowed + %w[application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document].freeze + end end diff --git a/app/models/job_application.rb b/app/models/job_application.rb index ecacc2259f..81024248c2 100644 --- a/app/models/job_application.rb +++ b/app/models/job_application.rb @@ -72,6 +72,8 @@ class JobApplication < ApplicationRecord validates :email_address, email_address: true, if: -> { email_address_changed? } # Allows data created prior to validation to still be valid + has_one_attached :baptism_certificate, service: :amazon_s3_documents + def name "#{first_name} #{last_name}" end diff --git a/app/views/jobseekers/job_applications/_job_application_review_sections.html.slim b/app/views/jobseekers/job_applications/_job_application_review_sections.html.slim index 02f35df687..2c899ac3c7 100644 --- a/app/views/jobseekers/job_applications/_job_application_review_sections.html.slim +++ b/app/views/jobseekers/job_applications/_job_application_review_sections.html.slim @@ -4,6 +4,8 @@ = render "jobseekers/job_applications/review/training_and_cpds", r: r, job_application: job_application = render "jobseekers/job_applications/review/employment_history", r: r, job_application: job_application = render "jobseekers/job_applications/review/personal_statement", r: r, job_application: job_application +- if job_application.vacancy.religion_type.present? + = render "jobseekers/job_applications/review/religious_information", r: r, job_application: job_application = render "jobseekers/job_applications/review/references", r: r, job_application: job_application - if jobseeker_signed_in? = render "jobseekers/job_applications/review/equal_opportunities", r: r diff --git a/app/views/jobseekers/job_applications/build/religion_details.html.slim b/app/views/jobseekers/job_applications/build/religion_details.html.slim index b277d55fbc..7a13ded5b9 100644 --- a/app/views/jobseekers/job_applications/build/religion_details.html.slim +++ b/app/views/jobseekers/job_applications/build/religion_details.html.slim @@ -11,26 +11,26 @@ = form_for form, url: wizard_path, method: :patch do |f| = f.govuk_error_summary - = f.govuk_text_field :faith, label: { size: "s", text: t(".faith.text") }, hint: { text: t(".faith.hint") } + = f.govuk_text_field :faith, label: { size: "s" } = f.govuk_text_area :place_of_worship, label: { size: "s", text: t(".place_of_worship.text") }, rows: 6, hint: { text: t(".place_of_worship.hint") } = f.govuk_radio_buttons_fieldset :religious_reference_type, hint: -> { t(".referee_type.hints_html") } do - = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.referee") } 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, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_certificate") } do + = f.govuk_radio_button :religious_reference_type, :baptism_certificate do = f.govuk_file_field :baptism_certificate, - label: { size: "m" }, - accept: ".doc, .docx, .pdf", + label: { size: "s" }, + accept: ".doc, .docx, .pdf .png", enctype: "multipart/form-data" - = f.govuk_radio_button :religious_reference_type, :baptism_date, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_date") } do + = 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, label: { text: t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.no_referee") } + = 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/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim new file mode 100644 index 0000000000..543f90c7ba --- /dev/null +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -0,0 +1,54 @@ +- r.with_section :religion_details + = govuk_summary_list do |summary_list| + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion") + - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.no") + + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_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_religion_details_form.religious_reference_type") + - row.with_value text: t("helpers.label.jobseekers_job_application_religion_details_form.religious_reference_type_options.#{job_application.religious_reference_type}") + + - case job_application.religious_reference_type + - when "referee" + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_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_religion_details_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_religion_details_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_religion_details_form.religious_referee_phone") + - row.with_value text: job_application.religious_referee_phone + + - when "baptism_certificate" + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_form.baptism_certificate") + - row.with_value text: job_application.baptism_certificate.filename + + - when "baptism_date" + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_form.baptism_date") + - row.with_value text: job_application.baptism_date.to_formatted_s(:day_month_year) + diff --git a/config/locales/activerecord.yml b/config/locales/activerecord.yml index df03197a3d..1527d1ece1 100644 --- a/config/locales/activerecord.yml +++ b/config/locales/activerecord.yml @@ -569,6 +569,12 @@ en: email: Enter a valid email address religious_reference_type: inclusion: Select if you can provide a religious referee + baptism_address: + blank: Enter the address of the baptism + baptism_date: + blank: Enter the baptism date + baptism_certificate: + blank: Upload your baptism certificate jobseekers/job_application/professional_status_form: attributes: qualified_teacher_status: diff --git a/config/locales/forms.yml b/config/locales/forms.yml index d40917ed6a..b0fe799e66 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -181,6 +181,10 @@ en: benefit letter, payslip or P60. For example, ‘QQ 12 34 56 C’. phone_number: Enter a phone number you are happy to be contacted on. For example, 01632 960 001, 07700 900 982 or +44 0808 157 0192. previous_names: For example maiden name or name at birth, if different from the name you have now. + jobseekers_job_application_religion_details_form: + baptism_date: For example 27 3 2007 + faith: For example, Christian. + place_of_worship: For example, Westminster Abbey, Dean's Yard, London. jobseekers_qualifications_degree_form: institution: For example, a university or college qualifications_section_completed: Ensure you've added all the education and qualifications you've done. @@ -533,6 +537,25 @@ en: training_and_cpds_section_completed_options: false: No, I'll come back to it later true: Yes, I've completed this section + jobseekers_job_application_following_religion_form: + following_religion: Are you currently following a religion or faith? + "yes": "Yes" + "no": "No" + jobseekers_job_application_religion_details_form: + 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" + 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_review_form: update_profile_options: qualifications: Update qualifications on profile @@ -940,16 +963,7 @@ en: "no": "No" jobseekers_job_application_religion_details_form: religious_reference_type: Can you provide a religious referee? - 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" - 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_date: What was the date of your baptism? jobseekers_break_form: ended_on: End of gap started_on: Start of gap diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 532cd8493d..8b3e3793f0 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -186,9 +186,6 @@ en: religion_details: heading: Religious information title: Religious information — Application - faith: - text: What is your religious denomination or faith? - hint: For example, Christian. place_of_worship: text: Address of place of worship (optional) hint: For example, Westminster Abbey, Dean's Yard, London. diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index 74586b4d1c..46b24b1163 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -102,49 +102,33 @@ context "with a catholic vacancy" do let(:vacancy) { create(:vacancy, job_roles: ["teacher"], organisations: [organisation], religion_type: :catholic) } - it "allows jobseekers to complete an application and go to review page", :js do + before do visit jobseekers_job_application_build_path(job_application, :personal_details) - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_details.heading")) - expect(page).to have_field("Email address", with: jobseeker.email) - validates_step_complete fill_in_personal_details click_on I18n.t("buttons.save_and_continue") - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.professional_status.heading")) validates_step_complete fill_in_professional_status click_on I18n.t("buttons.save_and_continue") - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.qualifications.heading")) - validates_step_complete choose I18n.t("helpers.label.jobseekers_job_application_qualifications_form.qualifications_section_completed_options.true") click_on I18n.t("buttons.save_and_continue") - expect(page).not_to have_content("There is a problem") + click_on I18n.t("buttons.back") click_on I18n.t("buttons.add_qualification") - validates_step_complete(button: I18n.t("buttons.continue")) + select_qualification_category("Undergraduate degree") - expect(page).to have_content(I18n.t("jobseekers.job_applications.qualifications.new.heading.undergraduate")) - validates_step_complete(button: I18n.t("buttons.save_qualification.one")) fill_in_undergraduate_degree click_on I18n.t("buttons.save_qualification.one") click_on I18n.t("buttons.save_and_continue") - expect(page).to have_content("Training and continuing professional development (CPD)") - validates_step_complete click_on "Add training" - click_on "Save and continue" - expect(page).to have_content("There is a problem") fill_in_training_and_cpds click_on "Save and continue" choose "Yes, I've completed this section" click_on "Save and continue" - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.employment_history.heading")) - validates_step_complete click_on I18n.t("buttons.add_work_history") - click_on I18n.t("buttons.save_employment") - expect(page).to have_content("There is a problem") fill_in_employment_history click_on I18n.t("buttons.save_employment") click_on I18n.t("buttons.add_reason_for_break") @@ -153,70 +137,150 @@ choose I18n.t("helpers.label.jobseekers_job_application_employment_history_form.employment_history_section_completed_options.true") click_on I18n.t("buttons.save_and_continue") - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.personal_statement.heading")) - validates_step_complete fill_in_personal_statement click_on I18n.t("buttons.save_and_continue") + end + it "validates first religion step" do expect(page).to have_content(I18n.t("jobseekers.job_applications.build.following_religion.heading")) validates_step_complete expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/following_religion_form.attributes.following_religion.inclusion")) - choose "Yes" - click_on I18n.t("buttons.save_and_continue") + end - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.religion_details.faith.hint")) - validates_step_complete - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.faith.blank")) - expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_reference_type.inclusion")) - fill_in "What is your religious denomination or faith?", with: "Catholic" - choose I18n.t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.no_referee") - click_on I18n.t("buttons.save_and_continue") - # validates_step_complete - sleep 20 - - # choose "Yes" - # validates_step_complete - # sleep 20 - # - # choose I18n.t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_certificate") - # validates_step_complete - # sleep 20 - # - # choose I18n.t("helpers.legend.jobseekers_job_application_religion_details_form.religious_reference_type_options.baptism_date") - # validates_step_complete - # sleep 20 - # - # click_on I18n.t("buttons.save_and_continue") - # sleep 200 + context "when on religious details step" do + before do + choose "Yes" + click_on I18n.t("buttons.save_and_continue") + end - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) - expect(page).not_to have_content(I18n.t("buttons.save_and_continue")) - click_on I18n.t("buttons.add_reference") - click_on I18n.t("buttons.save_reference") - expect(page).to have_content("There is a problem") - fill_in_reference - click_on I18n.t("buttons.save_reference") - click_on I18n.t("buttons.add_another_reference") - fill_in_reference - click_on I18n.t("buttons.save_reference") - click_on I18n.t("buttons.save_and_continue") + it "produces the correct errors" do + expect(page).to have_content(I18n.t("helpers.hint.jobseekers_job_application_religion_details_form.faith")) + validates_step_complete + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.faith.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_reference_type.inclusion")) + end - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.equal_opportunities.heading")) - validates_step_complete - fill_in_equal_opportunities - click_on I18n.t("buttons.save_and_continue") + context "with a denomination" do + before do + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.faith"), with: "follower of #{Faker::Religion::Bible.character}" + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.place_of_worship"), with: "#{Faker::Address.city} Church" + end - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.ask_for_support.heading")) - validates_step_complete - fill_in_ask_for_support - click_on I18n.t("buttons.save_and_continue") + context "with a referee" do + before do + choose I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_reference_type_options.referee") + end - expect(page).to have_content(I18n.t("jobseekers.job_applications.build.declarations.heading")) - validates_step_complete - fill_in_declarations - click_on I18n.t("buttons.save_and_continue") + let(:referee_name) { Faker::Name.name } + let(:referee_address) { Faker::Address.full_address } + let(:referee_role) { "Pastor at #{Faker::Religion::Bible.location}" } + let(:referee_email) { Faker::Internet.email(domain: "contoso.com") } + let(:referee_phone) { Faker::PhoneNumber.phone_number } - expect(current_path).to eq(jobseekers_job_application_review_path(job_application)) + it "produces the correct error messages" do + validates_step_complete + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_referee_name.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_referee_role.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_referee_address.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_referee_email.blank")) + end + + it "allows jobseekers to specify a religious referee" do + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_name"), with: referee_name + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_address"), with: referee_address + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_role"), with: referee_role + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_email"), with: referee_email + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_phone"), with: referee_phone + 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 + + expect(page).to have_content(referee_name) + expect(page).to have_content(referee_address) + expect(page).to have_content(referee_role) + expect(page).to have_content(referee_email) + expect(page).to have_content(referee_phone) + end + end + + context "with a baptism certificate" do + before do + choose I18n.t("helpers.label.jobseekers_job_application_religion_details_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/religion_details_form.attributes.baptism_certificate.blank")) + end + + it "allows the certificate to be uploaded" do + page.attach_file("jobseekers-job-application-religion-details-form-baptism-certificate-field", Rails.root.join("spec/fixtures/files/blank_job_spec.pdf")) + + allow_any_instance_of(FormFileValidator).to receive(:virus_free?).and_return(true) + 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 + expect(page).to have_content("blank_job_spec.pdf") + end + end + + context "with an address and date of baptism" do + before do + choose I18n.t("helpers.label.jobseekers_job_application_religion_details_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/religion_details_form.attributes.baptism_address.blank")) + expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_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_religion_details_form.baptism_address"), with: baptism_address + fill_in "Day", with: 7 + fill_in "Month", with: 3 + fill_in "Year", with: 2007 + 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 + + expect(page).to have_content("07 March 2007") + expect(page).to have_content(baptism_address) + end + end + + context "without a referee" do + before do + choose I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_reference_type_options.no_referee") + end + + it "allows jobseeker to not specify a religious referee" do + click_on I18n.t("buttons.save_and_continue") + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) + end + end + end end end + + def complete_from_references_page + click_on I18n.t("buttons.add_reference") + fill_in_reference + click_on I18n.t("buttons.save_reference") + click_on I18n.t("buttons.add_another_reference") + fill_in_reference + click_on I18n.t("buttons.save_reference") + click_on I18n.t("buttons.save_and_continue") + + fill_in_equal_opportunities + click_on I18n.t("buttons.save_and_continue") + + fill_in_ask_for_support + click_on I18n.t("buttons.save_and_continue") + + fill_in_declarations + click_on I18n.t("buttons.save_and_continue") + end end From 3b5b74f73bd01476fa468518f69115c1e375d180 Mon Sep 17 00:00:00 2001 From: starswan Date: Wed, 30 Oct 2024 16:30:45 +0000 Subject: [PATCH 05/16] slim lint errors --- .../job_applications/review/_religious_information.html.slim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/jobseekers/job_applications/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index 543f90c7ba..e029ee4891 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -2,7 +2,7 @@ = govuk_summary_list do |summary_list| - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion") - - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.no") + - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.no") - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_form.faith") @@ -51,4 +51,3 @@ - summary_list.with_row do |row| - row.with_key text: t("helpers.legend.jobseekers_job_application_religion_details_form.baptism_date") - row.with_value text: job_application.baptism_date.to_formatted_s(:day_month_year) - From 28006efbfa90a8997af9aa9bdb9cf923695ee41f Mon Sep 17 00:00:00 2001 From: starswan Date: Thu, 31 Oct 2024 09:02:38 +0000 Subject: [PATCH 06/16] add blurb to references screen --- .../job_applications/review/_religious_information.html.slim | 4 +++- config/locales/jobseekers.yml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/jobseekers/job_applications/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index e029ee4891..d1759a5f28 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -1,4 +1,6 @@ - r.with_section :religion_details + 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_following_religion_form.following_religion") @@ -40,7 +42,7 @@ - when "baptism_certificate" - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_form.baptism_certificate") + - row.with_key text: t("jobseekers.job_applications.review.religious_information.baptism_certificate") - row.with_value text: job_application.baptism_certificate.filename - when "baptism_date" diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 8b3e3793f0..e33f2a0c0f 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -501,6 +501,9 @@ en: warning: You cannot review a non-draft job application training_and_cpds: none: You have not added any training. + religious_information: + heading: The school is a school with a religious character, please therefore provide the additional information requested as appropriate. + baptism_certificate: Baptism certficate show: application_sections: Application sections ask_for_support: From 5434ab94667664ab5a48782b7e8530c2af1cf75e Mon Sep 17 00:00:00 2001 From: starswan Date: Thu, 31 Oct 2024 14:46:05 +0000 Subject: [PATCH 07/16] fix up issues with submitting job application --- .../job_application_review_component.rb | 16 ++++--- .../religious_information_section.rb | 7 +++ .../following_religion_form.rb | 5 ++- .../job_applications/build/_steps.html.slim | 5 ++- .../build/following_religion.html.slim | 6 ++- .../review/_religious_information.html.slim | 6 +-- config/locales/forms.yml | 8 ++-- ...d_following_religion_to_job_application.rb | 5 ++- ...ers_can_complete_a_job_application_spec.rb | 45 ++++++++++++------- 9 files changed, 66 insertions(+), 37 deletions(-) create mode 100644 app/components/job_application_review_component/religious_information_section.rb diff --git a/app/components/job_application_review_component.rb b/app/components/job_application_review_component.rb index c4b88a6c1d..ef63ce7897 100644 --- a/app/components/job_application_review_component.rb +++ b/app/components/job_application_review_component.rb @@ -1,11 +1,15 @@ class JobApplicationReviewComponent < ReviewComponent renders_many(:sections, lambda do |section_name, **kwargs| - JobApplicationReviewComponent::Section.new( - @job_application, - allow_edit: @allow_edit, - name: section_name, - **kwargs, - ) + if section_name == :religious_information + ReligiousInformationSection.new(@job_application) + else + JobApplicationReviewComponent::Section.new( + @job_application, + allow_edit: @allow_edit, + name: section_name, + **kwargs, + ) + end end) def initialize(job_application, step_process:, allow_edit: nil, classes: [], html_attributes: {}, **) diff --git a/app/components/job_application_review_component/religious_information_section.rb b/app/components/job_application_review_component/religious_information_section.rb new file mode 100644 index 0000000000..63a682373e --- /dev/null +++ b/app/components/job_application_review_component/religious_information_section.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class JobApplicationReviewComponent::ReligiousInformationSection < JobApplicationReviewComponent::Section + def initialize(job_application) + super(job_application, forms: %w[FollowingReligionForm ReligionDetailsForm], name: :following_religion) + end +end diff --git a/app/form_models/jobseekers/job_application/following_religion_form.rb b/app/form_models/jobseekers/job_application/following_religion_form.rb index dbcf72b232..d6784df6d3 100644 --- a/app/form_models/jobseekers/job_application/following_religion_form.rb +++ b/app/form_models/jobseekers/job_application/following_religion_form.rb @@ -1,10 +1,11 @@ class Jobseekers::JobApplication::FollowingReligionForm < Jobseekers::JobApplication::BaseForm include ActiveModel::Model + include ActiveModel::Attributes def self.fields %i[following_religion] end - attr_accessor(*fields) + attribute :following_religion, :boolean - validates :following_religion, inclusion: { in: %w[yes no] } + validates :following_religion, inclusion: { in: [true, false] } end diff --git a/app/views/jobseekers/job_applications/build/_steps.html.slim b/app/views/jobseekers/job_applications/build/_steps.html.slim index 365e01b119..3daf509471 100644 --- a/app/views/jobseekers/job_applications/build/_steps.html.slim +++ b/app/views/jobseekers/job_applications/build/_steps.html.slim @@ -1,4 +1,5 @@ = render StepsComponent.new title: t("jobseekers.job_applications.review.steps"), classes: "govuk-!-margin-top-6" do |component| - - step_process.step_groups.keys.excluding(:review).each do |wizard_step| - - component.with_step(label: t("jobseekers.job_applications.build.#{wizard_step}.step_title"), current: (wizard_step == step_process.current_step_group), completed: wizard_step.to_s.in?(job_application.completed_steps)) + - step_process.step_groups.excluding(:review).each do |step_group, wizard_steps| + - component.with_step(label: t("jobseekers.job_applications.build.#{step_group}.step_title"), + current: (step_group == step_process.current_step_group), completed: wizard_steps.map(&:to_s).intersection(job_application.completed_steps).map(&:to_sym) == wizard_steps) - component.with_step(label: t("jobseekers.job_applications.review.heading"), current: false, completed: false) diff --git a/app/views/jobseekers/job_applications/build/following_religion.html.slim b/app/views/jobseekers/job_applications/build/following_religion.html.slim index b7ee903573..ecbfb6129b 100644 --- a/app/views/jobseekers/job_applications/build/following_religion.html.slim +++ b/app/views/jobseekers/job_applications/build/following_religion.html.slim @@ -20,8 +20,10 @@ = f.govuk_error_summary = f.govuk_radio_buttons_fieldset :following_religion do - = f.govuk_radio_button :following_religion, :yes, link_errors: true, label: { text: t("helpers.legend.jobseekers_job_application_following_religion_form.yes") } - = f.govuk_radio_button :following_religion, :no, label: { text: t("helpers.legend.jobseekers_job_application_following_religion_form.no") } + = f.govuk_radio_button :following_religion, true, link_errors: true, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") } + = f.govuk_radio_button :following_religion, false, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") } + / = f.govuk_radio_button :following_religion, :yes, link_errors: true + / = f.govuk_radio_button :following_religion, :no = 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/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index d1759a5f28..4a11e2953c 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -1,10 +1,10 @@ -- r.with_section :religion_details +- r.with_section :religious_information 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_following_religion_form.following_religion") - - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.no") + - row.with_key text: t("helpers.legend.jobseekers_job_application_following_religion_form.following_religion") + - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_form.faith") diff --git a/config/locales/forms.yml b/config/locales/forms.yml index b0fe799e66..2ae4b44f60 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -538,9 +538,9 @@ en: false: No, I'll come back to it later true: Yes, I've completed this section jobseekers_job_application_following_religion_form: - following_religion: Are you currently following a religion or faith? - "yes": "Yes" - "no": "No" + following_religion_options: + "yes": "Yes" + "no": "No" jobseekers_job_application_religion_details_form: religious_reference_type_options: referee: "Yes" @@ -959,8 +959,6 @@ en: religion: What is your religion or belief? jobseekers_job_application_following_religion_form: following_religion: Are you currently following a religion or faith? - "yes": "Yes" - "no": "No" jobseekers_job_application_religion_details_form: religious_reference_type: Can you provide a religious referee? baptism_date: What was the date of your baptism? diff --git a/db/migrate/20241028134844_add_following_religion_to_job_application.rb b/db/migrate/20241028134844_add_following_religion_to_job_application.rb index 97a35aade6..7030e400da 100644 --- a/db/migrate/20241028134844_add_following_religion_to_job_application.rb +++ b/db/migrate/20241028134844_add_following_religion_to_job_application.rb @@ -1,6 +1,9 @@ class AddFollowingReligionToJobApplication < ActiveRecord::Migration[7.1] def change - add_column :job_applications, :following_religion, :boolean, null: false, default: false + # we might need to know if this boolean is unknown - so it needs to be tri-state + # rubocop:disable Rails/ThreeStateBooleanColumn + add_column :job_applications, :following_religion, :boolean + # rubocop:enable Rails/ThreeStateBooleanColumn add_column :job_applications, :religious_reference_type, :integer add_column :job_applications, :faith, :string add_column :job_applications, :place_of_worship, :string diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index 46b24b1163..bf45603be6 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -153,7 +153,7 @@ click_on I18n.t("buttons.save_and_continue") end - it "produces the correct errors" do + it "produces the correct errors", :js do expect(page).to have_content(I18n.t("helpers.hint.jobseekers_job_application_religion_details_form.faith")) validates_step_complete expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.faith.blank")) @@ -185,21 +185,34 @@ expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.religious_referee_email.blank")) end - it "allows jobseekers to specify a religious referee" do - fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_name"), with: referee_name - fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_address"), with: referee_address - fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_role"), with: referee_role - fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_email"), with: referee_email - fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_phone"), with: referee_phone - 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 - - expect(page).to have_content(referee_name) - expect(page).to have_content(referee_address) - expect(page).to have_content(referee_role) - expect(page).to have_content(referee_email) - expect(page).to have_content(referee_phone) + context "when on review page" do + before do + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_name"), with: referee_name + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_address"), with: referee_address + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_role"), with: referee_role + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_email"), with: referee_email + fill_in I18n.t("helpers.label.jobseekers_job_application_religion_details_form.religious_referee_phone"), with: referee_phone + click_on I18n.t("buttons.save_and_continue") + complete_from_references_page + end + + it "has the correct content" do + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) + + expect(page).to have_content(referee_name) + expect(page).to have_content(referee_address) + expect(page).to have_content(referee_role) + expect(page).to have_content(referee_email) + expect(page).to have_content(referee_phone) + end + + it "can be submitted as an application" do + 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") + click_on I18n.t("buttons.submit_application") + click_on "View your applications" + expect(page).to have_content(vacancy.job_title) + end end end From 0ff07bf8ab5b95aaeada07ca885ad94bd8637a4d Mon Sep 17 00:00:00 2001 From: starswan Date: Thu, 31 Oct 2024 16:26:09 +0000 Subject: [PATCH 08/16] cope with candidate not following a religion --- .../job_applications/build_controller.rb | 4 +- .../review/_religious_information.html.slim | 95 ++++++++++--------- ...ers_can_complete_a_job_application_spec.rb | 14 ++- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/app/controllers/jobseekers/job_applications/build_controller.rb b/app/controllers/jobseekers/job_applications/build_controller.rb index 403dd2f22a..3267a17e9c 100644 --- a/app/controllers/jobseekers/job_applications/build_controller.rb +++ b/app/controllers/jobseekers/job_applications/build_controller.rb @@ -10,6 +10,8 @@ class Jobseekers::JobApplications::BuildController < Jobseekers::JobApplications def show skip_step_if_missing + skip_step if step == :religion_details && !job_application.following_religion + render_wizard end @@ -18,7 +20,7 @@ def update job_application.update(update_params.except(:teacher_reference_number, :has_teacher_reference_number)) update_or_create_jobseeker_profile! if step == :professional_status - return redirect_to finish_wizard_path, success: t("messages.jobseekers.job_applications.saved") if redirect_to_review? + return redirect_to finish_wizard_path, success: t("messages.jobseekers.job_applications.saved") if redirect_to_review? && step_process.last_of_group? render_wizard job_application else diff --git a/app/views/jobseekers/job_applications/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index 4a11e2953c..a98479b72a 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -6,50 +6,51 @@ - row.with_key text: t("helpers.legend.jobseekers_job_application_following_religion_form.following_religion") - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") - - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_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_religion_details_form.religious_reference_type") - - row.with_value text: t("helpers.label.jobseekers_job_application_religion_details_form.religious_reference_type_options.#{job_application.religious_reference_type}") - - - case job_application.religious_reference_type - - when "referee" - - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_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_religion_details_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_religion_details_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_religion_details_form.religious_referee_phone") - - row.with_value text: job_application.religious_referee_phone - - - when "baptism_certificate" - - summary_list.with_row do |row| - - row.with_key text: t("jobseekers.job_applications.review.religious_information.baptism_certificate") - - row.with_value text: job_application.baptism_certificate.filename - - - when "baptism_date" - - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_form.baptism_date") - - row.with_value text: job_application.baptism_date.to_formatted_s(:day_month_year) + - if job_application.following_religion + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_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_religion_details_form.religious_reference_type") + - row.with_value text: t("helpers.label.jobseekers_job_application_religion_details_form.religious_reference_type_options.#{job_application.religious_reference_type}") + + - case job_application.religious_reference_type + - when "referee" + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_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_religion_details_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_religion_details_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_religion_details_form.religious_referee_phone") + - row.with_value text: job_application.religious_referee_phone + + - when "baptism_certificate" + - summary_list.with_row do |row| + - row.with_key text: t("jobseekers.job_applications.review.religious_information.baptism_certificate") + - row.with_value text: job_application.baptism_certificate.filename + + - when "baptism_date" + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_job_application_religion_details_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_religion_details_form.baptism_date") + - row.with_value text: job_application.baptism_date.to_formatted_s(:day_month_year) diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index bf45603be6..068ccba97c 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -147,7 +147,19 @@ expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/following_religion_form.attributes.following_religion.inclusion")) end - context "when on religious details step" do + context "when not following a religion" do + before do + choose "No" + click_on I18n.t("buttons.save_and_continue") + end + + it "skips the religion details step" do + expect(page).to have_current_path(jobseekers_job_application_build_path(job_application, :references)) + complete_from_references_page + end + end + + context "when following a religion" do before do choose "Yes" click_on I18n.t("buttons.save_and_continue") From 930be75a9778b52c499d5b3b23942288ea2ac508 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 09:35:40 +0000 Subject: [PATCH 09/16] Disallow edits on religious info form when viewing --- app/components/job_application_review_component.rb | 3 ++- .../religious_information_section.rb | 9 +++++++-- .../jobseekers/job_applications/build_controller.rb | 4 +++- .../jobseekers/job_application/religion_details_form.rb | 6 +++++- .../review/_religious_information.html.slim | 7 ++++--- config/locales/activerecord.yml | 4 ++++ 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/components/job_application_review_component.rb b/app/components/job_application_review_component.rb index ef63ce7897..fe1f0600c5 100644 --- a/app/components/job_application_review_component.rb +++ b/app/components/job_application_review_component.rb @@ -1,7 +1,8 @@ class JobApplicationReviewComponent < ReviewComponent renders_many(:sections, lambda do |section_name, **kwargs| if section_name == :religious_information - ReligiousInformationSection.new(@job_application) + ReligiousInformationSection.new(@job_application, + allow_edit: @allow_edit) else JobApplicationReviewComponent::Section.new( @job_application, diff --git a/app/components/job_application_review_component/religious_information_section.rb b/app/components/job_application_review_component/religious_information_section.rb index 63a682373e..1a25da7844 100644 --- a/app/components/job_application_review_component/religious_information_section.rb +++ b/app/components/job_application_review_component/religious_information_section.rb @@ -1,7 +1,12 @@ # frozen_string_literal: true class JobApplicationReviewComponent::ReligiousInformationSection < JobApplicationReviewComponent::Section - def initialize(job_application) - super(job_application, forms: %w[FollowingReligionForm ReligionDetailsForm], name: :following_religion) + def initialize(job_application, allow_edit:) + # don't include the details for if we don't follow a religion + if job_application.following_religion + super(job_application, forms: %w[FollowingReligionForm ReligionDetailsForm], name: :following_religion, allow_edit: allow_edit) + else + super(job_application, forms: %w[FollowingReligionForm], name: :following_religion, allow_edit: allow_edit) + end end end diff --git a/app/controllers/jobseekers/job_applications/build_controller.rb b/app/controllers/jobseekers/job_applications/build_controller.rb index 3267a17e9c..c526fff3aa 100644 --- a/app/controllers/jobseekers/job_applications/build_controller.rb +++ b/app/controllers/jobseekers/job_applications/build_controller.rb @@ -20,7 +20,9 @@ def update job_application.update(update_params.except(:teacher_reference_number, :has_teacher_reference_number)) update_or_create_jobseeker_profile! if step == :professional_status - return redirect_to finish_wizard_path, success: t("messages.jobseekers.job_applications.saved") if redirect_to_review? && step_process.last_of_group? + if redirect_to_review? && (step_process.last_of_group? || (step == :following_religion && !job_application.following_religion)) + return redirect_to finish_wizard_path, success: t("messages.jobseekers.job_applications.saved") + end render_wizard job_application else diff --git a/app/form_models/jobseekers/job_application/religion_details_form.rb b/app/form_models/jobseekers/job_application/religion_details_form.rb index e86acaf407..90e88e32b1 100644 --- a/app/form_models/jobseekers/job_application/religion_details_form.rb +++ b/app/form_models/jobseekers/job_application/religion_details_form.rb @@ -33,8 +33,12 @@ def file_type :document end + def valid_file_types + %i[PDF DOC DOCX] + end + def file_size_limit - 5.megabytes + 10.megabytes end def content_types_allowed diff --git a/app/views/jobseekers/job_applications/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index a98479b72a..94eb4285a5 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -2,9 +2,10 @@ 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.legend.jobseekers_job_application_following_religion_form.following_religion") - - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") + - if job_application.following_religion.in? [true,false] + - summary_list.with_row do |row| + - row.with_key text: t("helpers.legend.jobseekers_job_application_following_religion_form.following_religion") + - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") - if job_application.following_religion - summary_list.with_row do |row| diff --git a/config/locales/activerecord.yml b/config/locales/activerecord.yml index 1527d1ece1..18aa7933ac 100644 --- a/config/locales/activerecord.yml +++ b/config/locales/activerecord.yml @@ -621,6 +621,10 @@ en: incomplete: Complete your qualifications references: incomplete: Complete your references + following_religion: + incomplete: Complete your religious information + religion_details: + incomplete: Complete your religious information training_and_cpds: incomplete: Complete your training and CPD jobseekers/job_application/withdraw_form: From 70f63a2b04c75bbd065511b02d41c25f61c993fd Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 09:40:19 +0000 Subject: [PATCH 10/16] anchor link on view application for relgious section --- app/views/jobseekers/job_applications/_show.html.slim | 1 + config/locales/jobseekers.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/views/jobseekers/job_applications/_show.html.slim b/app/views/jobseekers/job_applications/_show.html.slim index 8bb8c8deee..4adb83fe97 100644 --- a/app/views/jobseekers/job_applications/_show.html.slim +++ b/app/views/jobseekers/job_applications/_show.html.slim @@ -10,6 +10,7 @@ - navigation.with_anchor text: t(".qualifications.heading"), href: "#qualifications" - navigation.with_anchor text: t(".employment_history.heading"), href: "#employment_history" - navigation.with_anchor text: t(".personal_statement.heading"), href: "#personal_statement" + - navigation.with_anchor text: t(".religious_information.heading"), href: "#following_religion" - navigation.with_anchor text: t(".references.heading"), href: "#references" - navigation.with_anchor text: t(".ask_for_support.heading"), href: "#ask_for_support" - navigation.with_anchor text: t(".declarations.heading"), href: "#declarations" diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index e33f2a0c0f..81bcb7397f 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -539,6 +539,8 @@ en: your_address: Your address personal_statement: heading: Personal statement + religious_information: + heading: Religious Information professional_status: heading: Professional status statutory_induction_complete: Have you completed your statutory induction period? From 0421e18c46435777e5d11a516d291310075bba24 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 11:29:07 +0000 Subject: [PATCH 11/16] only shwo religious information where relevant --- app/views/jobseekers/job_applications/_show.html.slim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/jobseekers/job_applications/_show.html.slim b/app/views/jobseekers/job_applications/_show.html.slim index 4adb83fe97..dd860d9c24 100644 --- a/app/views/jobseekers/job_applications/_show.html.slim +++ b/app/views/jobseekers/job_applications/_show.html.slim @@ -10,7 +10,8 @@ - navigation.with_anchor text: t(".qualifications.heading"), href: "#qualifications" - navigation.with_anchor text: t(".employment_history.heading"), href: "#employment_history" - navigation.with_anchor text: t(".personal_statement.heading"), href: "#personal_statement" - - navigation.with_anchor text: t(".religious_information.heading"), href: "#following_religion" + - if vacancy.religion_type + - navigation.with_anchor text: t(".religious_information.heading"), href: "#following_religion" - navigation.with_anchor text: t(".references.heading"), href: "#references" - navigation.with_anchor text: t(".ask_for_support.heading"), href: "#ask_for_support" - navigation.with_anchor text: t(".declarations.heading"), href: "#declarations" From 95242d638538de5d30222c2e3910323b67058603 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 11:49:49 +0000 Subject: [PATCH 12/16] added baptism certificate to fields as it is not an 'attribute' --- app/controllers/jobseekers/job_applications_controller.rb | 1 + .../job_applications/review/_religious_information.html.slim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/jobseekers/job_applications_controller.rb b/app/controllers/jobseekers/job_applications_controller.rb index 6443b79d79..64c5fc94aa 100644 --- a/app/controllers/jobseekers/job_applications_controller.rb +++ b/app/controllers/jobseekers/job_applications_controller.rb @@ -128,6 +128,7 @@ def step_valid?(step) attributes = job_application.attributes.slice(*step_form.fields.map(&:to_s)) attributes.merge!(trn_params) if step == :professional_status + attributes.merge!(baptism_certificate: job_application.baptism_certificate) if step == :religion_details form = step_form.new(attributes) diff --git a/app/views/jobseekers/job_applications/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index 94eb4285a5..b3f75b77a4 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -45,7 +45,7 @@ - when "baptism_certificate" - summary_list.with_row do |row| - row.with_key text: t("jobseekers.job_applications.review.religious_information.baptism_certificate") - - row.with_value text: job_application.baptism_certificate.filename + - row.with_value text: govuk_link_to("#{job_application.baptism_certificate.filename} (#{number_to_human_size(job_application.baptism_certificate.byte_size)})", job_application.baptism_certificate, download: "true") - when "baptism_date" - summary_list.with_row do |row| From e5c93b87543d9423f00f1db4d0333e495dff5e56 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 13:53:15 +0000 Subject: [PATCH 13/16] add test to submit an application with a baptism certificate --- .../jobseekers/job_applications_controller.rb | 20 ++++++------- ...ers_can_complete_a_job_application_spec.rb | 28 ++++++++++++++----- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/app/controllers/jobseekers/job_applications_controller.rb b/app/controllers/jobseekers/job_applications_controller.rb index 64c5fc94aa..e484509f50 100644 --- a/app/controllers/jobseekers/job_applications_controller.rb +++ b/app/controllers/jobseekers/job_applications_controller.rb @@ -126,9 +126,16 @@ def all_steps_valid? def step_valid?(step) step_form = "jobseekers/job_application/#{step}_form".camelize.constantize - attributes = job_application.attributes.slice(*step_form.fields.map(&:to_s)) - attributes.merge!(trn_params) if step == :professional_status - attributes.merge!(baptism_certificate: job_application.baptism_certificate) if step == :religion_details + attributes = step_form.storable_fields.index_with do |field| + case field + when :teacher_reference_number + current_jobseeker&.jobseeker_profile&.teacher_reference_number + when :has_teacher_reference_number + current_jobseeker&.jobseeker_profile&.has_teacher_reference_number + else + job_application.public_send(field) + end + end form = step_form.new(attributes) @@ -233,11 +240,4 @@ def previous_application? def quick_apply? previous_application? || profile.present? end - - def trn_params - { - teacher_reference_number: current_jobseeker&.jobseeker_profile&.teacher_reference_number, - has_teacher_reference_number: current_jobseeker&.jobseeker_profile&.has_teacher_reference_number, - } - end end diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index 068ccba97c..2c275fdc8b 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -238,14 +238,28 @@ expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.baptism_certificate.blank")) end - it "allows the certificate to be uploaded" do - page.attach_file("jobseekers-job-application-religion-details-form-baptism-certificate-field", Rails.root.join("spec/fixtures/files/blank_job_spec.pdf")) + context "with an uploaded baptism cerificate" do + before do + page.attach_file("jobseekers-job-application-religion-details-form-baptism-certificate-field", Rails.root.join("spec/fixtures/files/blank_job_spec.pdf")) - allow_any_instance_of(FormFileValidator).to receive(:virus_free?).and_return(true) - 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 - expect(page).to have_content("blank_job_spec.pdf") + allow_any_instance_of(FormFileValidator).to receive(:virus_free?).and_return(true) + click_on I18n.t("buttons.save_and_continue") + end + + it "allows the certificate to be uploaded" do + expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) + complete_from_references_page + expect(page).to have_content("blank_job_spec.pdf") + end + + 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") + click_on I18n.t("buttons.submit_application") + click_on "View your applications" + expect(page).to have_content(vacancy.job_title) + end end end From 66a715fd337ac7ab43d4bd6c75ef9704845a3fc5 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 13:55:21 +0000 Subject: [PATCH 14/16] create blank baptism cert --- spec/fixtures/files/blank_baptism_cert.pdf | Bin 0 -> 28527 bytes ...ekers_can_complete_a_job_application_spec.rb | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 spec/fixtures/files/blank_baptism_cert.pdf diff --git a/spec/fixtures/files/blank_baptism_cert.pdf b/spec/fixtures/files/blank_baptism_cert.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4eac350d71562502789821d206836b75e4cb4b7d GIT binary patch literal 28527 zcmeI5do+~W|HnJ-#@=U_N-a+JnQp(_WtbsdG>3qz1E)f zdCM5^Yh0F3l zt}YBNONYf|+p{1I4YViMgT-(~`=Au*%jxp;$E)`!?K4u6S1`P9BHt{4j<<+cT+f$M z{js|EOCI)&%aEI0eb4v;%uTwbt+E1vg^cZd6KM08&c3&I#P z92b5)SZ-WM`RnLRS)Ob!4<^eKQu%72u-&-Gb5DpjBV_o7EPE%0HrofX!XgGdi3ky~ z1RFFmgT*+!cHd@h?7?Q5vAB>G5=@5*VfMNrA+;B;l*Q{_$Ogh#(CnO9OfJOB*Iri` zA}&PJ(BP$Jv16X;TgQtjB`tVizE0;`7Z@`yJMO{+7s5f915Wlx`pHB*gxSM#ay-I? zU_6XP;vh5g;IMh`0nPRBLUKW2yRbdXI1DBWB7g0g=YwPiW6VO5!r^)`Tp)~@A;a@1 zg!HhG5N#)}C-RiScIB|$5MMOu-{0}bV;IH9$5(e{KC7QC_=_f^CK$ypxN<%AFt`Cp z04o7d04M+y015yFfC4}Ppa4(+C;$`y3IGLw0zd(v08juZ02BZU00n>oKmnitPyi?Z z6aWeU1%LuT0iXa-04M+y015yFfC4}Ppa4(+C;$`y3IGLw0zd(v08juZ02BZU00n>o zKmnitPyi?Z6aWeU1%LuT0iXa-04VtXO2Ifkf7^wWoPU=5;T6N-)yIK}WD@yX(VT@U zH9u6%f#LsC*_^+M?!OV5Mh`?qpB(ARQ0KbFRU{zs*8P{NC)amI#GYve&u z98ehuR7C<5015yFfC4}Ppa4(+C;$`y3IGLw0zd(v08juZ02BZU00n@8{}lzFYWObX zcAfg?iNeA`0q^iY1qwNMNxJKfI_OV1&pBV6=Gp25v}EeQ5D`z*G+@`TuXS z2YGRhbhDRY4O3NvTefKOp%hYxTEB7?QkMM`wd$(Kc};C0_$Sff=C0*u(bCcu)WdY0 z+9E!j`3?&cmlw)M8gZC`{H5nz2w?(xtw9=3=d0?r|ewL z%@mLZzu4_0?q3t#Vt8Qu(;+O)g%M#PwqP7rqe$WtTLe^jeb_xnW5! zlkO)PFAX=lvsIS6=0>WJSaS$dEykzr;Oi?Bwx_c;lj}VQYiA>U`sRlTUp@%n&)Q1#U>R#>KaY`Wi;6bQjwu?G=VEi_@8NQnyg*F zqwu~&%?9Jk31;cg0^zPXL^;Bi)_Vl$QUWIb2q;@O9k z6;GtON|vYEulhd`n-ujEsyg-YD&{dmqU!?ZB8ieH{BT`=Xn2jx+ov4U4iRgie31j; zN9#)8sk#$6RX5{q(tM*?x*m10yFQOoKCuN< zwc-vNa^yJ6g-&wo0<__j^M%ozcup)Q9INR=+a^K?>(ddp!@}p{wXFA8Q#$s!$R=;| zUi&%h&Nh*~m+TEcY}1XpnWkYSKY9Li z(?G^x{*Jso9k&XXk2{oYOutW`rQh7H zPj{xD&790!nSnXvQIo1GGX@c94%fu4+&iFXnq#Jx*Z!y;jz|bJko1%( zPWFu@UooN+5A*~x zhylTyV5FRn9mPuGU~B^8dSlv?o@9l)&)VomZZ(y(PM%08KUn#4d$D=3W1nT8#Dw+) zbz+$qcLh7#SFBWws1z2PADa+srBrY*#oWkTJ7;4~PJ3o)acQGpj@OiEooJatw?e6z zpUV*ymrDVcsFyUX3}0bit-FzTqu|;_1H+4!Dy5!7L^ZjJ9Tk2RpFcW(-11Rz_|-@! z$$~sC;Vj{%`gAk@<~Y?G%NNZmypx9g*i`Xx6F8*Eje-|dWZa?d?O z9Sg);6z{%2P;iJ%Vdo#qn_@~arK%qpUCwaP_ZIZWe2ytdDtIuVy zwdQ5!ZBWjrB2*hHa!JIJR{l-=p&^MOVuDF4Wd%Y7{EqVVGWPC`3C5O3 zxJSGO-eGgFP8Oe6a;c4Hgq0;vUOF9q$7(ASvbJbTHzUorr?PRkgNP&bVQ#|owq^}y z6S^Z_+0Shn3zj$=)?7S^h+9SNvqEo-aB0v(bet| zYDUhoG7a?!tTe0?50DC68f4t1ATO?NIANej^N$@(sNQnict9yvv|4mJEL*ogIYjw} zV?g7X#*P^B#dVk45)B_3HEBqjuXX(OQO`jCj>f@Q3;kbZswO)6T@#7hgkwhU>v}l$ z-{{R^-hIMKI5jMH(6;(Opy7POwEM*BoyIoMAx?Qs_F=Eu*1DRyPO)zB4`SXsaMmRO zCY^R4yEp4c$z*h}}Bf5UNEx*nLp=Yv+ zEXpk`JBpi`Z67cHzB@c{)Nho)PBbNP@ zZm;~h{eGW$#d^c4XxZPgqUAI3{)@+^wb}AnK4tEs_g2KTZZBhBbvy4ml!wl7e&urA zcdif9RySlts3ttH;+EyU`M^*NdjE&3#;c1r-n(L6&rctCQgF;$VB|;^Atx_)YkTkW zU0IPiW3vzbC_9~`s-}M|@U_gFwhA@psRY5e)2Dac@^2?xjktcVwyMd$U}U26dAogU zN$SDka_;WoxRIcF|K_o>)h8tfNCSR_gHeMiN}&m%`j%0#A+agujH7HTJFBU4QCl~U zNREVlDV$?IH@TBaXuzM%Q#0Cih#N4e^ET{l^!aEEE&cM)So|yZFWkDpOO6i7gQ}bS zKF*fccxI@*Op<%(pS;_zcCPMRc)qw5hHUFxKFpmSUzed6T9H^`nSaaLwW7~Eugc$V z>i73=p3`2B-*z9B?e9ysdRumj-SDQmHM*nKKQyTS^d8cVd&jQb}B8@NAEs?2Gon!rf-2S9ERe<5wr47)wU*4$h>eDwqJaD+HtF*s3 zd39w}<$B+Pvt>h_R)-E&s!m2e+8q}va$4|^zHMan!3p!vBl*W#-*~OmTeaKo@?2mK zrAcojvSN36;LxnZm+8UASxg#czpc{k8$m1PJ|4#VbLn+49u3YY36-l(PJC={)Z?|N z_~(3?#rKX5!7J=%gZS<>PVJ2Q65jCMZF;qZFv@EeAG`upm(S;tFNnRc{^(yk@V-znkPBMvmt6(dnpuch9}D& zf_b}bQ^@Aq?)zIio=(k*B_y6)Gi2NIT%iB#@|Sj)j|a;EjfG$W8vEx5QXvqO36KNy)rKRIv50CK z?*q9l+OSwy1^HXm-)uM{k?^Apalj#o{hJ@smViiv{b0ip|LLc!g8U)tZ+M3k$;SV!xPCr&I5-h!H6!~kNshPjEk&B{C7642gAvQ<*^`QXXfO`Lh=V; zOxbLnfZD>cL?qN4*vR5q5JKClgDfv~92rk0!Z@;>iV9wtgk>;r4on7)iN~ohNDg*P gf(H8ET@XRI1w}k$Z7jSv90{vJM$5?P(x~YF0>Tk49smFU literal 0 HcmV?d00001 diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index 2c275fdc8b..f76551e9c9 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -240,7 +240,7 @@ context "with an uploaded baptism cerificate" do before do - page.attach_file("jobseekers-job-application-religion-details-form-baptism-certificate-field", Rails.root.join("spec/fixtures/files/blank_job_spec.pdf")) + page.attach_file("jobseekers-job-application-religion-details-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") From 9093a97eb1f09ba2433f2d8ef7c9f78897bb92f4 Mon Sep 17 00:00:00 2001 From: starswan Date: Fri, 1 Nov 2024 15:21:18 +0000 Subject: [PATCH 15/16] copy religious information from previous job application --- .github/workflows/lint.yml | 2 +- .rubocop_todo.yml | 63 ++----------------- .../job_application_review_component.rb | 5 +- .../religious_information_section.rb | 15 ++--- app/form_models/base_form.rb | 7 +++ .../job_application/religion_details_form.rb | 18 +----- .../publishers/job_listing/vacancy_form.rb | 7 --- app/models/job_application.rb | 2 + app/models/vacancy.rb | 2 - ...b_application_from_previous_application.rb | 33 ++++++++-- app/services/step_process.rb | 4 +- .../job_applications/_show.html.slim | 2 +- .../build/following_religion.html.slim | 2 - .../build/religion_details.html.slim | 2 +- .../review/_religious_information.html.slim | 4 +- config/locales/jobseekers.yml | 3 - ...1025154606_add_religion_type_to_vacancy.rb | 5 -- ..._following_religion_to_job_application.rb} | 0 db/schema.rb | 13 +++- spec/rails_helper.rb | 3 +- .../jobseekers/govuk_one_login_spec.rb | 2 +- ...ers_can_complete_a_job_application_spec.rb | 8 ++- .../jobseekers_can_sign_in_by_email_spec.rb | 2 - ...shers_are_redirected_after_sign_in_spec.rb | 2 +- 24 files changed, 82 insertions(+), 124 deletions(-) delete mode 100644 db/migrate/20241025154606_add_religion_type_to_vacancy.rb rename db/migrate/{20241028134844_add_following_religion_to_job_application.rb => 20241030134844_add_following_religion_to_job_application.rb} (100%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d81c0b2b73..00d7ba7bdb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: run: bundle exec rubocop - name: Run Slim-Lint with PR annotations - run: bundle exec slim-lint -r github app/views app/components + run: bundle exec slim-lint app/views app/components - name: Run Brakeman run: bundle exec brakeman diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d6b4032f3a..cfe2eeebd0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 350` -# on 2024-10-31 16:37:50 UTC using RuboCop version 1.64.1. +# on 2024-11-04 13:50:21 UTC using RuboCop version 1.64.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -36,7 +36,7 @@ Capybara/ClickLinkOrButtonStyle: - 'spec/system/support_users/feedback_spec.rb' - 'spec/system/support_users/service_data_spec.rb' -# Offense count: 326 +# Offense count: 333 # This cop supports safe autocorrection (--autocorrect). Capybara/CurrentPathExpectation: Exclude: @@ -317,61 +317,10 @@ Lint/MissingSuper: Metrics/BlockLength: Max: 28 -# Offense count: 19 +# Offense count: 20 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 188 - -# Offense count: 91 -RSpec/AnyInstance: - Exclude: - - 'spec/controllers/jobseekers/subscriptions_controller_spec.rb' - - 'spec/form_models/publishers/job_listing/documents_form_spec.rb' - - 'spec/form_models/publishers/organisation/logo_form_spec.rb' - - 'spec/form_models/publishers/organisation/photo_form_spec.rb' - - 'spec/jobs/alert_mailer_job_spec.rb' - - 'spec/jobs/send_daily_alert_email_job_spec.rb' - - 'spec/jobs/send_weekly_alert_email_job_spec.rb' - - 'spec/lib/modules/aws_ip_ranges_spec.rb' - - 'spec/mailers/jobseekers/alert_mailer_spec.rb' - - 'spec/mailers/jobseekers/subscription_mailer_spec.rb' - - 'spec/rails_helper.rb' - - 'spec/requests/cors_spec.rb' - - 'spec/requests/jobseekers/job_applications/build_spec.rb' - - 'spec/requests/jobseekers/job_applications/employments_spec.rb' - - 'spec/requests/jobseekers/job_applications/qualifications_spec.rb' - - 'spec/requests/jobseekers/job_applications/references_spec.rb' - - 'spec/requests/jobseekers/profiles/employments_spec.rb' - - 'spec/requests/jobseekers/unsubscribe_feedbacks_spec.rb' - - 'spec/requests/publishers/notifications_spec.rb' - - 'spec/requests/publishers/organisations/logo_spec.rb' - - 'spec/requests/publishers/sessions_spec.rb' - - 'spec/requests/publishers/vacancies/application_forms_spec.rb' - - 'spec/requests/publishers/vacancies/build_spec.rb' - - 'spec/requests/publishers/vacancies/documents_spec.rb' - - 'spec/requests/publishers/vacancies/end_listing_spec.rb' - - 'spec/requests/publishers/vacancies/extend_deadline_spec.rb' - - 'spec/requests/publishers/vacancies/job_applications_spec.rb' - - 'spec/requests/publishers/vacancies/statistics_spec.rb' - - 'spec/requests/recaptcha_spec.rb' - - 'spec/services/image_manipulator_spec.rb' - - 'spec/services/jobseekers/account_transfer_spec.rb' - - 'spec/system/jobseekers/jobseekers_can_create_a_job_alert_from_a_mailing_campaign_spec.rb' - - 'spec/system/jobseekers/jobseekers_can_create_a_job_alert_from_a_search_spec.rb' - - 'spec/system/jobseekers/jobseekers_can_create_a_job_alert_from_the_dashboard_spec.rb' - - 'spec/system/jobseekers/jobseekers_can_give_job_alert_feedback_spec.rb' - - 'spec/system/jobseekers/jobseekers_can_search_for_jobs_spec.rb' - - 'spec/system/jobseekers/jobseekers_can_view_an_organisation_spec.rb' - - 'spec/system/other/general_feedback_spec.rb' - - 'spec/system/other/get_help_spec.rb' - - 'spec/system/publishers/publishers_can_delete_vacancies_spec.rb' - - 'spec/system/publishers/publishers_can_edit_a_published_vacancy_as_a_school_spec.rb' - - 'spec/system/publishers/publishers_can_manage_a_profile_spec.rb' - - 'spec/system/publishers/publishers_can_preview_a_profile_spec.rb' - - 'spec/system/publishers/publishers_can_publish_a_vacancy_as_a_school_spec.rb' - - 'spec/system/publishers/publishers_can_sign_in_by_email_spec.rb' - - 'spec/system/publishers/publishers_get_email_notifications_from_job_applications_spec.rb' - - 'spec/validators/form_file_validator_spec.rb' + Max: 190 # Offense count: 79 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -1417,7 +1366,7 @@ Rails/CompactBlank: - 'app/services/search/criteria_inventor.rb' - 'app/services/zendesk.rb' -# Offense count: 48 +# Offense count: 50 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowToTime. # SupportedStyles: strict, flexible @@ -1825,7 +1774,7 @@ Style/DateTime: - 'spec/system/publishers/publishers_are_reminded_of_application_functionality_spec.rb' - 'spec/system/publishers/publishers_can_extend_a_deadline_spec.rb' -# Offense count: 298 +# Offense count: 299 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize, WordRegex. # SupportedStyles: percent, brackets diff --git a/app/components/job_application_review_component.rb b/app/components/job_application_review_component.rb index fe1f0600c5..695c32ae9c 100644 --- a/app/components/job_application_review_component.rb +++ b/app/components/job_application_review_component.rb @@ -1,10 +1,11 @@ class JobApplicationReviewComponent < ReviewComponent renders_many(:sections, lambda do |section_name, **kwargs| - if section_name == :religious_information + if section_name == :following_religion ReligiousInformationSection.new(@job_application, + name: section_name, allow_edit: @allow_edit) else - JobApplicationReviewComponent::Section.new( + Section.new( @job_application, allow_edit: @allow_edit, name: section_name, diff --git a/app/components/job_application_review_component/religious_information_section.rb b/app/components/job_application_review_component/religious_information_section.rb index 1a25da7844..60feeb73d4 100644 --- a/app/components/job_application_review_component/religious_information_section.rb +++ b/app/components/job_application_review_component/religious_information_section.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true class JobApplicationReviewComponent::ReligiousInformationSection < JobApplicationReviewComponent::Section - def initialize(job_application, allow_edit:) - # don't include the details for if we don't follow a religion - if job_application.following_religion - super(job_application, forms: %w[FollowingReligionForm ReligionDetailsForm], name: :following_religion, allow_edit: allow_edit) - else - super(job_application, forms: %w[FollowingReligionForm], name: :following_religion, allow_edit: allow_edit) - end + def initialize(job_application, allow_edit:, name:) + # only include the details form if we follow a religion + forms = if job_application.following_religion + %w[FollowingReligionForm ReligionDetailsForm] + else + %w[FollowingReligionForm] + end + super(job_application, forms: forms, name: name, allow_edit: allow_edit) end end diff --git a/app/form_models/base_form.rb b/app/form_models/base_form.rb index 018dbdce0e..28e3397dee 100644 --- a/app/form_models/base_form.rb +++ b/app/form_models/base_form.rb @@ -8,6 +8,13 @@ class BaseForm valid_file_types: %i[JPG JPEG PNG].freeze, }.freeze + DOCUMENT_VALIDATION_OPTIONS = { + file_type: :document, + content_types_allowed: %w[application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document].freeze, + file_size_limit: 10.megabytes, + valid_file_types: %i[PDF DOC DOCX], + }.freeze + include ActiveModel::Model include ActiveModel::Validations::Callbacks diff --git a/app/form_models/jobseekers/job_application/religion_details_form.rb b/app/form_models/jobseekers/job_application/religion_details_form.rb index 90e88e32b1..e4805b9016 100644 --- a/app/form_models/jobseekers/job_application/religion_details_form.rb +++ b/app/form_models/jobseekers/job_application/religion_details_form.rb @@ -27,21 +27,5 @@ def self.fields validates :baptism_address, :baptism_date, presence: true, if: -> { religious_reference_type == "baptism_date" } - validates :baptism_certificate, form_file: true, presence: true, if: -> { religious_reference_type == "baptism_certificate" } - - def file_type - :document - end - - def valid_file_types - %i[PDF DOC DOCX] - end - - def file_size_limit - 10.megabytes - end - - def content_types_allowed - %w[application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document].freeze - end + validates :baptism_certificate, form_file: DOCUMENT_VALIDATION_OPTIONS, presence: true, if: -> { religious_reference_type == "baptism_certificate" } end diff --git a/app/form_models/publishers/job_listing/vacancy_form.rb b/app/form_models/publishers/job_listing/vacancy_form.rb index 1f7fc56db5..c71269f063 100644 --- a/app/form_models/publishers/job_listing/vacancy_form.rb +++ b/app/form_models/publishers/job_listing/vacancy_form.rb @@ -1,13 +1,6 @@ class Publishers::JobListing::VacancyForm < BaseForm attr_accessor :params, :vacancy, :completed_steps, :current_organisation - DOCUMENT_VALIDATION_OPTIONS = { - file_type: :document, - content_types_allowed: %w[application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document].freeze, - file_size_limit: 10.megabytes, - valid_file_types: %i[PDF DOC DOCX], - }.freeze - def initialize(params = {}, vacancy = nil, current_publisher = nil) @params = params @vacancy = vacancy diff --git a/app/models/job_application.rb b/app/models/job_application.rb index 81024248c2..63e41325dd 100644 --- a/app/models/job_application.rb +++ b/app/models/job_application.rb @@ -27,6 +27,8 @@ class JobApplication < ApplicationRecord training_and_cpds: 9, employment_history: 3, personal_statement: 4, + following_religion: 10, + religion_details: 11, references: 5, equal_opportunities: 6, ask_for_support: 7, diff --git a/app/models/vacancy.rb b/app/models/vacancy.rb index 7ed204f0d1..e91d203458 100644 --- a/app/models/vacancy.rb +++ b/app/models/vacancy.rb @@ -57,8 +57,6 @@ class Vacancy < ApplicationRecord enum religion_type: { no_religion: 0, other_religion: 1, catholic: 2 } - enum religion_type: { no_religion: 0, other_religion: 1, catholic: 2 } - belongs_to :publisher, optional: true belongs_to :publisher_organisation, class_name: "Organisation", optional: true 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 20a2cf2dbc..22003e3b53 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 @@ -21,13 +21,29 @@ def call private def copy_personal_info - new_job_application.assign_attributes(recent_job_application.slice(*attributes_to_copy)) + attributes = attributes_to_copy + if attributes.include? :baptism_certificate + new_job_application.assign_attributes(recent_job_application.slice(*(attributes - [:baptism_certificate]))) + + if recent_job_application.baptism_certificate.present? + recent_job_application.baptism_certificate.blob.open do |tempfile| + new_job_application.baptism_certificate.attach({ + io: tempfile, + filename: recent_job_application.baptism_certificate.blob.filename, + content_type: recent_job_application.baptism_certificate.blob.content_type, + }) + end + end + else + new_job_application.assign_attributes(recent_job_application.slice(*attributes)) + end end def attributes_to_copy - %i[personal_details professional_status ask_for_support personal_statement].select { |step| relevant_steps.include?(step) } - .map { |step| form_fields_from_step(step) } - .flatten - jobseeker_profile_fields + %i[personal_details professional_status ask_for_support personal_statement following_religion religion_details] + .select { |step| relevant_steps.include?(step) } + .map { |step| form_fields_from_step(step) } + .flatten - jobseeker_profile_fields end def jobseeker_profile_fields @@ -87,11 +103,16 @@ 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 + step_process = if vacancy.religion_type.present? + Jobseekers::JobApplications::ReligiousJobApplicationStepProcess.new(:review, job_application: new_job_application) + else + Jobseekers::JobApplications::JobApplicationStepProcess.new(:review, job_application: new_job_application) + end + step_process.steps end def completed_steps - completed_steps = %w[personal_details personal_statement references ask_for_support qualifications training_and_cpds].select { |step| relevant_steps.include?(step.to_sym) } + completed_steps = %w[personal_details personal_statement references ask_for_support qualifications training_and_cpds following_religion religion_details].select { |step| relevant_steps.include?(step.to_sym) } completed_steps << "employment_history" unless previous_application_was_submitted_before_we_began_validating_gaps_in_work_history? completed_steps << "professional_status" if previous_application_has_professional_status_details? completed_steps diff --git a/app/services/step_process.rb b/app/services/step_process.rb index 06b5e0f69c..bffac7c3ba 100644 --- a/app/services/step_process.rb +++ b/app/services/step_process.rb @@ -7,9 +7,7 @@ def initialize(current_step, step_groups = {}) @current_step = current_step.to_sym @step_groups = step_groups.compact_blank - unless current_step.in?(steps) - raise MissingStepError, "Current step `#{current_step}` missing from steps (#{steps.join(', ')})" - end + raise MissingStepError, "Current step `#{current_step}` missing from steps (#{steps.join(', ')})" unless current_step.in?(steps) end # Returns the keys of all individual steps in order diff --git a/app/views/jobseekers/job_applications/_show.html.slim b/app/views/jobseekers/job_applications/_show.html.slim index dd860d9c24..3ff7cfc19f 100644 --- a/app/views/jobseekers/job_applications/_show.html.slim +++ b/app/views/jobseekers/job_applications/_show.html.slim @@ -10,7 +10,7 @@ - navigation.with_anchor text: t(".qualifications.heading"), href: "#qualifications" - navigation.with_anchor text: t(".employment_history.heading"), href: "#employment_history" - navigation.with_anchor text: t(".personal_statement.heading"), href: "#personal_statement" - - if vacancy.religion_type + - if vacancy.religion_type.present? - navigation.with_anchor text: t(".religious_information.heading"), href: "#following_religion" - navigation.with_anchor text: t(".references.heading"), href: "#references" - navigation.with_anchor text: t(".ask_for_support.heading"), href: "#ask_for_support" diff --git a/app/views/jobseekers/job_applications/build/following_religion.html.slim b/app/views/jobseekers/job_applications/build/following_religion.html.slim index ecbfb6129b..89069e8f40 100644 --- a/app/views/jobseekers/job_applications/build/following_religion.html.slim +++ b/app/views/jobseekers/job_applications/build/following_religion.html.slim @@ -22,8 +22,6 @@ = f.govuk_radio_buttons_fieldset :following_religion do = f.govuk_radio_button :following_religion, true, link_errors: true, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") } = f.govuk_radio_button :following_religion, false, label: { text: t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") } - / = f.govuk_radio_button :following_religion, :yes, link_errors: true - / = f.govuk_radio_button :following_religion, :no = 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/religion_details.html.slim b/app/views/jobseekers/job_applications/build/religion_details.html.slim index 7a13ded5b9..99b047038b 100644 --- a/app/views/jobseekers/job_applications/build/religion_details.html.slim +++ b/app/views/jobseekers/job_applications/build/religion_details.html.slim @@ -13,7 +13,7 @@ = f.govuk_text_field :faith, label: { size: "s" } - = f.govuk_text_area :place_of_worship, label: { size: "s", text: t(".place_of_worship.text") }, rows: 6, hint: { text: t(".place_of_worship.hint") } + = f.govuk_text_area :place_of_worship, label: { size: "s" }, rows: 6 = f.govuk_radio_buttons_fieldset :religious_reference_type, hint: -> { t(".referee_type.hints_html") } do = f.govuk_radio_button :religious_reference_type, :referee, link_errors: true do diff --git a/app/views/jobseekers/job_applications/review/_religious_information.html.slim b/app/views/jobseekers/job_applications/review/_religious_information.html.slim index b3f75b77a4..bf726995c1 100644 --- a/app/views/jobseekers/job_applications/review/_religious_information.html.slim +++ b/app/views/jobseekers/job_applications/review/_religious_information.html.slim @@ -1,8 +1,8 @@ -- r.with_section :religious_information +- r.with_section :following_religion 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] + - if job_application.following_religion.in? [true, false] - summary_list.with_row do |row| - row.with_key text: t("helpers.legend.jobseekers_job_application_following_religion_form.following_religion") - row.with_value text: job_application.following_religion ? t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.yes") : t("helpers.label.jobseekers_job_application_following_religion_form.following_religion_options.no") diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 81bcb7397f..a74eaa9c6e 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -186,9 +186,6 @@ en: religion_details: heading: Religious information title: Religious information — Application - place_of_worship: - text: Address of place of worship (optional) - hint: For example, Westminster Abbey, Dean's Yard, London. referee_type: text: Can you provide a religious referee? hints_html: >- diff --git a/db/migrate/20241025154606_add_religion_type_to_vacancy.rb b/db/migrate/20241025154606_add_religion_type_to_vacancy.rb deleted file mode 100644 index 1469760526..0000000000 --- a/db/migrate/20241025154606_add_religion_type_to_vacancy.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddReligionTypeToVacancy < ActiveRecord::Migration[7.1] - def change - add_column :vacancies, :religion_type, :integer - end -end diff --git a/db/migrate/20241028134844_add_following_religion_to_job_application.rb b/db/migrate/20241030134844_add_following_religion_to_job_application.rb similarity index 100% rename from db/migrate/20241028134844_add_following_religion_to_job_application.rb rename to db/migrate/20241030134844_add_following_religion_to_job_application.rb diff --git a/db/schema.rb b/db/schema.rb index 342a3ec814..8c976f876a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_10_29_154606) do +ActiveRecord::Schema[7.1].define(version: 2024_10_30_134844) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" enable_extension "citext" @@ -246,6 +246,17 @@ t.text "safeguarding_issue_details" t.boolean "training_and_cpds_section_completed" t.integer "imported_steps", default: [], null: false, array: true + t.boolean "following_religion" + t.integer "religious_reference_type" + t.string "faith" + t.string "place_of_worship" + t.string "religious_referee_name" + t.string "religious_referee_address" + t.string "religious_referee_role" + t.string "religious_referee_email" + t.string "religious_referee_phone" + t.string "baptism_address" + t.date "baptism_date" t.index ["jobseeker_id"], name: "index_job_applications_jobseeker_id" t.index ["vacancy_id"], name: "index_job_applications_on_vacancy_id" end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ad672e84eb..4f8585916b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,4 +1,4 @@ -# require "spec_helper" +require "spec_helper" ENV["RAILS_ENV"] ||= "test" require File.expand_path("../config/environment", __dir__) abort("The Rails environment is running in production mode!") if Rails.env.production? @@ -32,6 +32,7 @@ Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end end + Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new(args: %w[no-sandbox disable-gpu window-size=1400,1800]) diff --git a/spec/requests/jobseekers/govuk_one_login_spec.rb b/spec/requests/jobseekers/govuk_one_login_spec.rb index da4aa814ed..6684b0d255 100644 --- a/spec/requests/jobseekers/govuk_one_login_spec.rb +++ b/spec/requests/jobseekers/govuk_one_login_spec.rb @@ -45,7 +45,7 @@ end before do - allow_any_instance_of(ApplicationController).to receive(:stored_location_for).and_return(devise_stored_location) # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(ApplicationController).to receive(:stored_location_for).and_return(devise_stored_location) allow(Jobseekers::GovukOneLogin::UserFromAuthResponse).to receive(:call).and_return(govuk_one_login_user) get root_path # Loads OneLogin Sign-in button and sets session values for user. end diff --git a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb index f76551e9c9..2c7fad78bd 100644 --- a/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_complete_a_job_application_spec.rb @@ -165,7 +165,7 @@ click_on I18n.t("buttons.save_and_continue") end - it "produces the correct errors", :js do + it "produces the correct errors" do expect(page).to have_content(I18n.t("helpers.hint.jobseekers_job_application_religion_details_form.faith")) validates_step_complete expect(page).to have_content(I18n.t("activemodel.errors.models.jobseekers/job_application/religion_details_form.attributes.faith.blank")) @@ -218,6 +218,10 @@ expect(page).to have_content(referee_phone) end + it "contains the entered information" do + expect(job_application.reload).to have_attributes(religious_reference_type: "referee") + end + it "can be submitted as an application" do 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") @@ -249,7 +253,7 @@ it "allows the certificate to be uploaded" do expect(page).to have_content(I18n.t("jobseekers.job_applications.build.references.heading")) complete_from_references_page - expect(page).to have_content("blank_job_spec.pdf") + expect(page).to have_content("blank_baptism_cert.pdf") end it "can be submitted as an application" do diff --git a/spec/system/jobseekers/jobseekers_can_sign_in_by_email_spec.rb b/spec/system/jobseekers/jobseekers_can_sign_in_by_email_spec.rb index e95cff4684..b6fd9fbecf 100644 --- a/spec/system/jobseekers/jobseekers_can_sign_in_by_email_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_sign_in_by_email_spec.rb @@ -21,7 +21,6 @@ let(:message_delivery) { instance_double(ActionMailer::MessageDelivery) } - # rubocop:disable RSpec/AnyInstance before do allow_any_instance_of(Jobseekers::LoginKeysController) .to receive(:generate_login_key) @@ -31,7 +30,6 @@ .with(login_key_id: login_key.id, jobseeker: jobseeker) .and_return(message_delivery) end - # rubocop:enable RSpec/AnyInstance context "when a jobseeker tries to sign in" do it "can sign in, sign out" do diff --git a/spec/system/publishers/publishers_are_redirected_after_sign_in_spec.rb b/spec/system/publishers/publishers_are_redirected_after_sign_in_spec.rb index 964754a016..8078f57ba0 100644 --- a/spec/system/publishers/publishers_are_redirected_after_sign_in_spec.rb +++ b/spec/system/publishers/publishers_are_redirected_after_sign_in_spec.rb @@ -45,7 +45,7 @@ end context "when the organisation's profile is incomplete" do - before { allow_any_instance_of(Organisation).to receive(:profile_complete?).and_return(false) } # rubocop:disable RSpec/AnyInstance + before { allow_any_instance_of(Organisation).to receive(:profile_complete?).and_return(false) } scenario "it redirects to the interstitial profile completion reminder page" do sign_in_publisher(navigate: true) From e5eea15d81c2ed202885d846d230401a15db2269 Mon Sep 17 00:00:00 2001 From: starswan Date: Tue, 5 Nov 2024 12:34:06 +0000 Subject: [PATCH 16/16] DRY up accept field on baptism certificate --- app/form_models/base_form.rb | 4 +++- .../job_applications/build/religion_details.html.slim | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/form_models/base_form.rb b/app/form_models/base_form.rb index 28e3397dee..7696ae969c 100644 --- a/app/form_models/base_form.rb +++ b/app/form_models/base_form.rb @@ -8,11 +8,13 @@ class BaseForm valid_file_types: %i[JPG JPEG PNG].freeze, }.freeze + VALID_DOCUMENT_TYPES = %i[PDF DOC DOCX] + DOCUMENT_VALIDATION_OPTIONS = { file_type: :document, content_types_allowed: %w[application/pdf application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document].freeze, file_size_limit: 10.megabytes, - valid_file_types: %i[PDF DOC DOCX], + valid_file_types: VALID_DOCUMENT_TYPES, }.freeze include ActiveModel::Model diff --git a/app/views/jobseekers/job_applications/build/religion_details.html.slim b/app/views/jobseekers/job_applications/build/religion_details.html.slim index 99b047038b..33528655dc 100644 --- a/app/views/jobseekers/job_applications/build/religion_details.html.slim +++ b/app/views/jobseekers/job_applications/build/religion_details.html.slim @@ -25,7 +25,7 @@ = f.govuk_radio_button :religious_reference_type, :baptism_certificate do = f.govuk_file_field :baptism_certificate, label: { size: "s" }, - accept: ".doc, .docx, .pdf .png", + 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