Skip to content

Commit

Permalink
Merge pull request #3352 from DFE-Digital/LUPEYALPHA-1174-EY-admin-em…
Browse files Browse the repository at this point in the history
…ployment-task

[LUPEYALPHA-1174] EY employment task
  • Loading branch information
alkesh authored Oct 31, 2024
2 parents 099ab4c + 018daaf commit d892aa6
Show file tree
Hide file tree
Showing 32 changed files with 161 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ def has_ecp_or_lupp_policy?
has_ecp_policy? || has_lupp_policy?
end

def has_early_years_payments_policy?
policy == Policies::EarlyYearsPayments
end

def important_notes
notes&.where(important: true)
end
Expand Down
20 changes: 20 additions & 0 deletions app/models/policies/early_years_payments/admin_tasks_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Policies
module EarlyYearsPayments
class AdminTasksPresenter
include Admin::PresenterMethods

attr_reader :claim

def initialize(claim)
@claim = claim
end

def employment
[
["Current employment", claim.eligibility.eligible_ey_provider.nursery_name],
["Start date", l(claim.eligibility.start_date)]
]
end
end
end
end
8 changes: 8 additions & 0 deletions app/models/policies/early_years_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def eligible_ey_provider
def provider_claim_submitted?
provider_claim_submitted_at.present?
end

def employment_task_available_at
start_date + 6.months
end

def employment_task_available?
Date.today >= employment_task_available_at
end
end
end
end
6 changes: 6 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ def to_param
def identity_confirmation?
name == "identity_confirmation"
end

def employment_task_available?
return true unless claim.has_early_years_payments_policy?

claim.eligibility.employment_task_available?
end
end
6 changes: 5 additions & 1 deletion app/views/admin/tasks/employment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
<% if @task.persisted? %>
<%= render "task_outcome", task: @task, notes: @notes %>
<% else %>
<%= render "form", task_name: "employment", claim: @claim %>
<% if @task.employment_task_available? %>
<%= render "form", task_name: "employment", claim: @claim %>
<% else %>
<%= govuk_inset_text(text: "This task will be available from #{l(@claim.eligibility.employment_task_available_at)}") %>
<% end %>
<% end %>

<%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,9 @@ en:
duplicate: Duplicate
no_response: No response
other: Other
task_questions:
employment:
title: Is the claimant still working at the current nursery above?
early_years_payment_practitioner:
journey_name: Claim an early years financial incentive payment - practitioner
feedback_email: "[email protected]"
Expand Down
21 changes: 21 additions & 0 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,27 @@
end
end

describe "#has_early_years_payments_policy?" do
subject { claim.has_early_years_payments_policy? }
let(:claim) { create(:claim, :submitted, policy:) }

context "with early years payements policy" do
let(:policy) { Policies::EarlyYearsPayments }

it { is_expected.to be true }
end

context "with other policies:" do
(Policies.all - [Policies::EarlyYearsPayments]).each do |policy|
context policy do
let(:policy) { policy }

it { is_expected.to be false }
end
end
end
end

describe "#important_notes" do
subject(:important_notes) do
claim.important_notes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "rails_helper"

RSpec.describe Policies::EarlyYearsPayments::AdminTasksPresenter do
describe "#employment" do
let(:claim) {
create(:claim,
:submitted,
policy: Policies::EarlyYearsPayments,
eligibility_attributes: {
nursery_urn: eligible_ey_provider.urn,
start_date: Date.new(2018, 1, 1)
})
}
let(:eligible_ey_provider) { create(:eligible_ey_provider) }

subject { described_class.new(claim).employment }

it "shows current employment" do
expect(subject[0][1]).to eq claim.eligibility.eligible_ey_provider.nursery_name
end

it "shows start date" do
expect(subject[1][1]).to eq "1 January 2018"
end
end
end
35 changes: 35 additions & 0 deletions spec/models/policies/early_years_payments/eligibility_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe Policies::EarlyYearsPayments::Eligibility do
let(:eligibility) { build(:early_years_payments_eligibility, :eligible) }

describe "#employment_task_available_at" do
subject { eligibility.employment_task_available_at }

it { is_expected.to eq eligibility.start_date + 6.months }
end

describe "#employment_task_available?" do
subject { eligibility.employment_task_available? }

context "before 6 months from start date" do
before { travel_to eligibility.start_date }

it { is_expected.to be false }
end

context "exactly 6 months from start date" do
before { travel_to eligibility.start_date + 6.months }

it { is_expected.to be true }
end

context "after 6 months from start date" do
before { travel_to eligibility.start_date + 6.months + 1.day }

it { is_expected.to be true }
end
end
end
33 changes: 33 additions & 0 deletions spec/models/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,37 @@
end
end
end

describe "#employment_task_available?" do
subject { task.employment_task_available? }

let(:task) { build(:task, claim: claim) }
let(:claim) { create(:claim, :submitted, policy:) }

context "for claims with EarlyYearsPayments policy" do
let(:policy) { Policies::EarlyYearsPayments }

context "when the task is available" do
let(:claim) { create(:claim, :submitted, policy:, eligibility_attributes: {start_date: 1.year.ago}) }

it { is_expected.to be true }
end

context "when the task is not yet available" do
let(:claim) { create(:claim, :submitted, policy:, eligibility_attributes: {start_date: 1.day.ago}) }

it { is_expected.to be false }
end
end

context "for claims with other policies" do
(Policies.all - [Policies::EarlyYearsPayments]).each do |policy|
context policy do
let(:policy) { policy }

it { is_expected.to be true }
end
end
end
end
end

0 comments on commit d892aa6

Please sign in to comment.