-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#90355 [10-10 Health Apps] Improve code quality for shared code #20022
base: master
Are you sure you want to change the base?
Conversation
…fairs/vets-api into 90355_1010_apps_improve_code_quality
Generated by 🚫 Danger |
@@ -71,7 +71,7 @@ def send_failure_email? | |||
end | |||
|
|||
def submit_sync | |||
@parsed_form = override_parsed_form(parsed_form) | |||
@parsed_form = HCA::OverridesParser.new(parsed_form).override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed a bit more logical than calling a method that calls this line of code.
|
||
Rails.logger.error( | ||
"10-10EZR form validation failed. Form does not match schema. Error list: #{validation_errors}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logger was moved into the log_validation_errors
method.
lib/form1010_ezr/service.rb
Outdated
@@ -155,7 +159,7 @@ def configure_and_validate_form(parsed_form) | |||
post_fill_fields(parsed_form) | |||
validate_form(parsed_form) | |||
# Due to overriding the JSON form schema, we need to do so after the form has been validated | |||
override_parsed_form(parsed_form) | |||
HCA::OverridesParser.new(parsed_form).override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed a bit more logical than calling a method that calls this line of code.
lib/hca/enrollment_system.rb
Outdated
@@ -865,18 +865,18 @@ def add_attachment(file, id, is_dd214) | |||
end | |||
|
|||
# @param [Hash] veteran data in JSON format | |||
# @param [Account] current_user | |||
# @param [Hash] user_identifier | |||
# @param [String] form_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current_user
was not a record, but instead a Hash. I changed the name of this variable because it was kind of misleading.
# @param [Hash] user_identifier | ||
# @example { 'icn' => user.icn, 'edipi' => user.edipi } | ||
def initialize(user_identifier = nil) | ||
super() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint was complaining about not havingsuper
, so I added it 😅
end | ||
end | ||
|
||
describe '#submission_body' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this is a private method, we have some tests in the HCA service spec called conformance tests
, which essentially ensure the json form is being formatted into the proper xml. Well, this method is what handles that formatting, so I added them here because it's more of an integration test in the HCA service spec as opposed to a unit test like it is here.
|
||
allow_any_instance_of(HCA::Service).to receive(:submit_form) do | ||
raise Common::Client::Errors::HTTPError, 'error message' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is different than what we had before adding the new enrollment service. The code on line 872
did not work. I'm wondering why we didn't allow it to receive submit_form
in the original implementation instead of :post
🤔 This seems much more straight forward 🤷♂️ Please let me know if I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works for the original because the es_submit
is an included method on the class, so it is the same as having the HCA::Service
call the post method. With the toggle on, you're instantiating your new VA1010Forms::EnrollmentSystem::Service
class which is making the call, but it's this new service class that is making the post
call now, and not the HCA::Service
class anymore. Does that make sense?
So in this case, I do want to call out that this spec isn't really testing the flipper logic, but is rather just testing that the submit_form
method is called on the HCA::Service
. I think it's fine since we are testing that logic in the service elsewhere, but that does make this test kind of awkward at the moment. You could delete the toggle and this one would still pass. However, it's probably still a good test since once we remove the toggle the old one will fail since we are no longer making the post
call from the HCA::Service
, but rather the new VA1010Forms::EnrollmentSystem::Service
.
So all that to say I think these updated specs here look good as far as I can tell😄
|
||
allow_any_instance_of(HCA::Service).to receive(:post) do | ||
raise Common::Client::Errors::HTTPError, 'error message' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I was referring to in the previous comment ⬆️
…fairs/vets-api into 90355_1010_apps_improve_code_quality
@JoshingYou1 there are some linting warnings |
…fairs/vets-api into 90355_1010_apps_improve_code_quality
They have been addressed. Thank you! |
Note: Delete the description statements, complete each step. None are optional, but can be justified as to why they cannot be completed as written. Provide known gaps to testing that may raise the risk of merging to production.
Summary
The majority of the code written in this PR was to split unit tests out for when the flipper is enabled and disabled.
VA1010Forms::EnrollmentSystem::Service
for the 10-10EZ and 10-10EZR.conformance tests
fromspec/lib/hca/service_spec.rb
tospec/lib/va1010_forms/enrollment_system/service_spec.rb
because they don't actually test anything functionality that belongs to theHCA::Service
class.10-10 Health apps
The success criteria is that the app functions the same way with the toggle on and off.
Related issue(s)
Testing done
Yes. Tests are written for when the flipper is on and when it's off
Screenshots
Note: Optional
What areas of the site does it impact?
10-10EZ and 10-10EZR forms
Acceptance criteria
Requested Feedback
(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?