Skip to content

Commit

Permalink
wip ci run
Browse files Browse the repository at this point in the history
  • Loading branch information
rjlynch committed Dec 5, 2024
1 parent 0b0f70c commit e7c8c7f
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/models/concerns/eligibility_checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def trainee_teacher?

def common_ineligible_attributes?
[
policy_closed?,
indicated_ineligible_school?,
supply_teacher_lacking_either_long_contract_or_direct_employment?,
poor_performance?,
Expand All @@ -59,6 +60,10 @@ def common_ineligible_attributes?
].any?
end

def policy_closed?
policy.closed?(claim_year)
end

def indicated_ineligible_school?
current_school.present? && !policy::SchoolEligibility.new(current_school).eligible?
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/policies/early_career_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,9 @@ def future_years(year)
def selectable_itt_years_for_claim_year(claim_year)
(AcademicYear.new(claim_year - 5)...AcademicYear.new(claim_year)).to_a
end

def closed?(claim_year)
claim_year > POLICY_END_YEAR
end
end
end
2 changes: 1 addition & 1 deletion app/models/policies/early_career_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def policy
hsh[year] = AcademicYear::Type.new.serialize(year)
end.merge({AcademicYear.new => AcademicYear::Type.new.serialize(AcademicYear.new)})

enum :itt_academic_year, ITT_ACADEMIC_YEARS
enum :itt_academic_year, ITT_ACADEMIC_YEARS, validate: true

enum :qualification, {
postgraduate_itt: 0,
Expand Down
4 changes: 4 additions & 0 deletions app/models/policies/levelling_up_premium_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,9 @@ def future_years(year)
def selectable_itt_years_for_claim_year(claim_year)
(AcademicYear.new(claim_year - 5)...AcademicYear.new(claim_year)).to_a
end

def closed?(claim_year)
claim_year > POLICY_END_YEAR
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<p class="govuk-body">
You are not eligible for the
<%= link_to("early-career payment (opens in new tab)", Policies::EarlyCareerPayments.eligibility_criteria_url, class: "govuk-link", target: "_blank") %>
because the policy has now closed.
</p>
<p class="govuk-body">
You are not eligible for the
<%= link_to("#{I18n.t("levelling_up_premium_payments.policy_short_name").downcase} (opens in new tab)", Policies::LevellingUpPremiumPayments.eligibility_criteria_url, class: "govuk-link", target: "_blank") %>
because the school you teach in is not eligible. <%= I18n.t("levelling_up_premium_payments.policy_short_name").capitalize.pluralize %> are offered in schools identified as having a higher need for teachers.
</p>

<p class="govuk-body">
For more information, check the eligibility criteria for
<%= link_to("early-career payments", Policies::EarlyCareerPayments.eligibility_criteria_url, class: "govuk-link") %>
and
<%= link_to(I18n.t("levelling_up_premium_payments.policy_short_name").downcase.pluralize, Policies::LevellingUpPremiumPayments.eligibility_criteria_url, class: "govuk-link") %>.
</p>
6 changes: 5 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2024_11_26_105650) do
ActiveRecord::Schema[8.0].define(version: 2024_11_29_103823) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_catalog.plpgsql"
Expand Down Expand Up @@ -113,7 +113,11 @@
t.date "onelogin_idv_date_of_birth"
t.datetime "started_at", precision: nil, null: false
t.datetime "verified_at"
t.index "lower((email_address)::text)", name: "index_claims_on_lower_email_address"
t.index "lower((first_name)::text), lower((surname)::text), date_of_birth", name: "index_claims_on_personal_details"
t.index "lower((national_insurance_number)::text)", name: "index_claims_on_lower_national_insurance_number"
t.index ["academic_year"], name: "index_claims_on_academic_year"
t.index ["bank_account_number", "bank_sort_code"], name: "index_claims_on_bank_details"
t.index ["created_at"], name: "index_claims_on_created_at"
t.index ["eligibility_type", "eligibility_id"], name: "index_claims_on_eligibility_type_and_eligibility_id"
t.index ["held"], name: "index_claims_on_held"
Expand Down
13 changes: 12 additions & 1 deletion lib/ineligibility_reason_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ def initialize(answers)
end

def reason
if current_school?
if ecp_only_and_ecp_closed?
:ecp_only_ecp_closed
elsif current_school?
:current_school
elsif dqt_data_ineligible?
:dqt_data_ineligible
Expand Down Expand Up @@ -41,6 +43,15 @@ def reason

private

def ecp_only_and_ecp_closed?
school = @answers.current_school

[
Policies::EarlyCareerPayments::SchoolEligibility.new(school).eligible?,
!Policies::LevellingUpPremiumPayments::SchoolEligibility.new(school).eligible?
].all? && Policies::EarlyCareerPayments.closed?(@answers.policy_year)
end

def current_school?
school = @answers.current_school

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
factory :early_career_payments_eligibility, class: "Policies::EarlyCareerPayments::Eligibility" do
award_amount { 5000.0 }

itt_academic_year do
Journeys.for_policy(Policies::EarlyCareerPayments).configuration.current_academic_year - 3
end

trait :eligible do
teacher_reference_number { generate(:teacher_reference_number) }
eligible_now
Expand Down
86 changes: 84 additions & 2 deletions spec/features/combined_teacher_claim_journey_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
end
let(:eligibility) { claim.eligibility }

before { create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2023)) }

scenario "Eligible for both" do
create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2023))

school = create(:school, :combined_journey_eligibile_for_all)

visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME)
Expand Down Expand Up @@ -243,6 +243,8 @@
end

scenario "Eligible for only one" do
create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2023))

school = create(:school, :early_career_payments_uplifted)

visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME)
Expand Down Expand Up @@ -323,4 +325,84 @@
expect(page).not_to have_selector('input[type="radio"]')
expect(page).to have_button("Apply now")
end

context "when ECP is closed" do
before do
create(
:journey_configuration,
:additional_payments,
current_academic_year: AcademicYear.new(2025)
)
end

scenario "choosing an ecp only school is ineligible" do
school = create(:school, :early_career_payments_eligible)

visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME)

click_on "Continue without signing"

choose_school school

expect(page).to have_content "You are not eligible"
expect(page).to have_content "the policy has now closed"
end

scenario "choosing a lup eligible school allows completing the journey" do
school = create(:school, :combined_journey_eligibile_for_all)

visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME)

click_on "Continue without signing"

choose_school school
click_on "Continue"

# - Have you started your first year as a newly qualified teacher?
choose "Yes"
click_on "Continue"

# - Have you completed your induction as an early-career teacher?
choose "Yes"
click_on "Continue"

# - Are you currently employed as a supply teacher
choose "No"
click_on "Continue"

# - Poor performance
within all(".govuk-fieldset")[0] do
choose("No")
end
within all(".govuk-fieldset")[1] do
choose("No")
end
click_on "Continue"

# - What route into teaching did you take?
choose("Undergraduate initial teacher training (ITT)")
click_on "Continue"

# - In which academic year did you complete your undergraduate ITT?
choose("2024 to 2025")
click_on "Continue"

# - Which subject did you do your undergraduate ITT in
choose "Mathematics"
click_on "Continue"

# Do you spend at least half of your contracted hours teaching eligible
# subjects?
choose "Yes"
click_on "Continue"

# Check your answers
click_on "Continue"

expect(page).to have_content("You’re eligible for an additional payment")
expect(page).to have_content(
"you can apply for a school targeted retention incentive"
)
end
end
end

0 comments on commit e7c8c7f

Please sign in to comment.