From 43235f9f1b8099cca243c0a8185d35fc5e83691b Mon Sep 17 00:00:00 2001 From: starswan Date: Mon, 7 Oct 2024 12:26:42 +0100 Subject: [PATCH 1/3] Remove FactoryBot from production --- .../job_application_review_component.rb | 2 + .../publishers/vacancies/build_controller.rb | 6 +- app/helpers/job_applications_helper.rb | 104 ++++++++++++++++++ .../review/_professional_status.html.slim | 2 +- .../build/applying_for_the_job.html.slim | 4 +- spec/factories/employments.rb | 14 --- spec/factories/job_applications.rb | 51 --------- spec/factories/qualification_results.rb | 50 --------- spec/factories/qualifications.rb | 45 -------- spec/factories/references.rb | 14 --- 10 files changed, 110 insertions(+), 182 deletions(-) diff --git a/app/components/job_application_review_component.rb b/app/components/job_application_review_component.rb index c4b88a6c1d..d113420c9f 100644 --- a/app/components/job_application_review_component.rb +++ b/app/components/job_application_review_component.rb @@ -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, diff --git a/app/controllers/publishers/vacancies/build_controller.rb b/app/controllers/publishers/vacancies/build_controller.rb index 5eb113a45f..be730bcd25 100644 --- a/app/controllers/publishers/vacancies/build_controller.rb +++ b/app/controllers/publishers/vacancies/build_controller.rb @@ -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 @@ -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 diff --git a/app/helpers/job_applications_helper.rb b/app/helpers/job_applications_helper.rb index 8b8396ebf1..f9c55e3fbb 100644 --- a/app/helpers/job_applications_helper.rb +++ b/app/helpers/job_applications_helper.rb @@ -152,4 +152,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: "jane.smith@gmail.com", + 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.
+ 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.
+ 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.
+ 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: "l.davison@english.townington.ac.uk", + job_title: %w[Headteacher Teacher].sample), + Reference.new(name: "John Thompson", + organisation: "Sheffield Secondary School", + relationship: "Line manager", + email: "john.thompson@english.sheffield.ac.uk", + 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 diff --git a/app/views/jobseekers/job_applications/review/_professional_status.html.slim b/app/views/jobseekers/job_applications/review/_professional_status.html.slim index 8b0e5fdfb3..58d7dcf9af 100644 --- a/app/views/jobseekers/job_applications/review/_professional_status.html.slim +++ b/app/views/jobseekers/job_applications/review/_professional_status.html.slim @@ -5,7 +5,7 @@ - s.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_job_application_personal_details_form.teacher_reference_number_review") - - row.with_value text: job_application_jobseeker_profile_info(job_application) + - row.with_value text: job_application.teacher_reference_number - s.with_row do |row| - row.with_key text: t("helpers.legend.jobseekers_job_application_professional_status_form.statutory_induction_complete") diff --git a/app/views/publishers/vacancies/build/applying_for_the_job.html.slim b/app/views/publishers/vacancies/build/applying_for_the_job.html.slim index 12500ef5f2..8138760aab 100644 --- a/app/views/publishers/vacancies/build/applying_for_the_job.html.slim +++ b/app/views/publishers/vacancies/build/applying_for_the_job.html.slim @@ -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 diff --git a/spec/factories/employments.rb b/spec/factories/employments.rb index ea3e04223f..b2e4e3ef66 100644 --- a/spec/factories/employments.rb +++ b/spec/factories/employments.rb @@ -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 } diff --git a/spec/factories/job_applications.rb b/spec/factories/job_applications.rb index 5773c2f85d..3e7190b74c 100644 --- a/spec/factories/job_applications.rb +++ b/spec/factories/job_applications.rb @@ -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 { "jane.smith@gmail.com" } - 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.
- 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.
- 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.
- 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 diff --git a/spec/factories/qualification_results.rb b/spec/factories/qualification_results.rb index 717a7c5448..99c4e31618 100644 --- a/spec/factories/qualification_results.rb +++ b/spec/factories/qualification_results.rb @@ -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 diff --git a/spec/factories/qualifications.rb b/spec/factories/qualifications.rb index 5a3d497494..fbe2b58394 100644 --- a/spec/factories/qualifications.rb +++ b/spec/factories/qualifications.rb @@ -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 diff --git a/spec/factories/references.rb b/spec/factories/references.rb index 4cef9ad3ff..abef6ad524 100644 --- a/spec/factories/references.rb +++ b/spec/factories/references.rb @@ -10,18 +10,4 @@ job_application end - - trait :reference1 do - name { "Laura Davison" } - organisation { "Townington Secondary School" } - relationship { "Line manager" } - email { "l.davison@english.townington.ac.uk" } - end - - trait :reference2 do - name { "John Thompson" } - organisation { "Sheffield Secondary School" } - relationship { "Line manager" } - email { "john.thompson@english.sheffield.ac.uk" } - end end From 23285afa1801e36e286f6b4d5c3078d05a6b8bd7 Mon Sep 17 00:00:00 2001 From: starswan Date: Thu, 17 Oct 2024 11:20:29 +0100 Subject: [PATCH 2/3] Rework professional status to use job_application TRN rather than possible profile TRN --- app/helpers/job_applications_helper.rb | 5 ++--- .../job_applications/review/_professional_status.html.slim | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/helpers/job_applications_helper.rb b/app/helpers/job_applications_helper.rb index f9c55e3fbb..cbbcaee507 100644 --- a/app/helpers/job_applications_helper.rb +++ b/app/helpers/job_applications_helper.rb @@ -41,9 +41,8 @@ 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 + if job_application.teacher_reference_number.present? + job_application.teacher_reference_number else "None" end diff --git a/app/views/jobseekers/job_applications/review/_professional_status.html.slim b/app/views/jobseekers/job_applications/review/_professional_status.html.slim index 58d7dcf9af..8b0e5fdfb3 100644 --- a/app/views/jobseekers/job_applications/review/_professional_status.html.slim +++ b/app/views/jobseekers/job_applications/review/_professional_status.html.slim @@ -5,7 +5,7 @@ - s.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_job_application_personal_details_form.teacher_reference_number_review") - - row.with_value text: job_application.teacher_reference_number + - row.with_value text: job_application_jobseeker_profile_info(job_application) - s.with_row do |row| - row.with_key text: t("helpers.legend.jobseekers_job_application_professional_status_form.statutory_induction_complete") From 20e5378cf2d6c65ead720b677f236d8ce0d51b37 Mon Sep 17 00:00:00 2001 From: starswan Date: Mon, 2 Dec 2024 10:55:49 +0000 Subject: [PATCH 3/3] linter --- app/helpers/job_applications_helper.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/helpers/job_applications_helper.rb b/app/helpers/job_applications_helper.rb index cbbcaee507..949409dcf1 100644 --- a/app/helpers/job_applications_helper.rb +++ b/app/helpers/job_applications_helper.rb @@ -41,11 +41,7 @@ def job_application_qualified_teacher_status_info(job_application) end def job_application_jobseeker_profile_info(job_application) - if job_application.teacher_reference_number.present? - job_application.teacher_reference_number - else - "None" - end + job_application.teacher_reference_number.presence || "None" end def job_application_support_needed_info(job_application)