Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove factory bot from production #7150

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/components/job_application_review_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class JobApplicationReviewComponent < ReviewComponent
)
end)

attr_reader :job_application

def initialize(job_application, step_process:, allow_edit: nil, classes: [], html_attributes: {}, **)
super(
classes: classes,
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/publishers/vacancies/build_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Publishers::Vacancies::BuildController < Publishers::Vacancies::BaseContro
:pay_package, :important_dates, :start_date, :applying_for_the_job, :how_to_receive_applications, :application_link,
:application_form, :school_visits, :visa_sponsorship, :contact_details, :about_the_role, :include_additional_documents, :documents

helper_method :form, :job_application_sample
helper_method :form

before_action :strip_checkbox_params, only: %i[update]
before_action :set_school_options
Expand All @@ -21,10 +21,6 @@ def show
render_wizard
end

def job_application_sample
@job_application_sample ||= FactoryBot.build(:job_application, :job_application_sample)
end

def update
if form.valid?
update_vacancy
Expand Down
111 changes: 105 additions & 6 deletions app/helpers/job_applications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ def job_application_qualified_teacher_status_info(job_application)
end

def job_application_jobseeker_profile_info(job_application)
profile = job_application&.jobseeker&.jobseeker_profile
if profile&.has_teacher_reference_number == "yes"
profile.teacher_reference_number
else
"None"
end
job_application.teacher_reference_number.presence || "None"
end

def job_application_support_needed_info(job_application)
Expand Down Expand Up @@ -152,4 +147,108 @@ def radio_button_legend_hint
}
end
end

# These are only used to generate example data
POSSIBLE_DEGREE_GRADES = %w[2.1 2.2 Honours].freeze
POSSIBLE_OTHER_GRADES = %w[Pass Merit Distinction].freeze

def job_application_sample(vacancy) # rubocop: disable Metrics/MethodLength, Metrics/AbcSize
JobApplication.new(
first_name: "Jane",
last_name: "Smith",
national_insurance_number: "QQ 12 34 56 C",
previous_names: "Churchill",
street_address: "1 House Street",
city: "Townington",
postcode: "AB1 2CD",
country: "England",
phone_number: "07123456789",
teacher_reference_number: "1234567",
qualified_teacher_status: "yes",
statutory_induction_complete: "yes",
right_to_work_in_uk: "yes",
safeguarding_issue: "yes",
safeguarding_issue_details: Faker::Lorem.paragraph(sentence_count: 1),
qualified_teacher_status_year: "2021",
email_address: "[email protected]",
support_needed: "yes",
support_needed_details: "I require a wheelchair accessible room for an interview",
close_relationships: "yes",
close_relationships_details: "Brother-in-law works at the trust",
personal_statement:
"As an English teacher, I am extremely passionate about instilling a love of reading and the written word into young people. I have been interested in a position at your school for a number of years and was thrilled to see this opportunity. I received my QTS in 2019, and have since worked as an English teacher in a secondary school in Sheffield.<br />
In the classroom, I always strive to modify my approach to suit a range of abilities and motivation. By planning lessons around my students’ interests, I have been able to inspire even the most unmotivated readers into a love of books. For example, teaching descriptive writing by looking at their favourite sports and persuasive writing via marketing materials for their favourite shops. Furthermore, I have worked with dozens of students for whom English is their second language and nothing motivates me more than seeing that lightbulb moment happen when they can see their own progress. Last year, 95% of my GCSE students passed with grade 5 or above, and I have a proven track record for ensuring all of my KS3 students improve by at least two grades over years 7 to 9.<br />
Moreover, I believe that good teaching doesn’t just happen in the classroom. I am a strong advocate for student wellbeing and pastoral support and have greatly enjoyed leading a morning form class for the last three years. Also, in my current school I have contributed to the English department by running a weekly book club, and organising several school trips to literary locations such as Haworth and Stratford Upon Avon, as well as visits to see plays on the curriculum.<br />
I really resonate with your school’s ethos around inclusion and leaving no student behind, and I hope to be an asset to your English department, while continuing to grow as a teacher.",
employment_history_section_completed: true,
employments:
[
Employment.new(
organisation: "Townington Secondary School",
job_title: "KS3 Teaching Assistant",
main_duties: "Pastoral support for students. Managing student behaviour. Monitored students’ progress and gave feedback to teachers.",
reason_for_leaving: "Moving out of the area",
subjects: Faker::Educator.subject,
started_on: Faker::Date.in_date_period(year: 2016),
current_role: "no",
ended_on: Faker::Date.in_date_period(year: 2018),
),
Employment.new(
organisation: "Sheffield Secondary School",
job_title: "English Teacher",
main_duties: "Planning and delivering English Literature and Language lessons ro a range of abilities across KS3 and GCSE to prepare them for exams. Contributing to the English department via extra curricular activities, organising trips, and running a reading club.",
reason_for_leaving: "No opportunities for career advancement",
subjects: Faker::Educator.subject,
started_on: Faker::Date.in_date_period(year: 2016),
current_role: "no",
ended_on: Faker::Date.in_date_period(year: 2018),
),
],
references:
[
Reference.new(name: "Laura Davison",
organisation: "Townington Secondary School",
relationship: "Line manager",
email: "[email protected]",
job_title: %w[Headteacher Teacher].sample),
Reference.new(name: "John Thompson",
organisation: "Sheffield Secondary School",
relationship: "Line manager",
email: "[email protected]",
job_title: %w[Headteacher Teacher].sample),
],
qualifications:
[
Qualification.new(category: :undergraduate,
institution: Faker::Educator.university,
year: 2016,
subject: "BA English Literature",
grade: "2.1"),
Qualification.new(category: :other, institution: Faker::Educator.university, year: 2019, subject: "PGCE English with QTS"),
Qualification.new(category: :a_level, institution: Faker::Educator.secondary_school, year: 2012, qualification_results: [
QualificationResult.new(subject: "English Literature", grade: "A"),
QualificationResult.new(subject: "History", grade: "B"),
QualificationResult.new(subject: "French", grade: "A"),
]),
Qualification.new(category: :gcse, institution: Faker::Educator.secondary_school, year: 2010, qualification_results: [
QualificationResult.new(subject: "Maths", grade: "A"),
QualificationResult.new(subject: "English Literature", grade: "A"),
QualificationResult.new(subject: "English Language", grade: "B"),
QualificationResult.new(subject: "History", grade: "C"),
QualificationResult.new(subject: "French", grade: "A"),
QualificationResult.new(subject: "Music", grade: "B"),
QualificationResult.new(subject: "Geography", grade: "C"),
]),
].map do |qual|
qual.tap do |q|
q.finished_studying = (q.undergraduate? || q.postgraduate? || q.other? ? Faker::Boolean.boolean : nil)
q.finished_studying_details = (q.finished_studying == false ? "Stopped due to illness" : "")
if q.finished_studying?
q.grade = q.undergraduate? || q.postgraduate? ? POSSIBLE_DEGREE_GRADES.sample : POSSIBLE_OTHER_GRADES.sample
end
end
end,
vacancy: vacancy,
)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
p.govuk-body = t(".reason_for_our_form")

