Skip to content

Commit

Permalink
Add casual contract type and remove maternity or paternal cover type
Browse files Browse the repository at this point in the history
This commit adds casual contract type to vacancies and also removes the maternity cover type. Going forward parental cover will be handled by the user choosing fixed term contract and selecting is_parental_leave_cover = true
  • Loading branch information
KyleMacPherson committed Jul 12, 2024
1 parent cac26ec commit 612fd47
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/publishers/wizardable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def subjects_params(params)

def contract_type_params(params)
params.require(:publishers_job_listing_contract_type_form)
.permit(:contract_type, :fixed_term_contract_duration, :parental_leave_cover_contract_duration)
.permit(:contract_type, :fixed_term_contract_duration, :is_parental_leave_cover)
.merge(completed_steps: completed_steps)
end

Expand Down
6 changes: 3 additions & 3 deletions app/form_models/publishers/job_listing/contract_type_form.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class Publishers::JobListing::ContractTypeForm < Publishers::JobListing::VacancyForm
attr_accessor :contract_type, :fixed_term_contract_duration, :parental_leave_cover_contract_duration
attr_accessor :contract_type, :fixed_term_contract_duration, :parental_leave_cover_contract_duration, :is_parental_leave_cover

validates :contract_type, inclusion: { in: Vacancy.contract_types.keys }
validates :fixed_term_contract_duration, presence: true, if: -> { contract_type == "fixed_term" }
validates :parental_leave_cover_contract_duration, presence: true, if: -> { contract_type == "parental_leave_cover" }
validates :is_parental_leave_cover, inclusion: { in: ["true", "false", true, false] }, if: -> { contract_type == "fixed_term" }

def self.fields
%i[contract_type fixed_term_contract_duration parental_leave_cover_contract_duration]
%i[contract_type fixed_term_contract_duration parental_leave_cover_contract_duration is_parental_leave_cover]
end
end
2 changes: 1 addition & 1 deletion app/models/vacancy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Vacancy < ApplicationRecord
array_enum phases: { nursery: 0, primary: 1, middle: 2, secondary: 3, sixth_form_or_college: 4, through: 5 }
array_enum job_roles: JOB_ROLES

enum contract_type: { permanent: 0, fixed_term: 1, parental_leave_cover: 2 }
enum contract_type: { permanent: 0, fixed_term: 1, casual: 3 }
enum ect_status: { ect_suitable: 0, ect_unsuitable: 1 }
enum hired_status: { hired_tvs: 0, hired_other_free: 1, hired_paid: 2, hired_no_listing: 3, not_filled_ongoing: 4, not_filled_not_looking: 5, hired_dont_know: 6 }
enum listed_elsewhere: { listed_paid: 0, listed_free: 1, listed_mix: 2, not_listed: 3, listed_dont_know: 4 }
Expand Down
10 changes: 6 additions & 4 deletions app/presenters/vacancy_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ def readable_subjects
def contract_type_with_duration
return nil unless model.contract_type.present?

duration = model.fixed_term? ? model.fixed_term_contract_duration : model.parental_leave_cover_contract_duration
return I18n.t("publishers.vacancies.build.contract_type.#{model.contract_type}") if model.fixed_term_contract_duration.blank?

return I18n.t("helpers.label.publishers_job_listing_contract_type_form.contract_type_options.#{model.contract_type}") if duration.blank?

[I18n.t("helpers.label.publishers_job_listing_contract_type_form.contract_type_options.#{model.contract_type}"), duration].compact.join(" - ")
if is_parental_leave_cover
[I18n.t("publishers.vacancies.build.contract_type.#{model.contract_type}"), model.fixed_term_contract_duration, I18n.t("publishers.vacancies.build.contract_type.parental_leave")].compact.join(" - ")
else
[I18n.t("publishers.vacancies.build.contract_type.#{model.contract_type}"), model.fixed_term_contract_duration].compact.join(" - ")
end
end

def school_group_names
Expand Down
9 changes: 5 additions & 4 deletions app/views/publishers/vacancies/build/contract_type.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
= f.govuk_radio_button :contract_type, :permanent, link_errors: true

= f.govuk_radio_button :contract_type, :fixed_term do
= f.govuk_radio_buttons_fieldset :is_parental_leave_cover, inline: true, legend: { text: "Is this covering maternity or paternity leave?" } do
= f.govuk_radio_button :is_parental_leave_cover, :true, label: { text: "Yes" }
= f.govuk_radio_button :is_parental_leave_cover, :false, label: { text: "No" }
= f.govuk_text_field :fixed_term_contract_duration, label: { size: "s" }

= f.govuk_radio_button :contract_type, :parental_leave_cover do
= f.govuk_text_field :parental_leave_cover_contract_duration, label: { size: "s" }


