From bf33fb350a0e38310d18b758b36fa68174a0581f Mon Sep 17 00:00:00 2001 From: Abigail McPhillips Date: Tue, 30 Jul 2024 10:07:44 +0100 Subject: [PATCH] Declaration of consent page - Add new ConsentForm with presence validation on :consent_given attr - Add form spec and extend happy_path feature test - Add basic ClaimSubmissionForm which is required --- .../provider/claim_submission_form.rb | 23 ++++++++ .../provider/consent_form.rb | 19 +++++++ .../journeys/early_years_payment/provider.rb | 4 +- .../provider/session_answers.rb | 2 + .../provider/slug_sequence.rb | 5 +- .../provider/claims/consent.html.erb | 52 +++++++++++++++++++ .../provider/claims/current_nursery.html.erb | 0 .../provider/landing_page.html.erb | 2 +- config/locales/en.yml | 8 +++ .../early_years_payment/provider/session.rb | 5 ++ .../provider/happy_path_spec.rb | 6 ++- .../provider/consent_form_spec.rb | 39 ++++++++++++++ 12 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 app/forms/journeys/early_years_payment/provider/claim_submission_form.rb create mode 100644 app/forms/journeys/early_years_payment/provider/consent_form.rb create mode 100644 app/views/early_years_payment/provider/claims/consent.html.erb create mode 100644 app/views/early_years_payment/provider/claims/current_nursery.html.erb create mode 100644 spec/factories/journeys/early_years_payment/provider/session.rb create mode 100644 spec/forms/journeys/early_years_payment/provider/consent_form_spec.rb diff --git a/app/forms/journeys/early_years_payment/provider/claim_submission_form.rb b/app/forms/journeys/early_years_payment/provider/claim_submission_form.rb new file mode 100644 index 0000000000..01ff2b9c93 --- /dev/null +++ b/app/forms/journeys/early_years_payment/provider/claim_submission_form.rb @@ -0,0 +1,23 @@ +module Journeys + module EarlyYearsPayment + module Provider + class ClaimSubmissionForm < ::ClaimSubmissionBaseForm + private + + def main_eligibility + @main_eligibility ||= Policies::EarlyYearsPayment::Eligibility.new + end + + def calculate_award_amount(eligibility) + # NOOP + # This is just for compatibility with the AdditionalPaymentsForTeaching + # claim submission form. + end + + def generate_policy_options_provided + [] + end + end + end + end +end diff --git a/app/forms/journeys/early_years_payment/provider/consent_form.rb b/app/forms/journeys/early_years_payment/provider/consent_form.rb new file mode 100644 index 0000000000..d84a940586 --- /dev/null +++ b/app/forms/journeys/early_years_payment/provider/consent_form.rb @@ -0,0 +1,19 @@ +module Journeys + module EarlyYearsPayment + module Provider + class ConsentForm < Form + attribute :consent_given, :boolean + + validates :consent_given, + presence: {message: i18n_error_message(:presence)} + + def save + return false if invalid? + + journey_session.answers.assign_attributes(consent_given:) + journey_session.save! + end + end + end + end +end diff --git a/app/models/journeys/early_years_payment/provider.rb b/app/models/journeys/early_years_payment/provider.rb index 3611606b21..61a5fbdaf1 100644 --- a/app/models/journeys/early_years_payment/provider.rb +++ b/app/models/journeys/early_years_payment/provider.rb @@ -9,7 +9,9 @@ module Provider I18N_NAMESPACE = "early_years_payment_provider" POLICIES = [Policies::EarlyYearsPayment] FORMS = { - "claims" => {} + "claims" => { + "consent" => ConsentForm + } } end end diff --git a/app/models/journeys/early_years_payment/provider/session_answers.rb b/app/models/journeys/early_years_payment/provider/session_answers.rb index aed76440e2..c520efea98 100644 --- a/app/models/journeys/early_years_payment/provider/session_answers.rb +++ b/app/models/journeys/early_years_payment/provider/session_answers.rb @@ -2,6 +2,8 @@ module Journeys module EarlyYearsPayment module Provider class SessionAnswers < Journeys::SessionAnswers + attribute :consent_given, :boolean + def policy Policies::EarlyYearsPayment end diff --git a/app/models/journeys/early_years_payment/provider/slug_sequence.rb b/app/models/journeys/early_years_payment/provider/slug_sequence.rb index 72a238301d..f9b60d5a6b 100644 --- a/app/models/journeys/early_years_payment/provider/slug_sequence.rb +++ b/app/models/journeys/early_years_payment/provider/slug_sequence.rb @@ -2,7 +2,10 @@ module Journeys module EarlyYearsPayment module Provider class SlugSequence - SLUGS = %w[].freeze + SLUGS = %w[ + consent + current-nursery + ].freeze def self.start_page_url Rails.application.routes.url_helpers.landing_page_path("early-years-payment-provider") diff --git a/app/views/early_years_payment/provider/claims/consent.html.erb b/app/views/early_years_payment/provider/claims/consent.html.erb new file mode 100644 index 0000000000..f686607c79 --- /dev/null +++ b/app/views/early_years_payment/provider/claims/consent.html.erb @@ -0,0 +1,52 @@ +<% content_for(:page_title, page_title(@form.t(:question), journey: current_journey_routing_name, show_error: @form.errors.any?)) %> + +
+
+ <%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %> + + <%= f.govuk_check_boxes_fieldset :consent_given, multiple: false, legend: nil do %> +