= govuk_details(summary_text: "See what an application form looks like") do
= job_application_review(job_application_sample, step_process: {}, show_tracks: false, show_sidebar: false, allow_edit: false) do |r|
- render "jobseekers/job_applications/job_application_review_sections", r: r, job_application: job_application_sample
= job_application_review(job_application_sample(vacancy), step_process: {}, show_tracks: false, show_sidebar: false, allow_edit: false) do |r|
- render "jobseekers/job_applications/job_application_review_sections", r: r, job_application: r.job_application

- if vacancy.listed?
= f.hidden_field :enable_job_applications
Expand Down
14 changes: 0 additions & 14 deletions spec/factories/employments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@
job_application
end

trait :employment1 do
organisation { "Townington Secondary School" }
job_title { "KS3 Teaching Assistant" }
main_duties { "Pastoral support for students. Managing student behaviour. Monitored students’ progress and gave feedback to teachers." }
reason_for_leaving { "Moving out of the area" }
end

trait :employment2 do
organisation { "English Teacher" }
job_title { "Sheffield Secondary School" }
main_duties { "Planning and delivering English Literature and Language lessons ro a range of abilities across KS3 and GCSE to prepare them for exams. Contributing to the English department via extra curricular activities, organising trips, and running a reading club." }
reason_for_leaving { "No opportunities for career advancement" }
end

trait :jobseeker_profile_employment do
job_application { nil }

Expand Down
51 changes: 0 additions & 51 deletions spec/factories/job_applications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,55 +192,4 @@

status { :withdrawn }
end

trait :job_application_sample do
first_name { "Jane" }
last_name { "Smith" }
previous_names { "Churchill" }
street_address { "1 House Street" }
city { "Townington" }
postcode { "AB1 2CD" }
country { "England" }
phone_number { "07123456789" }
teacher_reference_number { "123456" }
qualified_teacher_status { "yes" }
qualified_teacher_status_year { "2021" }
email_address { "[email protected]" }
support_needed { "yes" }
support_needed_details { "I require a wheelchair accessible room for an interview" }
close_relationships { "yes" }
close_relationships_details { "Brother-in-law works at the trust" }