= f.govuk_radio_button :contract_type, :casual
= render "publishers/vacancies/vacancy_form_partials/submit", f: f
4 changes: 3 additions & 1 deletion config/locales/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,13 @@ en:
true: "Yes"
publishers_job_listing_contract_type_form:
contract_type_options:
fixed_term: Fixed term
fixed_term: Fixed term (including maternity or parental leave cover)
parental_leave_cover: Maternity or parental leave cover
permanent: Permanent
casual: Casual
fixed_term_contract_duration: Length of contract
parental_leave_cover_contract_duration: Length of contract
is_parental_leave_cover: Is this covering maternity or paternal leave?
publishers_job_listing_contact_details_form:
contact_email_options:
other: Another email address
Expand Down
4 changes: 4 additions & 0 deletions config/locales/publishers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ en:
step_title: Subjects
contract_type:
step_title: Contract type
fixed_term: Fixed term
parental_leave: Maternity or parental leave cover
permanent: Permanent
casual: Casual
page_title:
create: Create job listing - [Section %{section_number} of 4] - Teaching Vacancies - GOV.UK
edit: Change job listing - [Section %{section_number} of 4] - Teaching Vacancies - GOV.UK
Expand Down
39 changes: 13 additions & 26 deletions spec/presenters/vacancy_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,15 @@
let(:vacancy) do
build_stubbed(:vacancy, contract_type: contract_type,
fixed_term_contract_duration: fixed_term_contract_duration,
parental_leave_cover_contract_duration: parental_leave_cover_contract_duration)
parental_leave_cover_contract_duration: parental_leave_cover_contract_duration,
is_parental_leave_cover: is_parental_leave_cover)
end
let(:parental_leave_cover_contract_duration) { "" }

context "when permanent" do
let(:contract_type) { :permanent }
let(:fixed_term_contract_duration) { "" }
let(:is_parental_leave_cover) { nil }

it "returns Permanent" do
expect(subject.contract_type_with_duration).to eq "Permanent"
Expand All @@ -217,35 +219,20 @@
let(:contract_type) { :fixed_term }
let(:fixed_term_contract_duration) { "6 months" }

it "returns Fixed term (duration)" do
expect(subject.contract_type_with_duration).to eq "Fixed term - 6 months"
end
end
end
context "when is_parental_leave_cover is false" do
let(:is_parental_leave_cover) { false }

describe "#parental_leave_cover_contract_duration" do
let(:vacancy) do
build_stubbed(:vacancy, contract_type: contract_type,
parental_leave_cover_contract_duration: parental_leave_cover_contract_duration,
fixed_term_contract_duration: fixed_term_contract_duration)
end
let(:fixed_term_contract_duration) { "" }

context "when permanent" do
let(:contract_type) { :permanent }
let(:parental_leave_cover_contract_duration) { "" }

it "returns Permanent" do
expect(subject.contract_type_with_duration).to eq "Permanent"
it "returns Fixed term (duration)" do
expect(subject.contract_type_with_duration).to eq "Fixed term - 6 months"
end
end
end

context "when parental_leave cover" do
let(:contract_type) { :parental_leave_cover }
let(:parental_leave_cover_contract_duration) { "6 months" }
context "when is_parental_leave_cover is true" do
let(:is_parental_leave_cover) { true }

it "returns Maternity or parental leave cover (duration)" do
expect(subject.contract_type_with_duration).to eq "Maternity or parental leave cover - 6 months"
it "returns Fixed term (duration)" do
expect(subject.contract_type_with_duration).to eq "Fixed term - 6 months - Maternity or parental leave cover"
end
end
end
end
Expand Down
8 changes: 7 additions & 1 deletion spec/support/vacancy_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ def fill_in_subjects_form_fields(vacancy)
end

def fill_in_contract_type_form_fields(vacancy)
choose I18n.t("helpers.label.publishers_job_listing_contract_type_form.contract_type_options.#{vacancy.contract_type}")
if vacancy.contract_type == "fixed_term"
choose I18n.t("helpers.label.publishers_job_listing_contract_type_form.contract_type_options.fixed_term")
choose "Yes"
fill_in "Length of contract", with: "1 month"
else
choose I18n.t("helpers.label.publishers_job_listing_contract_type_form.contract_type_options.#{vacancy.contract_type}")
end
end

def fill_in_working_patterns_form_fields(vacancy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:school_group) { create(:local_authority, schools: [school1, school2], safeguarding_information: nil) }
let(:school1) { create(:school, :not_applicable, name: "First school") }
let(:school2) { create(:school, :not_applicable, name: "Second school") }
let(:vacancy) { build(:vacancy, :no_tv_applications, :ect_suitable, job_roles: ["teacher"], phases: %w[secondary], organisations: [school1, school2]) }
let(:vacancy) { build(:vacancy, :no_tv_applications, :ect_suitable, job_roles: ["teacher"], phases: %w[secondary], organisations: [school1, school2], contract_type: "fixed_term", is_parental_leave_cover: true) }
let(:created_vacancy) { Vacancy.last }

before do
Expand Down

0 comments on commit 612fd47

Please sign in to comment.