-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
- Loading branch information
1 parent
4dc7151
commit bf33fb3
Showing
12 changed files
with
161 additions
and
4 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/forms/journeys/early_years_payment/provider/claim_submission_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
end | ||
|
||
def generate_policy_options_provided | ||
[] | ||
end | ||
end | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
app/forms/journeys/early_years_payment/provider/consent_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/views/early_years_payment/provider/claims/consent.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<% 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: nil do %> | ||
<h1 class="govuk-heading-l"> | ||
<%= @form.t(:question) %> | ||
</h1> | ||
|
||
<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> | ||
|
||
<%= 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1050,6 +1050,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: | ||
|
5 changes: 5 additions & 0 deletions
5
spec/factories/journeys/early_years_payment/provider/session.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
spec/forms/journeys/early_years_payment/provider/consent_form_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |