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-763] EY Declaration of consent page #3048

Merged
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
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this description as we're now using calculate_award_amount for IRP claims too - obv not a blocker!

end

def generate_policy_options_provided
[]
end
end
end
end
end
19 changes: 19 additions & 0 deletions app/forms/journeys/early_years_payment/provider/consent_form.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion app/models/journeys/early_years_payment/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ module Provider
I18N_NAMESPACE = "early_years_payment_provider"
POLICIES = [Policies::EarlyYearsPayment]
FORMS = {
"claims" => {}
"claims" => {
"consent" => ConsentForm
}
}
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Journeys
module EarlyYearsPayment
module Provider
class SessionAnswers < Journeys::SessionAnswers
attribute :consent_given, :boolean

def policy
Policies::EarlyYearsPayment
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
49 changes: 49 additions & 0 deletions app/views/early_years_payment/provider/claims/consent.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<% content_for(:page_title, page_title(@form.t(: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, html: { novalidate: false } do |f| %>

<%= f.govuk_check_boxes_fieldset :consent_given, multiple: false, legend: { text: @form.t(:question), tag: "h1", size: "l" }, hint: -> do %>
<p class="govuk-body">
You need to confirm that you’ve got consent from your employee before
you can continue with a claim.
</p>

<p class="govuk-body">
By continuing you’re confirming that you’ve:
</p>

<%= 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 %>

<p class="govuk-body">
You do not need to send us the consent forms, but you should keep them
for your records.
</p>

<p class="govuk-body">
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 %>.
</p>

<div class="govuk-warning-text">
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
<strong class="govuk-warning-text__text">
<span class="govuk-visually-hidden">Warning</span>
By ticking this box, you confirm that you have obtained consent from
your employee.
</strong>
</div>
<% end do %>

<%= f.govuk_check_box :consent_given, 1, 0, multiple: false, link_errors: true, label: { text: @form.t(:option) } %>
<% end %>

<%= f.govuk_submit %>
<% end %>
</div>
</div>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
</p>

<% 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 %>
</div>
</div>
8 changes: 8 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,14 @@ en:
landing_page:
title: Claim an early years financial incentive payment
feedback_email: "[email protected]"
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading