Skip to content

Commit

Permalink
mobile - lighthouse claims request decision (#12896)
Browse files Browse the repository at this point in the history
  • Loading branch information
aherzberg authored Jun 6, 2023
1 parent 6078929 commit 68f0a0d
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ module Mobile
module V0
class ClaimsAndAppealsController < ApplicationController
include IgnoreNotFound
before_action(only: %i[index get_claim]) do
before_action(only: %i[index get_claim request_decision]) do
if Flipper.enabled?(:mobile_lighthouse_claims, @current_user)
authorize :lighthouse, :access?
else
authorize :evss, :access?
end
end

before_action(except: %i[index get_claim]) do
before_action(except: %i[index get_claim request_decision]) do
authorize :evss, :access?
end

Expand Down Expand Up @@ -50,7 +50,11 @@ def get_appeal
end

def request_decision
jid = evss_claims_proxy.request_decision(params[:id])
jid = if Flipper.enabled?(:mobile_lighthouse_claims, @current_user)
lighthouse_claims_proxy.request_decision(params[:id])
else
evss_claims_proxy.request_decision(params[:id])
end
render json: { data: { job_id: jid } }, status: :accepted
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def get_claims_and_appeals
[data, errors]
end

def request_decision(id)
claims_service.submit5103(id)
end

private

def claims_adapter
Expand Down
27 changes: 18 additions & 9 deletions modules/mobile/spec/request/claims_decision_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@
require 'rails_helper'
require_relative '../support/helpers/iam_session_helper'

RSpec.describe 'claims decision request', type: :request do
RSpec.describe 'lighthouse claims decision request', type: :request do
describe 'GET /v0/claim/:id/request-decision' do
before do
iam_sign_in
FactoryBot.create(:evss_claim, id: 1, evss_id: 600_117_255, user_uuid: '3097e489-ad75-5746-ab1a-e0aabc1b426a')
token = 'abcdefghijklmnop'
allow_any_instance_of(BenefitsClaims::Configuration).to receive(:access_token).and_return(token)
user = build(:iam_user)
iam_sign_in(user)
Flipper.enable(:mobile_lighthouse_claims, user)
end

after { Flipper.disable(:mobile_lighthouse_claims) }

it 'returns jid with 202 status' do
post '/mobile/v0/claim/600117255/request-decision', headers: iam_headers
expect(response.status).to eq(202)
expect(response.parsed_body.dig('data', 'jobId')).to eq(EVSS::RequestDecision.jobs.first['jid'])
VCR.use_cassette('mobile/lighthouse_claims/request_decision/200_response') do
post '/mobile/v0/claim/600397108/request-decision', headers: iam_headers
end
expect(response).to have_http_status(:accepted)
expect(response.parsed_body.dig('data', 'jobId')).to eq({ 'success' => true })
end

it 'returns 500 for non-existent record' do
post '/mobile/v0/claim/3242233/request-decision', headers: iam_headers
expect(response.status).to eq(500)
it 'returns 404 for non-existent record' do
VCR.use_cassette('mobile/lighthouse_claims/request_decision/404_response') do
post '/mobile/v0/claim/600397108/request-decision', headers: iam_headers
end
expect(response).to have_http_status(:not_found)
end
end
end
25 changes: 25 additions & 0 deletions modules/mobile/spec/request/legacy_claims_decision_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/helpers/iam_session_helper'

RSpec.describe 'claims decision request', type: :request do
describe 'GET /v0/claim/:id/request-decision' do
before do
iam_sign_in
FactoryBot.create(:evss_claim, id: 1, evss_id: 600_117_255, user_uuid: '3097e489-ad75-5746-ab1a-e0aabc1b426a')
Flipper.disable(:mobile_lighthouse_claims)
end

it 'returns jid with 202 status' do
post '/mobile/v0/claim/600117255/request-decision', headers: iam_headers
expect(response).to have_http_status(:accepted)
expect(response.parsed_body.dig('data', 'jobId')).to eq(EVSS::RequestDecision.jobs.first['jid'])
end

it 'returns 500 for non-existent record' do
post '/mobile/v0/claim/3242233/request-decision', headers: iam_headers
expect(response).to have_http_status(:internal_server_error)
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 68f0a0d

Please sign in to comment.