From 6243411c4b7ffdf57e1dee5496021afdfab9dc4d Mon Sep 17 00:00:00 2001 From: Sri Harsha Date: Thu, 28 Sep 2023 15:28:13 -0400 Subject: [PATCH] includes cobra employees in eligible to enroll employees (#2462) Co-authored-by: utkarsh7989 --- app/models/census_employee.rb | 4 +++- .../benefit_applications/benefit_application_spec.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/census_employee.rb b/app/models/census_employee.rb index 51eceee314e..fa5a777cbe5 100644 --- a/app/models/census_employee.rb +++ b/app/models/census_employee.rb @@ -272,11 +272,13 @@ class CensusEmployee < CensusMember matched.by_benefit_group_assignment_ids(benefit_group_assignment_ids) } + # includes cobra employees in eligible to enroll non terminated employees. ref: 102639 scope :census_employees_active_on, lambda { |date| where( "$or" => [ {"employment_terminated_on" => nil}, - {"employment_terminated_on" => {"$gte" => date}} + {"employment_terminated_on" => {"$gte" => date}}, + {"aasm_state" => "cobra_linked"} ] ) } diff --git a/components/benefit_sponsors/spec/models/benefit_sponsors/benefit_applications/benefit_application_spec.rb b/components/benefit_sponsors/spec/models/benefit_sponsors/benefit_applications/benefit_application_spec.rb index e24b128dcd4..1d9ec8e9362 100644 --- a/components/benefit_sponsors/spec/models/benefit_sponsors/benefit_applications/benefit_application_spec.rb +++ b/components/benefit_sponsors/spec/models/benefit_sponsors/benefit_applications/benefit_application_spec.rb @@ -641,6 +641,17 @@ module BenefitSponsors expect(renewal_application.active_census_employees_under_py.count).to eq 4 end + it 'should return the cobra EEs' do + expect(renewal_application.active_census_employees_under_py.count).to eq 5 + term_date = renewal_application.effective_period.min - 10.days + ce = renewal_application.active_census_employees_under_py.first + ce.aasm_state = 'cobra_linked' + ce.employment_terminated_on = term_date + ce.benefit_group_assignments.last.update(benefit_package_id: renewal_application.benefit_packages.first.id) + ce.save(validate: false) + expect(renewal_application.active_census_employees_under_py.count).to eq 5 + end + it 'should not return term pending with prior effective date as term date' do expect(renewal_application.active_census_employees_under_py.count).to eq 5 term_date = renewal_application.effective_period.min - 10.days