Skip to content

Commit

Permalink
Submit VA Form 28-1900 to Central Mail (#7132)
Browse files Browse the repository at this point in the history
* upload to central mail

* updating specs

* update sending to central mail

* checking if user exists

* updating mailer

* updating specs
  • Loading branch information
kathleencrawford authored Jun 14, 2021
1 parent 32cd4b3 commit 5965003
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def create
end

Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"

claim.send_to_central_mail! if current_user && current_user.participant_id.blank?
claim.send_to_vre(current_user)

render json: claim
end

Expand Down
2 changes: 2 additions & 0 deletions app/mailers/veteran_readiness_employment_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ def build(user, email_addr)
email_addr = 'kcrawford@governmentcio.com' if FeatureFlipper.staging_email?

@submission_date = Time.current.in_time_zone('America/New_York').strftime('%m/%d/%Y')
@pid = user.participant_id || 'Sent to CM'

template = File.read('app/mailers/views/veteran_readiness_employment.html.erb')

mail(
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/views/veteran_readiness_employment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<body>
<p>
<b>Submitted Application</b><br>
Veteran's PID: <%= user.participant_id %><br>
Veteran's PID: <%= @pid %><br>
Type of Form Submitted: 28-1900<br>
Submitted Date: <%= @submission_date %><br>
</p>
Expand Down
13 changes: 13 additions & 0 deletions app/models/saved_claim/veteran_readiness_employment_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ def upload_to_vbms(doc_type: '1167')
uploader.upload!
end

def send_to_central_mail!
form_copy = parsed_form

form_copy['veteranSocialSecurityNumber'] = parsed_form.dig('veteranInformation', 'ssn')
form_copy['veteranFullName'] = parsed_form.dig('veteranInformation', 'fullName')
form_copy['vaFileNumber'] = parsed_form.dig('veteranInformation', 'VAFileNumber')

update(form: form_copy.to_json)

log_message_to_sentry(guid, :warn, { attachment_id: guid }, { team: 'vfs-ebenefits' })
process_attachments!
end

# SavedClaims require regional_office to be defined
def regional_office
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

RSpec.describe V0::VeteranReadinessEmploymentClaimsController, type: :controller do
let(:loa3_user) { create(:evss_user) }
let(:user_no_pid) { create(:unauthorized_evss_user) }

let(:test_form) do
build(:veteran_readiness_employment_claim)
Expand Down Expand Up @@ -33,6 +34,24 @@
sign_in_as(loa3_user)

form_params = { veteran_readiness_employment_claim: { form: test_form.form } }
expect_any_instance_of(SavedClaim::VeteranReadinessEmploymentClaim).not_to receive(:send_to_central_mail!)

post(:create, params: form_params)
expect(response.code).to eq('200')
end
end
end

context 'logged in user with no pid' do
it 'validates successfully and sends to central mail' do
VCR.use_cassette 'veteran_readiness_employment/send_to_vre' do
expect_any_instance_of(BGS::RORoutingService).to receive(:get_regional_office_by_zip_code).and_return(
{ regional_office: { number: '319' } }
)
sign_in_as(user_no_pid)

form_params = { veteran_readiness_employment_claim: { form: test_form.form } }
expect_any_instance_of(SavedClaim::VeteranReadinessEmploymentClaim).to receive(:send_to_central_mail!)

post(:create, params: form_params)
expect(response.code).to eq('200')
Expand Down
11 changes: 11 additions & 0 deletions spec/models/saved_claim/veteran_readiness_employment_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,15 @@
expect(claim.regional_office).to be_empty
end
end

describe '#send_to_central_mail!' do
it 'sends the claim to central mail' do
claim.send_to_central_mail!
end

it 'calls process_attachments! method' do
expect(claim).to receive(:process_attachments!)
claim.send_to_central_mail!
end
end
end

0 comments on commit 5965003

Please sign in to comment.