Skip to content

Commit

Permalink
add flipper toggle and ability to turn off calling the bgs service. W…
Browse files Browse the repository at this point in the history
…e plan to use this for a planned outage.
  • Loading branch information
coope93 committed Nov 13, 2024
1 parent b8000c2 commit a6a8755
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/v0/health_care_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class HealthCareApplicationsController < ApplicationController
before_action(only: :rating_info) { authorize(:hca_disability_rating, :access?) }

def rating_info
if Flipper.enabled?(:hca_disable_bgs_service)
# Return 0 when not calling the actual BGS::Service
render json: HCARatingInfoSerializer.new({ user_percent_of_disability: 0 })
return
end

service = BGS::Service.new(current_user)
disability_rating = service.find_rating_data[:disability_rating_record][:service_connected_combined_degree]

Expand Down
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ features:
hca_browser_monitoring_enabled:
actor_type: user
description: Enables browser monitoring for the health care application.
hca_disable_bgs_service:
actor_type: user
description: Do not call the BGS Service when this is turned on. Instead return 0 for rating.
hca_enrollment_status_override_enabled:
actor_type: user
description: Enables override of enrollment status for a user, to allow multiple submissions with same user.
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/v0/health_care_applications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let(:current_user) { build(:ch33_dd_user) }

before do
Flipper.disable(:hca_disable_bgs_service)
sign_in_as(current_user)
end

Expand All @@ -28,6 +29,22 @@
)
end

context 'hca_disable_bgs_service enabled' do
before do
Flipper.enable(:hca_disable_bgs_service)
end

it 'returns the rating info as 0' do
VCR.use_cassette('bgs/service/find_rating_data', VCR::MATCH_EVERYTHING) do
get(rating_info_v0_health_care_applications_path)
end

expect(JSON.parse(response.body)['data']['attributes']).to eq(
{ 'user_percent_of_disability' => 0 }
)
end
end

context 'User not found' do
before do
error404 = Common::Exceptions::RecordNotFound.new(1)
Expand Down

0 comments on commit a6a8755

Please sign in to comment.