Skip to content

Commit

Permalink
Merge pull request #2850 from DFE-Digital/CAPT-1721/remove-claim-from…
Browse files Browse the repository at this point in the history
…-slug-sequence

CAPT 1721/remove claim from slug sequence
  • Loading branch information
rjlynch authored Jun 14, 2024
2 parents 892ca0e + 463aea4 commit 9bd6816
Show file tree
Hide file tree
Showing 29 changed files with 161 additions and 303 deletions.
2 changes: 0 additions & 2 deletions app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def redirect_to_existing_claim_journey
params[:journey] = new_journey::ROUTING_NAME

new_page_sequence = new_journey.page_sequence_for_claim(
current_claim,
journey_session,
session[:slugs],
params[:slug]
Expand Down Expand Up @@ -101,7 +100,6 @@ def claim_ineligible?

def page_sequence
@page_sequence ||= journey.page_sequence_for_claim(
current_claim,
journey_session,
session[:slugs],
params[:slug]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ class SlugSequence
RESULTS_SLUGS
).freeze

attr_reader :claim, :journey_session
attr_reader :journey_session

delegate :answers, to: :journey_session

# Really this is a combined CurrentClaim
def initialize(claim, journey_session)
@claim = claim
def initialize(journey_session)
@journey_session = journey_session
end

Expand Down Expand Up @@ -178,8 +176,11 @@ def self.start_page_url
private

def personal_details_form
# FIXME RL: forms expect a claim argument even thought they don't use it
# this will be removed as part of no longer creating a claim at the
# start of the journey work
PersonalDetailsForm.new(
claim:,
claim: nil,
journey_session: journey_session,
journey: Journeys::AdditionalPaymentsForTeaching,
params: ActionController::Parameters.new
Expand Down
5 changes: 2 additions & 3 deletions app/models/journeys/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ def forms
defined?(self::FORMS) ? self::FORMS : {}
end

def page_sequence_for_claim(claim, journey_session, completed_slugs, current_slug)
def page_sequence_for_claim(journey_session, completed_slugs, current_slug)
PageSequence.new(
claim,
slug_sequence.new(claim, journey_session),
slug_sequence.new(journey_session),
completed_slugs,
current_slug,
journey_session
Expand Down
7 changes: 3 additions & 4 deletions app/models/journeys/page_sequence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
# Used to model the sequence of pages that make up the claim process.
module Journeys
class PageSequence
attr_reader :claim, :current_slug, :completed_slugs
attr_reader :current_slug, :completed_slugs

DEAD_END_SLUGS = %w[complete existing-session eligible-later future-eligibility ineligible]
OPTIONAL_SLUGS = %w[postcode-search select-home-address reset-claim]

def initialize(claim, slug_sequence, completed_slugs, current_slug, journey_session)
@claim = claim
def initialize(slug_sequence, completed_slugs, current_slug, journey_session)
@current_slug = current_slug
@slug_sequence = slug_sequence
@completed_slugs = completed_slugs
Expand Down Expand Up @@ -75,7 +74,7 @@ def can_skip_next_slug?
end

def lup_policy_and_trainee_teacher_at_lup_school?
Policies::LevellingUpPremiumPayments.in?(claim.policies) && lup_teacher_at_lup_school
journey == Journeys::AdditionalPaymentsForTeaching && lup_teacher_at_lup_school
end

def lup_teacher_at_lup_school
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,17 @@ class SlugSequence
RESULTS_SLUGS
).freeze

attr_reader :claim, :journey_session
attr_reader :journey_session

delegate :answers, to: :journey_session

def initialize(claim, journey_session)
@claim = claim
def initialize(journey_session)
@journey_session = journey_session
end

def slugs
SLUGS.dup.tap do |sequence|
if !Journeys.for_policy(claim.policy).configuration.teacher_id_enabled?
if !Journeys::TeacherStudentLoanReimbursement.configuration.teacher_id_enabled?
sequence.delete("sign-in-or-continue")
sequence.delete("reset-claim")
sequence.delete("qualification-details")
Expand Down Expand Up @@ -134,7 +133,7 @@ def self.start_page_url

def personal_details_form
PersonalDetailsForm.new(
claim:,
claim: nil,
journey_session: journey_session,
journey: Journeys::TeacherStudentLoanReimbursement,
params: ActionController::Parameters.new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def claimant_submits_claim(claim_attributes:, answers:, post_submission_claim_at
claim.save!

jump_to_claim_journey_page(
claim: claim,
slug: "check-your-answers",
journey_session: journey_session
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@
end

context "with a supplied postcode" do
let(:claim) do
Claim.by_policy(Policies::EarlyCareerPayments).order(:created_at).last
end

let(:journey_session) do
Journeys::AdditionalPaymentsForTeaching::Session.order(:created_at).last
end
Expand All @@ -270,9 +266,6 @@
create(:journey_configuration, :additional_payments)
start_early_career_payments_claim

claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible))
claim.save!

journey_session.answers.assign_attributes(
attributes_for(
:additional_payments_answers,
Expand All @@ -287,9 +280,13 @@
end

scenario "with Ordnance Survey API data" do
expect(claim.valid?(:submit)).to eq false
expect(
Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new(
journey_session: journey_session
).valid?
).to eq false

jump_to_claim_journey_page(
claim: claim,
slug: "postcode-search",
journey_session: journey_session
)
Expand Down Expand Up @@ -322,9 +319,12 @@
end

scenario "Claimant cannot find the correct address so chooses to manually enter address" do
expect(claim.valid?(:submit)).to eq false
expect(
Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new(
journey_session: journey_session
).valid?
).to eq false
jump_to_claim_journey_page(
claim: claim,
slug: "postcode-search",
journey_session: journey_session
)
Expand Down Expand Up @@ -368,9 +368,13 @@

# Bugfix - did cause an exception after pressing back
scenario "Claimant cannot find the correct address so chooses to manually enter address, presses back before filling anything to go to the postcode search again" do
expect(claim.valid?(:submit)).to eq false
expect(
Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new(
journey_session: journey_session
).valid?
).to eq false

jump_to_claim_journey_page(
claim: claim,
slug: "postcode-search",
journey_session: journey_session
)
Expand All @@ -396,9 +400,13 @@
end

scenario "Claimant decides they want to change the POSTCODE from the 'select-home-address' screen" do
expect(claim.valid?(:submit)).to eq false
expect(
Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new(
journey_session: journey_session
).valid?
).to eq false

jump_to_claim_journey_page(
claim: claim,
slug: "postcode-search",
journey_session: journey_session
)
Expand Down Expand Up @@ -468,9 +476,13 @@
end

scenario "Ordanance Survery Client raise a ResponseError" do
expect(claim.valid?(:submit)).to eq false
expect(
Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new(
journey_session: journey_session
).valid?
).to eq false

jump_to_claim_journey_page(
claim: claim,
slug: "postcode-search",
journey_session: journey_session
)
Expand Down
Loading

0 comments on commit 9bd6816

Please sign in to comment.