Skip to content

Commit

Permalink
Move additional payments journey specific reminder code to journey mo…
Browse files Browse the repository at this point in the history
…dule (#3173)
  • Loading branch information
slorek authored Sep 10, 2024
1 parent 5f2aa7e commit 677cf17
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 126 deletions.
7 changes: 0 additions & 7 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,6 @@ def dqt_teacher_record
policy::DqtRecord.new(Dqt::Teacher.new(dqt_teacher_status), eligibility) if has_dqt_record?
end

def set_a_reminder?
Reminder.set_a_reminder?(
policy_year: Journeys.for_policy(policy).configuration.current_academic_year,
itt_academic_year: eligibility.itt_academic_year
)
end

def same_claimant?(other_claim)
CLAIMANT_MATCHING_ATTRIBUTES.all? do |attr|
public_send(attr) == other_claim.public_send(attr)
Expand Down
8 changes: 8 additions & 0 deletions app/models/journeys/additional_payments_for_teaching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ module AdditionalPaymentsForTeaching
"email-verification" => Reminders::EmailVerificationForm
}
}.freeze

def set_a_reminder?(itt_academic_year:, policy_year: configuration.current_academic_year)
return false if policy_year >= EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR

next_year = policy_year + 1
eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year)
eligible_itt_years.include?(itt_academic_year)
end
end
end
8 changes: 0 additions & 8 deletions app/models/reminder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ class Reminder < ApplicationRecord
scope :inside_academic_year, -> { where(itt_academic_year: AcademicYear.current.to_s) }
scope :to_be_sent, -> { email_verified.not_yet_sent.inside_academic_year }

def self.set_a_reminder?(policy_year:, itt_academic_year:)
return false if policy_year >= EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR

next_year = policy_year + 1
eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year)
eligible_itt_years.include?(itt_academic_year)
end

def send_year
itt_academic_year.start_year
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/additional_payments/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<%= render partial: "submissions/confirmation" %>

<% if submitted_claim.set_a_reminder? %>
<% if journey.set_a_reminder?(itt_academic_year: submitted_claim.eligibility.itt_academic_year) %>
<%= render partial: "submissions/reminder" %>
<% end %>

Expand Down
110 changes: 110 additions & 0 deletions spec/models/journeys/additional_payments_for_teaching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,114 @@

it { is_expected.to eq(Journeys::AdditionalPaymentsForTeaching::AnswersPresenter) }
end

describe ".set_a_reminder?" do
subject { described_class.set_a_reminder?(itt_academic_year: itt_academic_year, policy_year: policy_year) }
let(:itt_academic_year) { AcademicYear.new(year) }

context "Claim year: 22/23" do
let(:policy_year) { AcademicYear.new(2022) }

# Eligible now - but falls out of 5 year window next year so don't set a reminder
context "ITT year: 17/18" do
let(:year) { 2017 }

specify { expect(subject).to be false }
end

context "ITT year: 18/19" do
let(:year) { 2018 }

specify { expect(subject).to be true }
end

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be true }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be true }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be true }
end
end

context "Claim year: 23/24" do
let(:policy_year) { AcademicYear.new(2023) }

# Eligible now - but falls out of 5 year window next year so don't set a reminder
context "ITT year: 18/19" do
let(:year) { 2018 }

specify { expect(subject).to be false }
end

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be true }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be true }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be true }
end

context "ITT year: 22/23" do
let(:year) { 2022 }

specify { expect(subject).to be true }
end
end

# Last policy year - no reminders to set
context "Claim year: 24/25" do
let(:policy_year) { AcademicYear.new(2024) }

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be false }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be false }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be false }
end

context "ITT year: 22/23" do
let(:year) { 2022 }

specify { expect(subject).to be false }
end

context "ITT year: 23/24" do
let(:year) { 2023 }

specify { expect(subject).to be false }
end
end
end
end
110 changes: 0 additions & 110 deletions spec/models/reminder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,114 +46,4 @@
end
end
end

describe ".set_a_reminder?" do
subject { Reminder.set_a_reminder?(policy_year: policy_year, itt_academic_year: itt_academic_year) }
let(:itt_academic_year) { AcademicYear.new(year) }

context "Claim year: 22/23" do
let(:policy_year) { AcademicYear.new(2022) }

# Eligible now - but falls out of 5 year window next year so don't set a reminder
context "ITT year: 17/18" do
let(:year) { 2017 }

specify { expect(subject).to be false }
end

context "ITT year: 18/19" do
let(:year) { 2018 }

specify { expect(subject).to be true }
end

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be true }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be true }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be true }
end
end

context "Claim year: 23/24" do
let(:policy_year) { AcademicYear.new(2023) }

# Eligible now - but falls out of 5 year window next year so don't set a reminder
context "ITT year: 18/19" do
let(:year) { 2018 }

specify { expect(subject).to be false }
end

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be true }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be true }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be true }
end

context "ITT year: 22/23" do
let(:year) { 2022 }

specify { expect(subject).to be true }
end
end

# Last policy year - no reminders to set
context "Claim year: 24/25" do
let(:policy_year) { AcademicYear.new(2024) }

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be false }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be false }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be false }
end

context "ITT year: 22/23" do
let(:year) { 2022 }

specify { expect(subject).to be false }
end

context "ITT year: 23/24" do
let(:year) { 2023 }

specify { expect(subject).to be false }
end
end
end
end

0 comments on commit 677cf17

Please sign in to comment.