Skip to content

Commit

Permalink
EY practitioner find reference requires email
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Sep 26, 2024
1 parent 51f6fff commit 2521d24
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def persist_claim
def check_page_is_in_sequence
unless correct_journey_for_claim_in_progress?
clear_claim_session
return redirect_to new_claim_path
return redirect_to new_claim_path(request.query_parameters)
end

raise ActionController::RoutingError.new("Not Found for #{params[:slug]}") unless page_sequence.in_sequence?(params[:slug])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/form_submittable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def redirect_to_slug(slug)
raise NoMethodError, "End of sequence: you must define #{current_slug.underscore}_after_form_save_success" unless next_slug
raise NoMethodError, "Missing path helper for resource: \"#{path_helper_resource}\"; try overriding it with #path_helper_resource" unless respond_to?(:"#{path_helper_resource}_path")

redirect_to send(:"#{path_helper_resource}_path", current_journey_routing_name, slug)
redirect_to send(:"#{path_helper_resource}_path", current_journey_routing_name, slug, request.query_parameters)
end

def redirect_to_next_slug
Expand Down
1 change: 1 addition & 0 deletions app/forms/current_school_form.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class CurrentSchoolForm < Form
attribute :current_school_id
attribute :change_school

attr_reader :schools

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module EarlyYearsPayment
module Practitioner
class FindReferenceForm < Form
attribute :reference_number, :string
attribute :email, :string

validates :reference_number, presence: {message: i18n_error_message(:presence)}
validate :validate_permissible_reference_number
Expand All @@ -20,6 +21,7 @@ def claim_exists?
Claim
.by_policy(Policies::EarlyYearsPayments)
.where(reference: reference_number)
.where(practitioner_email_address: email)
.exists?
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Journeys
module TeacherStudentLoanReimbursement
class ClaimSchoolForm < Form
attribute :claim_school_id
attribute :change_school

attr_reader :schools

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %>
<%= f.govuk_error_summary %>

<%= f.hidden_field :email, value: params[:email] %>

<h1 class="govuk-heading-l">
<%= @form.t(:question) %>
<h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "rails_helper"

RSpec.feature "Early years find reference" do
let(:claim) do
create(
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo",
practitioner_email_address: "[email protected]"
)
end

scenario "when different email address" do
when_early_years_payment_practitioner_journey_configuration_exists

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&[email protected]"
expect(page).to have_content "Track your application"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"

expect(page).to have_content "Track your application"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
create(
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo"
)
reference: "foo",
practitioner_email_address: "[email protected]"
)
end

scenario "Happy path" do
when_early_years_payment_practitioner_journey_configuration_exists

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&[email protected]"
expect(page).to have_content "Track your application"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
let(:journey) { Journeys::EarlyYearsPayment::Practitioner }
let(:journey_session) { create(:early_years_payment_practitioner_session) }

let(:reference_number){ nil }
let(:reference_number) { nil }
let(:email) { nil }

let(:params) do
ActionController::Parameters.new(claim: {reference_number:})
ActionController::Parameters.new(claim: {reference_number:, email:})
end

describe "validations" do
Expand All @@ -21,7 +22,7 @@
end

context "when random string" do
let(:reference_number){ "foo" }
let(:reference_number) { "foo" }

it "is not valid" do
expect(subject).to be_invalid
Expand All @@ -30,10 +31,15 @@
end

context "when non EY claim" do
let(:reference_number){ claim.reference }
let(:reference_number) { claim.reference }
let(:email) { claim.practitioner_email_address }

let(:claim) do
create(:claim)
create(
:claim,
reference: "foo",
practitioner_email_address: "[email protected]"
)
end

it "is not valid" do
Expand All @@ -43,14 +49,16 @@
end

context "when EY claim" do
let(:reference_number){ claim.reference }
let(:reference_number) { claim.reference }
let(:email) { claim.practitioner_email_address }

let(:claim) do
create(
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo"
)
reference: "foo",
practitioner_email_address: "[email protected]"
)
end

it "is valid" do
Expand All @@ -68,7 +76,7 @@
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo"
)
)
end

it "updates reference number in session" do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/reminders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

it "redirects to /email-verfication slug" do
submit_form
expect(response).to redirect_to("/additional-payments/reminders/email-verification")
expect(response).to redirect_to("/additional-payments/reminders/email-verification?form%5Bemail_address%5D=joe.bloggs%40example.com&form%5Bfull_name%5D=Joe+Bloggs")
end
end

Expand Down

0 comments on commit 2521d24

Please sign in to comment.