Skip to content

Commit

Permalink
remove email from EY practitioner magic link
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Nov 5, 2024
1 parent 4997175 commit 6321235
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module EarlyYearsPayment
module Practitioner
class FindReferenceForm < Form
attribute :reference_number, :string
attribute :email, :string

validates :reference_number, presence: {message: i18n_error_message(:presence)}

Expand All @@ -12,11 +11,10 @@ def save

existing_claim = Claim
.by_policy(Policies::EarlyYearsPayments)
.find_by(reference: reference_number, practitioner_email_address: email)
.find_by(reference: reference_number)

journey_session.answers.assign_attributes(
reference_number:,
start_email: email,
reference_number_found: existing_claim.present?,
claim_already_submitted: existing_claim&.submitted?,
nursery_name: existing_claim&.eligibility&.eligible_ey_provider&.nursery_name
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/claim_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def early_years_payment_provider_magic_link(one_time_password, email)
end

def early_years_practitioner_invite_link(claim:)
"https://#{ENV["CANONICAL_HOSTNAME"]}/#{Journeys::EarlyYearsPayment::Practitioner::ROUTING_NAME}/find-reference?skip_landing_page=true&email=#{CGI.escape(claim.practitioner_email_address)}"
"https://#{ENV["CANONICAL_HOSTNAME"]}/#{Journeys::EarlyYearsPayment::Practitioner::ROUTING_NAME}/find-reference?skip_landing_page=true"
end

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

<%= f.hidden_field :email, value: (params[:email] || journey_session.answers.attributes["start_email"]) %>

<h1 class="govuk-heading-l">
<%= @form.t(:question) %>
<h1>
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/admin_ey_identity_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def complete_practitioner_journey(

create(:journey_configuration, :early_years_payment_practitioner)

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&[email protected]"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true"

fill_in "Claim reference number", with: claim.reference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,10 @@
)
end

scenario "when correct email address with different case" 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 "Enter your claim reference"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"

expect(page).to have_content "Sign in with GOV.UK One Login"
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 "Enter your claim reference"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"

expect(page).to have_content "This claim reference isn’t correct."
end

scenario "after multiple attempts should work" do
when_early_years_payment_practitioner_journey_configuration_exists

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&[email protected]"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true"
expect(page).to have_content "Enter your claim reference"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"
Expand All @@ -52,7 +30,7 @@
scenario "should show ineligibility page when an invalid reference is given" do
when_early_years_payment_practitioner_journey_configuration_exists

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&[email protected]"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true"
expect(page).to have_content "Enter your claim reference"
fill_in "Claim reference number", with: "invalid"
click_button "Submit"
Expand Down Expand Up @@ -87,7 +65,7 @@
scenario "should show ineligibility page when a submitted claim reference is given" do
when_early_years_payment_practitioner_journey_configuration_exists

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&[email protected]"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true"
expect(page).to have_content "Enter your claim reference"
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 @@ -7,12 +7,11 @@
let(:journey_session) { create(:early_years_payment_practitioner_session) }

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

let(:eligible_ey_provider) { create(:eligible_ey_provider) }

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

describe "validations" do
Expand All @@ -25,14 +24,12 @@

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

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

Expand Down Expand Up @@ -120,13 +117,11 @@

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
full_name: claim.full_name,
setting_name: claim.eligibility.eligible_ey_provider.nursery_name,
ref_number: claim.reference,
complete_claim_url: "https://www.example.com/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=johndoe%40example.com"
complete_claim_url: "https://www.example.com/early-years-payment-practitioner/find-reference?skip_landing_page=true"
)
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/claim_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class SomePolicy; end
full_name: "Test Practitioner",
setting_name: "Test Nursery",
ref_number: "TEST123",
complete_claim_url: "https://www.example.com/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=practitioner%40example.com"
complete_claim_url: "https://www.example.com/early-years-payment-practitioner/find-reference?skip_landing_page=true"
}

expect(mail[:personalisation].unparsed_value).to eql(expected_personalisation)
Expand Down

0 comments on commit 6321235

Please sign in to comment.