Skip to content

Commit

Permalink
Remove shim
Browse files Browse the repository at this point in the history
Now now form are writing to the journey session we can remove the shim
classes
  • Loading branch information
rjlynch committed Jun 13, 2024
1 parent c78098c commit 7291f39
Show file tree
Hide file tree
Showing 26 changed files with 77 additions and 324 deletions.
9 changes: 1 addition & 8 deletions app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ def claim_in_progress?
end

def claim_ineligible?
journey::EligibilityChecker.new(journey_session: shim).ineligible?
end

def shim
@shim ||= journey::ClaimJourneySessionShim.new(
current_claim: current_claim,
journey_session: journey_session
)
journey::EligibilityChecker.new(journey_session: journey_session).ineligible?
end

def page_sequence
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/concerns/journey_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def find_journey_session
end

def create_journey_session!
journey::Session.create!(journey: params[:journey])
journey::Session.create!(
journey: params[:journey],
answers: {
academic_year: journey_configuration.current_academic_year
}
)
end

def journey_session_key
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ class SubmissionsController < BasePublicController
skip_before_action :send_unstarted_claimants_to_the_start, only: [:show]

def create
shim = journey::ClaimJourneySessionShim.new(
current_claim: current_claim,
journey_session: journey_session
)

@form = journey::ClaimSubmissionForm.new(journey_session: shim)
@form = journey::ClaimSubmissionForm.new(journey_session: journey_session)

if @form.save
current_claim.claims.each(&:destroy!)
Expand Down
7 changes: 1 addition & 6 deletions app/forms/claim_submission_base_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ def set_eligibility_attributes(eligibility)
end

def set_attributes_for_claim_submission
# Temp conditional while we're working with the shim
claim.journey_session = if journey_session.is_a?(ClaimJourneySessionShim)
journey_session.journey_session
else
journey_session
end
claim.journey_session = journey_session
claim.policy_options_provided = generate_policy_options_provided
claim.reference = generate_reference
claim.submitted_at = Time.zone.now
Expand Down
10 changes: 0 additions & 10 deletions app/forms/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ def persisted?
true
end

# NOTE RL: temporary method while migrating away from current claim for when
# we need to check against either answers or the claim for some information
# Will be removed once the migration is complete and we delete the shim
def shim
@shim ||= Journeys::AdditionalPaymentsForTeaching::ClaimJourneySessionShim.new(
current_claim: claim,
journey_session: journey_session
)
end

private

def permitted_attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def policies_eligible_now_and_sorted
end

def award_amount(policy)
policy::PolicyEligibilityChecker.new(answers: shim.answers).calculate_award_amount
policy::PolicyEligibilityChecker.new(answers: answers).calculate_award_amount
end

def selected_policy?(policy)
Expand All @@ -47,7 +47,7 @@ def allowed_policy_names
end

def eligibility_checker
@eligibility_checker ||= EligibilityChecker.new(journey_session: shim)
@eligibility_checker ||= EligibilityChecker.new(journey_session: journey_session)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def chemistry_or_physics_available?

def subject_symbols
@subject_symbols ||=
JourneySubjectEligibilityChecker.selectable_subject_symbols(shim.answers)
JourneySubjectEligibilityChecker.selectable_subject_symbols(answers)
end

def save
Expand Down
90 changes: 0 additions & 90 deletions app/models/claim_journey_session_shim.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def ecp_only_school?
!Policies::LevellingUpPremiumPayments::SchoolEligibility.new(current_school).eligible?
end

def calculate_award_amount
def calculate_award_amount(debug = false)
return 0 if eligible_itt_subject.blank?

args = {policy_year: claim_year, itt_year: itt_academic_year, subject_symbol: eligible_itt_subject.to_sym, school: current_school}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,16 @@ def set_by_teacher_id?(field)
answers.teacher_id_user_info[field].present?
end

def shim
@shim ||= Journeys::AdditionalPaymentsForTeaching::ClaimJourneySessionShim.new(
current_claim: claim,
journey_session: journey_session
)
end

def overall_eligibility_status
@overall_eligibility_status ||= EligibilityChecker.new(journey_session: shim).status
@overall_eligibility_status ||= EligibilityChecker.new(journey_session: journey_session).status
end

def ecp_eligibility_checker
@ecp_eligibility_checker ||= Policies::EarlyCareerPayments::PolicyEligibilityChecker.new(answers: shim.answers)
@ecp_eligibility_checker ||= Policies::EarlyCareerPayments::PolicyEligibilityChecker.new(answers: answers)
end

def lup_eligibility_checker
@lup_eligibility_checker ||= Policies::LevellingUpPremiumPayments::PolicyEligibilityChecker.new(answers: shim.answers)
@lup_eligibility_checker ||= Policies::LevellingUpPremiumPayments::PolicyEligibilityChecker.new(answers: answers)
end
end
end
Expand Down
11 changes: 2 additions & 9 deletions app/models/journeys/page_sequence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,11 @@ def journey
end

def claim_submittable?
journey::ClaimSubmissionForm.new(journey_session: shim).valid?
end

def shim
@shim ||= journey::ClaimJourneySessionShim.new(
current_claim: @claim,
journey_session: @journey_session
)
journey::ClaimSubmissionForm.new(journey_session: @journey_session).valid?
end

def journey_ineligible?
@journey_ineligible ||= journey::EligibilityChecker.new(journey_session: shim).ineligible?
@journey_ineligible ||= journey::EligibilityChecker.new(journey_session: @journey_session).ineligible?
end
end
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,7 @@ def ineligible?
end

def eligibility_checker
@eligibility_checker ||= Policies::StudentLoans::PolicyEligibilityChecker.new(answers: shim.answers)
end

def shim
@shim ||= ClaimJourneySessionShim.new(
current_claim: claim,
journey_session: journey_session
)
@eligibility_checker ||= Policies::StudentLoans::PolicyEligibilityChecker.new(answers: answers)
end

def signed_in_with_dfe_identity_and_details_match?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% content_for(
:page_title,
page_title(
eligible_itt_subject_translation(@form.shim.answers, @form.subject_symbols),
eligible_itt_subject_translation(@form.answers, @form.subject_symbols),
journey: current_journey_routing_name,
show_error: @form.errors.any?
)
Expand Down Expand Up @@ -29,7 +29,7 @@

<legend class="govuk-fieldset__legend <%= fieldset_legend_css_class_for_journey(f.object.journey) %>">
<h1 class="govuk-fieldset__heading">
<%= eligible_itt_subject_translation(f.object.shim.answers, f.object.subject_symbols) %>
<%= eligible_itt_subject_translation(f.object.answers, f.object.subject_symbols) %>
</h1>
</legend>

Expand Down
7 changes: 1 addition & 6 deletions app/views/additional_payments/claims/ineligible.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<% require "./lib/ineligibility_reason_checker.rb" %>
<% reason = IneligibilityReasonChecker.new(
Journeys::AdditionalPaymentsForTeaching::ClaimJourneySessionShim.new(
current_claim: current_claim,
journey_session: journey_session
).answers
).reason %>
<% reason = IneligibilityReasonChecker.new(journey_session.answers).reason %>
<% title_and_h1_content = reason == :current_school ? I18n.t("additional_payments.ineligible.school_heading") : I18n.t("additional_payments.ineligible.heading") %>
<% content_for(:page_title, page_title(title_and_h1_content, journey: current_journey_routing_name)) %>

Expand Down
Loading

0 comments on commit 7291f39

Please sign in to comment.