Skip to content

Commit

Permalink
Faith schools part 1 - publisher questions (#7210)
Browse files Browse the repository at this point in the history
  • Loading branch information
starswan committed Nov 5, 2024
1 parent 78c069e commit b0e12a4
Show file tree
Hide file tree
Showing 22 changed files with 229 additions and 32 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ Metrics/MethodLength:
- "spec/**/*"

Metrics/ModuleLength:
Max: 130 # Default 100
Exclude:
- "app/helpers/**/*"
- "spec/**/*"
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/concerns/publishers/wizardable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Publishers::Wizardable
module Publishers::Wizardable # rubocop:disable Metrics/ModuleLength
STRIP_CHECKBOXES = {
job_location: %i[organisation_ids],
education_phases: %i[phases],
Expand Down Expand Up @@ -104,6 +104,10 @@ def application_link_params(params)
.merge(completed_steps: completed_steps, current_organisation: current_organisation)
end

def religious_information_params(params)
params.require(:publishers_job_listing_religious_information_form).permit(:religion_type)
end

def school_visits_params(params)
if params[:publishers_job_listing_school_visits_form]
params.require(:publishers_job_listing_school_visits_form)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/publishers/vacancies/build_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Publishers::Vacancies::BuildController < Publishers::Vacancies::BaseContro
include OrganisationsHelper

steps :job_location, :job_title, :job_role, :education_phases, :key_stages, :subjects, :contract_type, :working_patterns,
:pay_package, :important_dates, :start_date, :applying_for_the_job, :how_to_receive_applications, :application_link,
:pay_package, :important_dates, :start_date, :applying_for_the_job, :how_to_receive_applications, :application_link, :religious_information,
:application_form, :school_visits, :visa_sponsorship, :contact_details, :about_the_role, :include_additional_documents, :documents

helper_method :form, :job_application_sample
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class Publishers::JobListing::ReligiousInformationForm < Publishers::JobListing::VacancyForm
validates_presence_of :religion_type

def self.fields
%i[religion_type]
end
attr_accessor(*fields)
end
2 changes: 2 additions & 0 deletions app/models/organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Organisation < ApplicationRecord

scope :visible_to_jobseekers, -> { schools.not_closed.not_out_of_scope.or(Organisation.trusts).registered_for_service }

scope :only_faith_schools, -> { where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", NON_FAITH_RELIGIOUS_CHARACTER_TYPES) }

validates :email, email_address: true, if: -> { email_changed? } # Allows data created prior to validation to still be valid

alias_attribute :data, :gias_data
Expand Down
4 changes: 4 additions & 0 deletions app/models/school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def religious_character
gias_data["ReligiousCharacter (name)"]
end

def faith_school?
religious_character.present?
end

def school_type
read_attribute(:school_type).singularize
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/school_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ def profile_complete?

super && schools.all?(&:profile_complete?)
end

def faith_school?
false
end
end
2 changes: 2 additions & 0 deletions app/models/vacancy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Vacancy < ApplicationRecord
enum :receive_applications, { email: 0, website: 1 }
enum :extension_reason, { no_applications: 0, didnt_find_right_candidate: 1, other_extension_reason: 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

Expand Down
4 changes: 2 additions & 2 deletions app/queries/vacancy_filter_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def add_school_type_filters(filters, built_scope)
built_scope = built_scope.joins(organisation_vacancies: :organisation)

if school_types.include?("faith_school") && school_types.include?("special_school")
built_scope.where.not("organisations.gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
built_scope.merge(Organisation.only_faith_schools)
.or(built_scope.where("organisations.detailed_school_type IN (?)", Organisation::SPECIAL_SCHOOL_TYPES)).distinct
elsif school_types.include?("faith_school")
built_scope.where.not("organisations.gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES).distinct
built_scope.merge(Organisation.only_faith_schools).distinct
elsif school_types.include?("special_school")
built_scope.where(organisations: { detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES }).distinct
else
Expand Down
2 changes: 2 additions & 0 deletions app/services/publishers/vacancies/vacancy_step_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def application_process_steps
steps = %i[school_visits visa_sponsorship contact_details]
steps.insert(0, :how_to_receive_applications) unless vacancy.enable_job_applications
steps.insert(1, application_method) if application_method.present?
elsif vacancy.organisations.any?(&:faith_school?) && vacancy.enable_job_applications
steps = %i[applying_for_the_job religious_information school_visits visa_sponsorship contact_details]
else
steps = %i[applying_for_the_job school_visits visa_sponsorship contact_details]
steps.insert(1, :how_to_receive_applications) unless vacancy.enable_job_applications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
= f.govuk_radio_buttons_fieldset :enable_job_applications, legend: { size: "m", tag: nil } do
= f.govuk_radio_button :enable_job_applications, true,
label: -> { safe_join([t("helpers.label.publishers_job_listing_applying_for_the_job_form.enable_job_applications_options.true"), govuk_tag(text: t(".kcsie_compliant"), colour: "green")]) },
hint: { text: t(".this_form_is_kept_up_to_date") },
hint: { text: vacancy.organisations.any?(&:faith_school?) ? t(".ask_about_religion") : t(".this_form_is_kept_up_to_date") },
link_errors: true
= f.govuk_radio_divider
= f.govuk_radio_button :enable_job_applications, "false"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- content_for :page_title_prefix, page_title_prefix(step_process, form)

.govuk-grid-row
.govuk-grid-column-two-thirds
= form_for form, url: wizard_path(current_step), method: :patch do |f|
= f.govuk_error_summary

= vacancy_form_page_heading(vacancy, step_process, back_path: back_path, fieldset: false)

= f.govuk_radio_buttons_fieldset :religion_type, legend: { size: "m", tag: "h2" } do
= f.govuk_radio_button :religion_type, :catholic, link_errors: true
= f.govuk_radio_button :religion_type, :other_religion

= f.govuk_radio_divider
= f.govuk_radio_button :religion_type, :no_religion

= render "publishers/vacancies/vacancy_form_partials/submit", f: f
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ shared:
- flexi_working
- extension_reason
- other_extension_reason_details
- religion_type
failed_imported_vacancies:
- id
- import_errors
Expand Down
10 changes: 10 additions & 0 deletions config/locales/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ en:
salary_types_options:
full_time: This is what the annual salary would be for someone working full time
part_time: This is the annual amount someone will take home
publishers_job_listing_religious_information_form:
religion_type_options:
catholic: This form has been approved by the Catholic Education Service.
publishers_job_listing_schools_form:
add_school: Add a school to your account
edit_schools_html: "Can't see the school you are looking for? %{link}"
Expand Down Expand Up @@ -856,6 +859,11 @@ en:
part_time: Actual salary
pay_scale: Pay scale
hourly_rate: Hourly rate of pay
publishers_job_listing_religious_information_form:
religion_type_options:
catholic: Their religion, place of worship and religious referee or baptism information
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
publishers_job_listing_school_visits_form:
school_visits_options:
false: "No"
Expand Down Expand Up @@ -1049,6 +1057,8 @@ en:
publishers_job_listing_pay_package_form:
salary_types: Salary details
benefits: Do you want to include additional allowances?
publishers_job_listing_religious_information_form:
religion_type: What would you like to ask applicants about their religion?
publishers_job_listing_school_visits_form:
school_visits: Do you want to offer school visits?
publishers_job_listing_working_patterns_form:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/publishers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ en:
kcsie_compliant: KCSIE compliant
reason_for_our_form: Online application forms make it quicker and easier for candidates to apply and may lead to more applicants for your role.
this_form_is_kept_up_to_date: This form is kept up to date with keeping children safe in education (KCSIE) guidance.
ask_about_religion: You'll be able to ask candidates about their religion.
step_title: Applying for the job
contact_details:
step_title: Contact details
Expand Down Expand Up @@ -656,6 +657,7 @@ en:
how_to_receive_applications: How do you want to receive applications?
application_link: Link to website
application_form: Receiving applications
religious_information: Applicants religious information
school_visits: Do you want to offer school visits?
contact_details: Contact details
about_the_role: About the role
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241025154606_add_religion_type_to_vacancy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddReligionTypeToVacancy < ActiveRecord::Migration[7.1]
def change
add_column :vacancies, :religion_type, :integer
end
end
6 changes: 5 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
bexleyheath_school = School.find_by!(urn: "137138")
weydon_trust = SchoolGroup.find_by!(uid: "16644")
southampton_la = SchoolGroup.find_by!(local_authority_code: "852")
plymouth_cast = SchoolGroup.find_by!(uid: "4214")

# Team users
users = [
Expand All @@ -32,7 +33,7 @@
]

users.each do |user|
Publisher.create(organisations: [bexleyheath_school, weydon_trust, southampton_la], **user)
Publisher.create(organisations: [bexleyheath_school, weydon_trust, southampton_la, plymouth_cast], **user)
SupportUser.create(user)
FactoryBot.create(:jobseeker, email: user[:email], password: "password")
end
Expand Down Expand Up @@ -110,3 +111,6 @@
end
end
end

# still need to delete jobs without an organisation
Vacancy.includes(:organisations).find_each.reject { |v| v.organisation.present? }.each(&:destroy)
2 changes: 1 addition & 1 deletion spec/factories/job_preferences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
phases { factory_rand_sample(Vacancy.phases.keys, 1..Vacancy.phases.keys.count) }
key_stages { key_stages_for_phases }
subjects { factory_rand_sample(SUBJECT_OPTIONS.map(&:first), 1..3) }
working_patterns { factory_rand_sample(Vacancy.working_patterns, 1..2) }
working_patterns { factory_rand_sample(Vacancy.working_patterns.keys, 1..2) }
builder_completed { true }
completed_steps do
{
Expand Down
1 change: 1 addition & 0 deletions spec/jobs/import_from_vacancy_source_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def each(...)
"readable_job_location" => nil,
"readable_phases" => [],
"receive_applications" => nil,
"religion_type" => nil,
"safeguarding_information" => nil,
"safeguarding_information_provided" => nil,
"salary" => "Main pay range 1 to Upper pay range 3, £23,719 to £39,406 per year (full time equivalent)",
Expand Down
22 changes: 21 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,23 @@
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,1400])

if ENV["SELENIUM_HUB_URL"]
Capybara::Selenium::Driver.new(app, browser: :remote, url: ENV.fetch("SELENIUM_HUB_URL", nil), options:)
else
Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
end
end
Capybara.javascript_driver = :chrome_headless
Capybara.server = :puma, { Silent: true, Threads: "0:1" }
Capybara.configure do |config|
# Allow us to use the `choose(label_text)` method in browser tests
# even when the radio button element attached to the label is hidden
# (as it is using the standard govuk radio element)
config.automatic_label_click = true
end

Rails.root.glob("spec/support/**/*.rb").each { |f| require f }
Rails.root.glob("spec/components/shared_examples/**/*.rb").each { |f| require f }
Expand Down Expand Up @@ -79,8 +94,13 @@
allow_any_instance_of(ApplicationController).to receive(:recaptcha_reply).and_return(recaptcha_reply)
end

# allow developers to see JS backed tests by default
config.before(:each, type: :system, js: true) do
driven_by :chrome_headless
if ENV.key? "CI"
driven_by :chrome_headless
else
driven_by :chrome
end
end

config.before(:each, geocode: true) do
Expand Down
40 changes: 39 additions & 1 deletion spec/support/vacancy_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def verify_all_vacancy_details(vacancy)
expect(page).to have_content(vacancy.actual_salary) if vacancy.salary_types.include?("part_time")
expect(page).to have_content(vacancy.pay_scale) if vacancy.salary_types.include?("pay_scale")

expect(page.html).to include(vacancy.benefits_details) if vacancy.benefits?
expect(page).to have_content(strip_tags(vacancy.benefits_details)) if vacancy.benefits?

expect(page).to have_content(vacancy.publish_on.to_formatted_s.strip)
expect(page).to have_content(vacancy.expires_at.to_date.to_formatted_s.strip)
Expand Down Expand Up @@ -398,4 +398,42 @@ def expect_correct_pay_package_options(vacancy)
end
end
end

def fill_in_forms_until_start_date(vacancy)
click_on I18n.t("buttons.create_job")
expect(page).to have_content(I18n.t("jobs.create_job_caption", step: 1, total: 4))
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :job_title), ignore_query: true)

fill_in_job_title_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :job_role), ignore_query: true)

fill_in_job_role_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :key_stages), ignore_query: true)

fill_in_key_stages_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :subjects), ignore_query: true)

fill_in_subjects_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :contract_type), ignore_query: true)

fill_in_contract_type_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :working_patterns), ignore_query: true)

fill_in_working_patterns_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :pay_package), ignore_query: true)

fill_in_pay_package_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :important_dates), ignore_query: true)

fill_in_important_dates_form_fields(vacancy)
click_on I18n.t("buttons.save_and_continue")
expect(page).to have_current_path(organisation_job_build_path(created_vacancy.id, :start_date), ignore_query: true)
end
end
Loading

0 comments on commit b0e12a4

Please sign in to comment.