Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LUPEYALPHA-941] Add ineligibility screen for users not on whitelist #3140

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def save
)
journey_session.save!
ClaimMailer.early_years_payment_provider_email(answers, otp_code(email_address), email_address).deliver_now
else
journey_session.answers.assign_attributes(email_address: email_address)
journey_session.save!
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SlugSequence
SLUGS = %w[
email-address
check-your-email
ineligible
].freeze

def self.start_page_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ def status
end

def ineligible?
return false if answers.is_a?(Journeys::EarlyYearsPayment::Provider::Start::SessionAnswers)

ineligibility_reason.present?
end

def ineligibility_reason
start_ineligibility_reason || authenticated_ineligibility_reason
end

def start_ineligibility_reason
return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Start::SessionAnswers)

if !EligibleEyProvider.eligible_email?(answers.email_address)
:email_not_on_whitelist
end
end

def authenticated_ineligibility_reason
return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Authenticated::SessionAnswers)

if answers.nursery_urn.to_s == "none_of_the_above"
:nursery_is_not_listed
elsif answers.child_facing_confirmation_given == false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% content_for(:page_title, page_title("You do not have access to this service", journey: current_journey_routing_name)) %>
<% @backlink_path = claim_path(current_journey_routing_name, "email-address") %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">You do not have access to this service</h1>
<p class="govuk-body">
This email address does not have access to this service. Check the email address you entered and try again.
</p>
<p class="govuk-body">
To request access, contact us at <%= govuk_mail_to t("early_years_payment_provider_start.feedback_email") %>.
</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<% ineligibility_reason = Journeys::EarlyYearsPayment::Provider::Start::EligibilityChecker.new(journey_session:).ineligibility_reason %>
<%= render "ineligibility_#{ineligibility_reason}" %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require "rails_helper"

RSpec.feature "Early years payment provider" do
let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Start::Session.last }

scenario "entering an email address which is not on the whitelist" do
when_early_years_payment_provider_start_journey_configuration_exists
when_eligible_ey_provider_exists

visit landing_page_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME)
click_link "Start now"

expect(page.title).to have_text("Enter your email address")
expect(page).to have_content("Enter your email address")
fill_in "Email address", with: "[email protected]"
click_on "Submit"

expect(page.title).to have_text("You do not have access to this service")
expect(page).to have_content("You do not have access to this service")
expect(page).to have_content("This email address does not have access to this service. Check the email address you entered and try again.")
expect(page).not_to have_css ".govuk-notification-banner--success"
end

scenario "entering an email address which is not valid" do
when_early_years_payment_provider_start_journey_configuration_exists
when_eligible_ey_provider_exists

visit landing_page_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME)
click_link "Start now"

expect(page.title).to have_text("Enter your email address")
expect(page).to have_content("Enter your email address")
fill_in "Email address", with: "invalidemailaddress"
click_on "Submit"

expect(page.title).to have_text("You do not have access to this service")
expect(page).to have_content("You do not have access to this service")
expect(page).to have_content("This email address does not have access to this service. Check the email address you entered and try again.")
expect(page).not_to have_css ".govuk-notification-banner--success"
end
end
Loading