Skip to content

Commit

Permalink
[LUPEYALPHA-882] Change checkbox to radio buttons for child-facing pa…
Browse files Browse the repository at this point in the history
…ge (#3119)
  • Loading branch information
alkesh authored Aug 28, 2024
1 parent 16ebfbb commit 6d89bbe
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ChildFacingForm < Form
attribute :child_facing_confirmation_given, :boolean

validates :child_facing_confirmation_given,
presence: {message: i18n_error_message(:presence)}
inclusion: {in: [true, false], message: i18n_error_message(:inclusion)}

def save
return false if invalid?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def ineligible?
def ineligibility_reason
if answers.nursery_urn.to_s == "none_of_the_above"
:nursery_is_not_listed
elsif answers.child_facing_confirmation_given == false
:not_child_facing_enough
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<% title = "#{answers.first_name} is not eligible for this payment" %>
<% content_for(:page_title, page_title(title, journey: current_journey_routing_name)) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l"><%= title %></h1>
<p class="govuk-body">
Based on the information you have provided,
<%= answers.first_name %> is not eligible to claim an early years incentive payment.
</p>

<p class="govuk-body">
For further guidance, you should refer to the
<%= govuk_link_to "full eligibility criteria", claim_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME, "landing-page") %>
at the start of this service.
</p>

<h2 class="govuk-heading-m">Get help with your claim</h2>

<p class="govuk-body">
If you have any questions, contact us for help at
<%= mail_to support_email_address(current_journey_routing_name), support_email_address(current_journey_routing_name), class: "govuk-link" %>
</p>
<%= govuk_button_link_to "Start a new claim", claim_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME, "landing-page") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<% content_for(:page_title, page_title(@form.t(:question, first_name: answers.first_name), journey: current_journey_routing_name, show_error: @form.errors.any?)) %>
<% question = @form.t("question", first_name: answers.first_name) %>
<% content_for(:page_title, page_title(question, journey: current_journey_routing_name, show_error: @form.errors.any?)) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_check_boxes_fieldset :child_facing_confirmation_given, multiple: false, legend: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" }, hint: -> do %>
<%= f.govuk_radio_buttons_fieldset :child_facing_confirmation_given,
inline: true,
legend: {
text: question,
tag: "h1",
size: "l"
}, hint: -> do %>
<div class="govuk-body">
<%= @form.t(:hint, first_name: answers.first_name) %>
</div>
<% end do %>
<%= f.govuk_check_box :child_facing_confirmation_given, 1, 0, multiple: false, link_errors: true, label: { text: @form.t(:option, first_name: answers.first_name) } %>
<%= f.govuk_radio_button :child_facing_confirmation_given, true, label: { text: "Yes" } %>
<%= f.govuk_radio_button :child_facing_confirmation_given, false, label: { text: "No" } %>
<% end %>

<%= govuk_details(summary_text: "What does working at least 70% of time directly with children mean?") do %>
Expand All @@ -23,10 +31,6 @@
</ul>
<% end %>

<p class="govuk-body">
<%= govuk_link_to "I cannot confirm this information", "" %>
</p>

<%= f.govuk_submit "Continue" %>
<% end %>
</div>
Expand Down
12 changes: 5 additions & 7 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ en:
claim_description: for an early years financial incentive payment
journey_name: Claim an early years financial incentive payment - provider
feedback_email: "[email protected]"
support_email_address: "[email protected]"
forms:
consent:
question: Declaration of Employee Consent
Expand Down Expand Up @@ -1184,14 +1185,12 @@ en:
date_not_in_future: Start date cannot be in the future
year_must_have_4_digits: Year must include 4 numbers
child_facing:
question: Confirm %{first_name} spends most of their time in their job working directly with children
question: Does %{first_name} spend most of their time in their job working directly with children?
hint:
"%{first_name}’s job must involve spending most of their contracted hours (approximately 70% or more) working
directly with children."
option:
I confirm that at least 70% of %{first_name}’s time in their job is spent working directly with children.
"%{first_name}’s job must involve spending most of their contracted hours (approximately 70% or more) directly working
with children."
errors:
presence: You must be able to confirm this information to continue
inclusion: You must select an option below to continue
returner:
question:
Did %{first_name} work in an early years setting between %{six_months_before_start_date} and %{start_date}?
Expand All @@ -1214,7 +1213,6 @@ en:
early_years_payments:
<<: *early_years_payment_provider_authenticated
claim_subject: "Early Years Payment"
support_email_address: "[email protected]"
activerecord:
errors:
models:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/child-facing"
check "I confirm that at least 70% of Bobby’s time in their job is spent working directly with children."
choose "Yes"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/returner"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require "rails_helper"

RSpec.feature "Early years payment provider child facing" do
let(:email_address) { "[email protected]" }
let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Authenticated::Session.last }
let(:mail) { ActionMailer::Base.deliveries.last }
let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] }
let!(:nursery) { create(:eligible_ey_provider, primary_key_contact_email_address: email_address) }

scenario "selecting No" do
when_early_years_payment_provider_authenticated_journey_configuration_exists
when_early_years_payment_provider_start_journey_completed

visit magic_link
check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice."
click_button "Continue"

choose nursery.nursery_name
click_button "Continue"

fill_in "claim-paye-reference-field", with: "123/123456SE90"
click_button "Continue"

fill_in "First name", with: "Bobby"
fill_in "Last name", with: "Bobberson"
click_button "Continue"

date = Date.yesterday
fill_in("Day", with: date.day)
fill_in("Month", with: date.month)
fill_in("Year", with: date.year)
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/child-facing"
click_button "Continue"

expect(page).to have_content "You must select an option below to continue"
choose "No"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/ineligible"
expect(page).to have_content("Bobby is not eligible for this payment")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
is_expected.not_to(
allow_value(child_facing_confirmation_given)
.for(:child_facing_confirmation_given)
.with_message("You must be able to confirm this information to continue")
.with_message("You must select an option below to continue")
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/steps/eligible_ey_journey_authenticated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def when_early_years_payment_provider_authenticated_journey_ready_to_submit
fill_in("Year", with: date.year)
click_button "Continue"

check "I confirm that at least 70% of Bobby’s time in their job is spent working directly with children."
choose "Yes"
click_button "Continue"

choose "No"
Expand Down

0 comments on commit 6d89bbe

Please sign in to comment.