-
Notifications
You must be signed in to change notification settings - Fork 13
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
Truncate employer name after 35 characters #5455
Conversation
Heroku app: https://gyr-review-app-5455-afe71c96318b.herokuapp.com/ |
@@ -21,7 +21,7 @@ def document | |||
xml.Body do | |||
column_a = w2.box14_ui_wf_swf&.positive? ? w2.box14_ui_wf_swf : w2.box14_ui_hc_wd | |||
|
|||
xml.EmployerName w2.employer_name | |||
xml.EmployerName w2.employer_name[0...35] |
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.
I recommend using sanitize_for_xml(w2.employer_name, 35)
because that method will
- ensure no excess spaces (only single spaces allowed in most (all?) xml strings)
- trim a trailing space if the truncation lands after a space (trailing whitespace can also cause a validation error)
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.
Fixed, thank you!
@mmazanec22 seeing XML errors now generating for the w2 > businessline1 field the IRS is doing validations on employer name for w2s, that limit is 70 characters, so we should never receive an employer name longer than that limit
|
expect(body.at('EmployerName').text).to eq(w2.employer_name) | ||
expect(body.at('EmployerName').text).to eq(w2.employer_name[0...35]) | ||
if w2.employer_name == long_employer_name | ||
expect(body.at('EmployerName').text.length).to eq(35) |
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.
[pebble] putting expectations inside an if
feels off to me, since there's an outside chance the test is only passing because the expectation isn't being tested. I think the expectation on line 28 is probably enough on its own, but if you feel there needs to be more then you could test explicitly the two expected names outside of the .each
?
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.
two pebbles and a dust but otherwise looks great to me!
@mluedke2 I'm going to address your comments in a fast follow since this is an urgent PR to fix bundle failures |
Link to pivotal/JIRA issue
https://github.com/newjersey/affordability-pm/issues/275
Is PM acceptance required? (delete one)
What was done?
Truncate the employer name to avoid bundle failures
How to test?