+ <%= @form.t(:question) %> +

+ +

+ You need to confirm that you’ve got consent from your employee before + you can continue with a claim. +

+ +

+ By continuing you’re confirming that you’ve: +

+ + <%= govuk_list [ + "obtained written consent from your employee to share their personal information (full name, start date, email address)", + "provided your employee with a privacy notice that explains what information will be collected, why it is being collected and who it will be shared with" + ], type: :bullet %> + +

+ You do not need to send us the consent forms, but you should keep them + for your records. +

+ +

+ If you have any questions, or need further guidance, contact our support + team at + <%= govuk_link_to t("early_years_payment_provider.feedback_email"), "mailto:#{t("early_years_payment_provider.feedback_email")}", no_visited_state: true %>. +

+ +
+ + + Warning + By ticking this box, you confirm that you have obtained consent from + your employee. + +
+ + <%= f.govuk_check_box :consent_given, 1, 0, multiple: false, link_errors: true, label: { text: @form.t(:option) } %> + <% end %> + + <%= f.govuk_submit %> + <% end %> +
+
diff --git a/app/views/early_years_payment/provider/claims/current_nursery.html.erb b/app/views/early_years_payment/provider/claims/current_nursery.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/early_years_payment/provider/landing_page.html.erb b/app/views/early_years_payment/provider/landing_page.html.erb index 67e4011a16..46b97343e6 100644 --- a/app/views/early_years_payment/provider/landing_page.html.erb +++ b/app/views/early_years_payment/provider/landing_page.html.erb @@ -133,7 +133,7 @@

<% if @journey_open %> - <%= govuk_start_button(text: "Start now", href: "#") %> + <%= govuk_start_button(text: "Start now", href: claim_path(current_journey_routing_name, "claim")) %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 9e63f7e170..26497110a7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1050,6 +1050,14 @@ en: landing_page: title: Claim an early years financial incentive payment feedback_email: "help@opsteam.education.gov.uk" + forms: + consent: + question: Declaration of Employee Consent + option: + I confirm that I have obtained consent from my employee and have provided them with the relevant privacy + notice. + errors: + presence: You must be able to confirm this information to continue activerecord: errors: models: diff --git a/spec/factories/journeys/early_years_payment/provider/session.rb b/spec/factories/journeys/early_years_payment/provider/session.rb new file mode 100644 index 0000000000..39bb086650 --- /dev/null +++ b/spec/factories/journeys/early_years_payment/provider/session.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :early_years_payment_provider_session, class: "Journeys::EarlyYearsPayment::Provider::Session" do + journey { Journeys::EarlyYearsPayment::Provider::ROUTING_NAME } + end +end diff --git a/spec/features/early_years_payment/provider/happy_path_spec.rb b/spec/features/early_years_payment/provider/happy_path_spec.rb index 3643bb1f86..f56592035a 100644 --- a/spec/features/early_years_payment/provider/happy_path_spec.rb +++ b/spec/features/early_years_payment/provider/happy_path_spec.rb @@ -5,6 +5,10 @@ when_early_years_payment_provider_journey_configuration_exists visit landing_page_path(Journeys::EarlyYearsPayment::Provider::ROUTING_NAME) - expect(page).to have_link("Start now") + click_link "Start now" + + expect(page).to have_content("Declaration of Employee Consent") + check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." + click_button "Continue" end end diff --git a/spec/forms/journeys/early_years_payment/provider/consent_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/consent_form_spec.rb new file mode 100644 index 0000000000..b1346dfbca --- /dev/null +++ b/spec/forms/journeys/early_years_payment/provider/consent_form_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Provider::ConsentForm, type: :model do + let(:journey) { Journeys::EarlyYearsPayment::Provider } + let(:journey_session) { create(:early_years_payment_provider_session) } + let(:consent_given) { nil } + + let(:params) do + ActionController::Parameters.new( + claim: { + consent_given: + } + ) + end + + subject do + described_class.new(journey_session:, journey:, params:) + end + + describe "validations" do + it do + is_expected.not_to( + allow_value(consent_given) + .for(:consent_given) + .with_message("You must be able to confirm this information to continue") + ) + end + end + + describe "#save" do + let(:consent_given) { true } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.consent_given }.to(true) + ) + end + end +end