Refactor NewPhoneForm class for clarity, consistency, conventions#7766
Merged
Refactor NewPhoneForm class for clarity, consistency, conventions#7766
Conversation
mitchellhenke
approved these changes
Feb 3, 2023
zachmargolis
approved these changes
Feb 3, 2023
Contributor
zachmargolis
left a comment
There was a problem hiding this comment.
LGTM one small suggestion
Comment on lines
+24
to
+27
| @user = user | ||
| @otp_delivery_preference = user.otp_delivery_preference | ||
| @otp_make_default_number = false | ||
| @setup_voice_preference = setup_voice_preference |
Contributor
There was a problem hiding this comment.
if we're no longer using the writer methods, let's change the attr_accessor above to attr_reader?
Contributor
Author
There was a problem hiding this comment.
Yeah I'd be on-board with that. I'll need to check that the accessor methods weren't being used outside the class implementation.
Rewrites phone validation specs since they rely on the accessor, which isn't actually how the class validation would happen in the real-world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎫 Ticket
Extracted from #7761, related to LG-8771.
🛠 Summary of changes
Minor revisions to
NewPhoneFormto improve clarity and consistency of arguments, and adopt conventions of instance variable assignment.userfrom positional argument to keyword argument, so that there's not an unnecessary combination of both, and to improve the clarity of the arguments that the class is expected to receive, since it's not instinctively obvious thatuserwould be the first argument of the class's constructor.@instead ofself.for class instance variable assignment, since it's more conventional.📜 Testing Plan
rspec spec/forms/new_phone_form_spec.rb