Skip to content

Commit

Permalink
fix cv3 family generation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
saipraveen18 committed Jul 31, 2024
1 parent 8588c01 commit a6de9dc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/domain/operations/transformers/family_to/cv3_family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions spec/domain/operations/transformers/family_to/cv3_family_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,34 @@
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!

expect do
::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
Expand Down

0 comments on commit a6de9dc

Please sign in to comment.