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

Faith school catholic flow #7222

Open
wants to merge 16 commits into
base: faith-schools-flow
Choose a base branch
from
Open
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: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
63 changes: 6 additions & 57 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had so many. Good trim

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).
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions app/components/job_application_review_component.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
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 == :following_religion
ReligiousInformationSection.new(@job_application,
name: section_name,
allow_edit: @allow_edit)
else
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: {}, **)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class JobApplicationReviewComponent::ReligiousInformationSection < JobApplicationReviewComponent::Section
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
15 changes: 11 additions & 4 deletions app/controllers/jobseekers/job_applications/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions app/controllers/jobseekers/job_applications/build_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ 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

def show
skip_step_if_missing

skip_step if step == :religion_details && !job_application.following_religion

render_wizard
end

Expand All @@ -18,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?
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
Expand Down Expand Up @@ -147,4 +151,8 @@ def update_or_create_jobseeker_profile!
)
end
end

def set_steps
self.steps = step_process.steps - [:review]
end
end
19 changes: 10 additions & 9 deletions app/controllers/jobseekers/job_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +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 = 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)

Expand Down Expand Up @@ -232,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
9 changes: 9 additions & 0 deletions app/form_models/base_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ 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: VALID_DOCUMENT_TYPES,
}.freeze

include ActiveModel::Model
include ActiveModel::Validations::Callbacks

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Jobseekers::JobApplication::FollowingReligionForm < Jobseekers::JobApplication::BaseForm
include ActiveModel::Model
include ActiveModel::Attributes

def self.fields
%i[following_religion]
end
attribute :following_religion, :boolean

validates :following_religion, inclusion: { in: [true, false] }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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_certificate
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" }

validates :baptism_certificate, form_file: DOCUMENT_VALIDATION_OPTIONS, presence: true, if: -> { religious_reference_type == "baptism_certificate" }
end
7 changes: 0 additions & 7 deletions app/form_models/publishers/job_listing/vacancy_form.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions app/models/job_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,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,
Expand All @@ -42,6 +46,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,
Expand All @@ -66,6 +74,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
Expand Down
Loading
Loading