Skip to content

Commit

Permalink
remove hca_use_facilities_API flag usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitch-A6 committed Oct 3, 2024
1 parent fd8e2e1 commit f80ebd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 45 deletions.
21 changes: 1 addition & 20 deletions app/models/health_care_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ def process!
prefill_fields

unless valid?
Rails.logger.warn("HealthCareApplication::ValidationError: #{Flipper.enabled?(:hca_use_facilities_API)}")

StatsD.increment("#{HCA::Service::STATSD_KEY_PREFIX}.validation_error")

StatsD.increment("#{HCA::Service::STATSD_KEY_PREFIX}.validation_error_short_form") if short_form?
Expand Down Expand Up @@ -304,28 +302,11 @@ def send_failure_email
log_exception_to_sentry(e)
end

# If the hca_use_facilities_API flag is on then vaMedicalFacility will only
# validate for a string, else it will validate through the enum. This avoids
# changes to vets-website and vets-json-schema having to deploy simultaneously.
def form_matches_schema
if form.present?
JSON::Validator.fully_validate(current_schema, parsed_form).each do |v|
JSON::Validator.fully_validate(VetsJsonSchema::SCHEMAS[self.class::FORM_ID], parsed_form).each do |v|
errors.add(:form, v.to_s)
end
end
end

def current_schema
feature_enabled_for_user = Flipper.enabled?(:hca_use_facilities_API, user)
Rails.logger.warn(
"HealthCareApplication::hca_use_facilitiesAPI enabled = #{feature_enabled_for_user}"
)

schema = VetsJsonSchema::SCHEMAS[self.class::FORM_ID]
return schema unless feature_enabled_for_user

schema.deep_dup.tap do |c|
c['properties']['vaMedicalFacility'] = { type: 'string' }.as_json
end
end
end
26 changes: 1 addition & 25 deletions spec/requests/v0/health_care_applications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def self.expect_async_submit
end
end

context 'with hca_use_facilities_API enabled' do
context 'with an arbitrary medical facility ID' do
let(:current_user) { create(:user) }
let(:params) do
test_veteran['vaMedicalFacility'] = '000'
Expand All @@ -480,8 +480,6 @@ def self.expect_async_submit

before do
sign_in_as(current_user)
Flipper.disable(:hca_use_facilities_API)
Flipper.enable(:hca_use_facilities_API, current_user)
end

it 'does not error on vaMedicalFacility validation' do
Expand All @@ -491,28 +489,6 @@ def self.expect_async_submit
expect(JSON.parse(response.body)['data']['attributes']).to eq(body)
end
end

context 'with hca_use_facilities_API disabled' do
let(:current_user) { create(:user) }
let(:params) do
test_veteran['vaMedicalFacility'] = '000'
{
form: test_veteran.to_json
}
end

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

it 'errors on vaMedicalFacility validation' do
subject

expect(JSON.parse(response.body)['errors']).not_to be_blank
expect(JSON.parse(response.body)['errors'].first['title']).to include('"000" did not match')
end
end
end
end
end

0 comments on commit f80ebd9

Please sign in to comment.