personal_statement do
"As an English teacher, I am extremely passionate about instilling a love of reading and the written word into young people. I have been interested in a position at your school for a number of years and was thrilled to see this opportunity. I received my QTS in 2019, and have since worked as an English teacher in a secondary school in Sheffield.<br />
In the classroom, I always strive to modify my approach to suit a range of abilities and motivation. By planning lessons around my students’ interests, I have been able to inspire even the most unmotivated readers into a love of books. For example, teaching descriptive writing by looking at their favourite sports and persuasive writing via marketing materials for their favourite shops. Furthermore, I have worked with dozens of students for whom English is their second language and nothing motivates me more than seeing that lightbulb moment happen when they can see their own progress. Last year, 95% of my GCSE students passed with grade 5 or above, and I have a proven track record for ensuring all of my KS3 students improve by at least two grades over years 7 to 9.<br />
Moreover, I believe that good teaching doesn’t just happen in the classroom. I am a strong advocate for student wellbeing and pastoral support and have greatly enjoyed leading a morning form class for the last three years. Also, in my current school I have contributed to the English department by running a weekly book club, and organising several school trips to literary locations such as Haworth and Stratford Upon Avon, as well as visits to see plays on the curriculum.<br />
I really resonate with your school’s ethos around inclusion and leaving no student behind, and I hope to be an asset to your English department, while continuing to grow as a teacher."
end

employment_history_section_completed { true }

employments do
[
association(:employment, :employment1),
association(:employment, :employment2),
]
end

references do
[
association(:reference, :reference1),
association(:reference, :reference2),
]
end

qualifications do
[
association(:qualification, :category_undergraduate),
association(:qualification, :category_other),
association(:qualification, :category_a_level),
association(:qualification, :category_gcse),
]
end
end
end
50 changes: 0 additions & 50 deletions spec/factories/qualification_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,5 @@

subject { Faker::Educator.subject }
grade { factory_sample(%w[A B C D E F]) }

trait :category_gcse_sample1 do
subject { "Maths" }
grade { "A" }
end

trait :category_gcse_sample2 do
subject { "English Literature" }
grade { "A" }
end

trait :category_gcse_sample3 do
subject { "English Language" }
grade { "B" }
end

trait :category_gcse_sample4 do
subject { "History" }
grade { "C" }
end

trait :category_gcse_sample5 do
subject { "French" }
grade { "A" }
end

trait :category_gcse_sample6 do
subject { "Music" }
grade { "B" }
end

trait :category_gcse_sample7 do
subject { "Geography" }
grade { "C" }
end

trait :category_alevel_sample1 do
subject { "English Literature" }
grade { "A" }
end

trait :category_alevel_sample2 do
subject { "History" }
grade { "B" }
end

trait :category_alevel_sample3 do
subject { "French" }
grade { "A" }
end
end
end
45 changes: 0 additions & 45 deletions spec/factories/qualifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,4 @@

job_application
end

trait :category_undergraduate do
results_count { 1 }
category { 4 }
year { 2016 }
subject { "BA English Literature " }
grade { "2.1" }
end

trait :category_other do
results_count { 1 }
category { 6 }
year { 2019 }
subject { "PGCE English with QTS " }
end

trait :category_a_level do
category { 2 }
year { 2012 }

qualification_results do
[
association(:qualification_result, :category_alevel_sample1),
association(:qualification_result, :category_alevel_sample2),
association(:qualification_result, :category_alevel_sample3),
]
end
end

trait :category_gcse do
category { 0 }
year { 2010 }

qualification_results do
[
association(:qualification_result, :category_gcse_sample1),
association(:qualification_result, :category_gcse_sample2),
association(:qualification_result, :category_gcse_sample3),
association(:qualification_result, :category_gcse_sample4),
association(:qualification_result, :category_gcse_sample5),
association(:qualification_result, :category_gcse_sample6),
association(:qualification_result, :category_gcse_sample7),
]
end
end
end
14 changes: 0 additions & 14 deletions spec/factories/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,4 @@

job_application
end

trait :reference1 do
name { "Laura Davison" }
organisation { "Townington Secondary School" }
relationship { "Line manager" }
email { "[email protected]" }
end

trait :reference2 do
name { "John Thompson" }
organisation { "Sheffield Secondary School" }
relationship { "Line manager" }
email { "[email protected]" }
end
end