From 709e36e30fe0068a371caa3c8a60d087a723b237 Mon Sep 17 00:00:00 2001 From: Kevin Suarez Date: Wed, 24 Apr 2024 09:52:16 -0400 Subject: [PATCH 1/2] 80453 pt2 rehydrate 5655 controller (#16459) * 80453 create a method to upsert IPFs based on 5655 metadata * move user verification logic out of UserVerification model at reviewer's request * 80453 add rehydration controller methods * linter or leave 'er am I right? --- .../v0/financial_status_reports_controller.rb | 22 ++++++++++++ modules/debts_api/config/routes.rb | 3 ++ .../debts_api/v0/fsr_rehydration_service.rb | 19 ++++++++++ ...inancial_status_reports_controller_spec.rb | 35 +++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 modules/debts_api/lib/debts_api/v0/fsr_rehydration_service.rb diff --git a/modules/debts_api/app/controllers/debts_api/v0/financial_status_reports_controller.rb b/modules/debts_api/app/controllers/debts_api/v0/financial_status_reports_controller.rb index 76ec33c8869..1cff11148e6 100644 --- a/modules/debts_api/app/controllers/debts_api/v0/financial_status_reports_controller.rb +++ b/modules/debts_api/app/controllers/debts_api/v0/financial_status_reports_controller.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'debts_api/v0/financial_status_report_service' +require 'debts_api/v0/fsr_rehydration_service' module DebtsApi module V0 @@ -23,6 +24,27 @@ def download_pdf ) end + def submissions + submissions = DebtsApi::V0::Form5655Submission.where(user_uuid: current_user.uuid) + render json: { 'submissions' => submissions.map { |sub| { 'id' => sub.id } } } + end + + def rehydrate + submission_id = params[:submission_id] + + DebtsApi::V0::FsrRehydrationService.attempt_rehydration(user_uuid: current_user.uuid, submission_id:) + + render json: { result: 'FSR rehydrated' } + rescue ActiveRecord::RecordNotFound + render json: { error: "Form5655Submission record #{submission_id} not found." }, status: :not_found + rescue DebtsApi::V0::FsrRehydrationService::UserDoesNotOwnsubmission + render json: { error: "User #{current_user.uuid} does not own submission #{submission_id}" }, + status: :unauthorized + rescue DebtsApi::V0::FsrRehydrationService::NoInProgressFormDataStored + render json: { error: "Form5655Submission record #{submission_id} missing InProgressForm data", + status: :not_found } + end + private def render_not_found diff --git a/modules/debts_api/config/routes.rb b/modules/debts_api/config/routes.rb index 6b3ab5c1b7a..5fbb494ba96 100644 --- a/modules/debts_api/config/routes.rb +++ b/modules/debts_api/config/routes.rb @@ -5,9 +5,12 @@ resources :financial_status_reports, only: %i[create] do collection do get :download_pdf + get :submissions end end + get 'financial_status_reports/rehydrate_submission/:submission_id', to: 'financial_status_reports#rehydrate' + post 'calculate_total_assets', to: 'financial_status_reports_calculations#total_assets' post 'calculate_monthly_expenses', to: 'financial_status_reports_calculations#monthly_expenses' post 'calculate_all_expenses', to: 'financial_status_reports_calculations#all_expenses' diff --git a/modules/debts_api/lib/debts_api/v0/fsr_rehydration_service.rb b/modules/debts_api/lib/debts_api/v0/fsr_rehydration_service.rb new file mode 100644 index 00000000000..c66130b30b5 --- /dev/null +++ b/modules/debts_api/lib/debts_api/v0/fsr_rehydration_service.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module DebtsApi + class V0::FsrRehydrationService + include SentryLogging + + class UserDoesNotOwnsubmission < StandardError; end + class NoInProgressFormDataStored < StandardError; end + + def self.attempt_rehydration(user_uuid:, submission_id:) + submission = DebtsApi::V0::Form5655Submission.find(submission_id) + + raise NoInProgressFormDataStored unless submission.ipf_data + raise UserDoesNotOwnsubmission unless submission.user_uuid == user_uuid + + submission.upsert_in_progress_form + end + end +end diff --git a/modules/debts_api/spec/request/debts_api/v0/financial_status_reports_controller_spec.rb b/modules/debts_api/spec/request/debts_api/v0/financial_status_reports_controller_spec.rb index 63be330783b..35f7955f963 100644 --- a/modules/debts_api/spec/request/debts_api/v0/financial_status_reports_controller_spec.rb +++ b/modules/debts_api/spec/request/debts_api/v0/financial_status_reports_controller_spec.rb @@ -59,4 +59,39 @@ def mock_pdf_fill expect(response.body).to eq(content) end end + + describe '#rehydrate' do + context 'on a nonexistent submission' do + it 'renders a 404' do + get '/debts_api/v0/financial_status_reports/rehydrate_submission/1' + expect(response).to have_http_status(:not_found) + end + end + + context 'on a submission you don\'t own' do + let(:form5655_submission) { create(:debts_api_form5655_submission) } + + it 'renders a 404' do + form5655_submission + form5655_submission.update!(user_uuid: 'nottherightguy', ipf_data: '{"its":"me"}') + get "/debts_api/v0/financial_status_reports/rehydrate_submission/#{form5655_submission.id}" + expect(response.code).to eq('401') + body = "{\"error\":\"User #{user.uuid} does not own submission #{form5655_submission.id}\"}" + expect(response.body).to eq(body) + end + end + + context 'on a submission you do own' do + let(:form5655_submission) do + create(:debts_api_form5655_submission, user_uuid: 'b2fab2b56af045e1a9e2394347af91ef') + end + + it 'rehydrates In Progress Form' do + form5655_submission + form5655_submission.update!(user_uuid: user.uuid, ipf_data: '{"its":"me"}') + get "/debts_api/v0/financial_status_reports/rehydrate_submission/#{form5655_submission.id}" + expect(response.code).to eq('200') + end + end + end end From a267cc85a78a10618d62a9ed4fa6d0d3c367ac04 Mon Sep 17 00:00:00 2001 From: Richard Davis Date: Wed, 24 Apr 2024 10:05:48 -0400 Subject: [PATCH 2/2] Adds mhv_landing_page_enable_va_gov_health_tools_links feature toggle (#16398) --- config/features.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/features.yml b/config/features.yml index 49463e5e0e6..79b167cdef5 100644 --- a/config/features.yml +++ b/config/features.yml @@ -730,6 +730,9 @@ features: actor_type: user description: Enables/disables refill-related content for Medications on VA.gov enable_in_development: true + mhv_landing_page_enable_va_gov_health_tools_links: + actor_type: user + description: Enables VA.gov Health Tools links (Appts, SM, Rx, Records) on MHV-on-VA.gov Landing Page mhv_to_logingov_account_transition: actor_type: cookie_id description: Enables/disables MHV to Login.gov account transfer experience (Identity)