Skip to content

Commit

Permalink
[LUPEYALPHA-1162] practitioner_claim_submitted_at for EY practitioner…
Browse files Browse the repository at this point in the history
… journey
  • Loading branch information
alkesh committed Oct 15, 2024
1 parent db687ce commit 9865c08
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def save
reference_number:,
start_email: email,
reference_number_found: existing_claim.present?,
claim_already_submitted: existing_claim&.submitted?,
claim_already_submitted: existing_claim&.eligibility&.practitioner_claim_submitted?,
nursery_name: existing_claim&.eligibility&.eligible_ey_provider&.nursery_name
)
journey_session.save!
Expand Down
4 changes: 4 additions & 0 deletions app/models/policies/early_years_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def ineligible?
def eligible_ey_provider
EligibleEyProvider.find_by_urn(nursery_urn)
end

def practitioner_claim_submitted?
practitioner_claim_submitted_at.present?
end
end
end
end
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,4 @@ shared:
- returning_within_6_months
- created_at
- updated_at
- practitioner_claim_submitted_at
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPractitionerClaimSubmittedAtToEarlyYearsPaymentEligibilities < ActiveRecord::Migration[7.0]
def change
add_column :early_years_payment_eligibilities, :practitioner_claim_submitted_at, :datetime
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_09_24_113642) do
ActiveRecord::Schema[7.0].define(version: 2024_10_15_093740) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -197,6 +197,7 @@
t.date "start_date"
t.boolean "child_facing_confirmation_given"
t.boolean "returning_within_6_months"
t.datetime "practitioner_claim_submitted_at"
end

create_table "eligible_ey_providers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/early_years_payments/eligibilities.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FactoryBot.define do
factory :early_years_payments_eligibility, class: "Policies::EarlyYearsPayments::Eligibility" do
trait :practitioner_claim_submitted do
practitioner_claim_submitted_at { Time.zone.now }
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo",
practitioner_email_address: "[email protected]"
practitioner_email_address: "[email protected]",
submitted_at: Time.zone.now
)
end

Expand Down Expand Up @@ -67,7 +68,7 @@
:claim,
:submitted,
policy: Policies::EarlyYearsPayments,
eligibility: build(:early_years_payments_eligibility, nursery_urn: eligible_ey_provider.urn),
eligibility: build(:early_years_payments_eligibility, :practitioner_claim_submitted, nursery_urn: eligible_ey_provider.urn),
reference: "foo",
practitioner_email_address: "[email protected]"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
require "rails_helper"

RSpec.feature "Early years payment practitioner" do
let(:claim) do
create(
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo",
practitioner_email_address: "[email protected]"
)
end
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) }
let(:claim) { Claim.last }

scenario "Happy path" do
when_early_years_payment_provider_authenticated_journey_submitted
when_early_years_payment_practitioner_journey_configuration_exists

visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=user@example.com"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=practitioner@example.com"
expect(page).to have_content "Enter your claim reference"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}.to change { journey_session.reload.answers.nursery_name }.from(nil).to(eligible_ey_provider.nursery_name)
end

context "when the claim is already submitted" do
context "when the claim has only been submitted by the provider, not the practitioner" do
let(:claim) do
create(
:claim,
Expand All @@ -84,7 +84,25 @@
)
end

it "updates claim_already_submitted in session" do
it "sets claim_already_submitted to false in session" do
expect {
subject.save
}.to change { journey_session.reload.answers.claim_already_submitted }.from(nil).to(false)
end
end

context "when the claim has been submitted by the practitioner already" do
let(:claim) do
create(
:claim,
:submitted,
policy: Policies::EarlyYearsPayments,
eligibility: build(:early_years_payments_eligibility, :practitioner_claim_submitted, nursery_urn: eligible_ey_provider.urn),
reference: "foo"
)
end

it "sets claim_already_submitted in session" do
expect {
subject.save
}.to change { journey_session.reload.answers.claim_already_submitted }.from(nil).to(true)
Expand Down
9 changes: 9 additions & 0 deletions spec/support/steps/eligible_ey_journey_authenticated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ def when_early_years_payment_provider_authenticated_journey_ready_to_submit
fill_in "claim-practitioner-email-address-field", with: "[email protected]"
click_button "Continue"
end

def when_early_years_payment_provider_authenticated_journey_submitted
when_early_years_payment_provider_authenticated_journey_configuration_exists
when_early_years_payment_provider_start_journey_completed
when_early_years_payment_provider_authenticated_journey_ready_to_submit

fill_in "claim-provider-contact-name-field", with: "John Doe"
click_button "Accept and send"
end

0 comments on commit 9865c08

Please sign in to comment.