From a6de9dc8ed00c089b92879ad70c64a097bf22634 Mon Sep 17 00:00:00 2001 From: Saipraveen Gudimetla Date: Wed, 31 Jul 2024 16:56:44 -0400 Subject: [PATCH] fix cv3 family generation issue --- .../transformers/family_to/cv3_family.rb | 9 ++++++-- .../transformers/family_to/cv3_family_spec.rb | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/domain/operations/transformers/family_to/cv3_family.rb b/app/domain/operations/transformers/family_to/cv3_family.rb index 0c9d65b0837..749cb74cd58 100644 --- a/app/domain/operations/transformers/family_to/cv3_family.rb +++ b/app/domain/operations/transformers/family_to/cv3_family.rb @@ -71,8 +71,13 @@ def transform_applications(family, exclude_applications) return Success(nil) unless EnrollRegistry.feature_enabled?(:financial_assistance) return Success([]) if exclude_applications - applications = ::FinancialAssistance::Application.only(:aasm_state, :family_id, :effective_date, :assistance_year, :renewal_base_year, :years_to_renew, :is_ridp_verified, :is_renewal_authorized, :us_state, :hbx_id, :submitted_at, - :applicants, :eligibility_determinations,:relationships, :'workflow_state_transitions.from_state', :full_medicaid_determination).where(family_id: family.id).determined + applications = ::FinancialAssistance::Application.only( + :aasm_state, :family_id, :effective_date, :assistance_year, :renewal_base_year, :years_to_renew, + :is_ridp_verified, :is_renewal_authorized, :us_state, :hbx_id, :submitted_at, + :applicants, :eligibility_determinations,:relationships, :'workflow_state_transitions.from_state', + :'workflow_state_transitions.transition_at', :full_medicaid_determination + ).where(family_id: family.id).determined + transformed_applications = applications.collect do |application| ::FinancialAssistance::Operations::Applications::Transformers::ApplicationTo::Cv3Application.new.call(application) end.compact diff --git a/spec/domain/operations/transformers/family_to/cv3_family_spec.rb b/spec/domain/operations/transformers/family_to/cv3_family_spec.rb index 4a47df93321..8ce94b67403 100644 --- a/spec/domain/operations/transformers/family_to/cv3_family_spec.rb +++ b/spec/domain/operations/transformers/family_to/cv3_family_spec.rb @@ -140,6 +140,15 @@ end end + before do + FinancialAssistance::Application.all.each do |application| + application.workflow_state_transitions.create!( + from_state: 'submitted', + to_state: 'determined' + ) + end + end + it 'performs under 4 seconds' do ::BenefitMarkets::Products::ProductRateCache.initialize_rate_cache! @@ -147,6 +156,18 @@ ::Operations::Transformers::FamilyTo::Cv3Family.new.call(family) end.to perform_under(4).sec end + + it "should not throw missing attribute error" do + applications = ::FinancialAssistance::Application.only( + :aasm_state, :family_id, :effective_date, :assistance_year, :renewal_base_year, :years_to_renew, + :is_ridp_verified, :is_renewal_authorized, :us_state, :hbx_id, :submitted_at, + :applicants, :eligibility_determinations,:relationships, :'workflow_state_transitions.from_state', + :'workflow_state_transitions.transition_at', :full_medicaid_determination + ).where(family_id: family.id).determined + + state_transition = applications.last.workflow_state_transitions.last + expect { state_transition.transition_at }.not_to raise_error(ActiveModel::MissingAttributeError) + end end context 'nested cv3 transform failures' do