-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Rename Poll::Question::Answer to Poll::Question::Option #5537
Open
javierm
wants to merge
6
commits into
master
Choose a base branch
from
rename_question_answer_to_option
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+774
−758
Conversation
This file contains 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
javierm
force-pushed
the
rename_question_answer_to_option
branch
from
May 13, 2024 23:20
433ed8f
to
a4779f5
Compare
javierm
force-pushed
the
rename_question_answer_to_option
branch
from
May 17, 2024 20:50
a4779f5
to
3284871
Compare
javierm
force-pushed
the
rename_question_answer_to_option
branch
2 times, most recently
from
June 7, 2024 19:42
87540aa
to
0e31139
Compare
We were using three different variable names for the same thing, in consecutite tests.
Not sure about when we stopped needing them, but all usages of require_dependency definitely become obsolete after we started using Zeitwerk in commit 5f24ee9. We're also going to rename `Poll::Question::Answer` to `Poll::Question::Option`, so the conflict of having two `Answer` classes, that made us add this code in the first place, will not even exist.
Just like we do every else (sometimes even on that very same file), we use the method instead of the instance variable. We're doing this change now because we're about to modify one of these files (the poll question answers documents index component).
javierm
force-pushed
the
rename_question_answer_to_option
branch
2 times, most recently
from
June 12, 2024 17:42
5d5e5b2
to
785e0e4
Compare
|
||
describe "#polls_link" do | ||
it "is marked as current when managing poll options", | ||
controller: Admin::Poll::Questions::OptionsController 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.
Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent)
Suggested change
controller: Admin::Poll::Questions::OptionsController do | |
controller: Admin::Poll::Questions::OptionsController do |
Having a class named `Poll::Question::Answer` and another class named `Poll::Answer` was so confusing that no developer working on the project has ever been capable of remembering which is which for more than a few seconds. Furthermore, we're planning to add open answers to polls, and we might add a reference from the `poll_answers` table to the `poll_question_answers` table to property differentiate between open answers and closed answers. Having yet another thing named answer would be more than what our brains can handle (we know it because we did this once in a prototype). So we're renaming `Poll::Question::Answer` to `Poll::Question::Option`. Hopefully that'll make it easier to remember. The name is also (more or less) consistent with the `Legislation::QuestionOption` class, which is similar. We aren't changing the table or columns names for now in order to avoid possible issues when upgrading (old code running with the new database tables/columns after running the migrations but before deployment has finished, for instance). We might do it in the future. I've tried not to change the internationalization keys either so existing translations would still be valid. However, since we have to change the keys in `activerecord.yml` so methods like `human_attribute_name` keep working, I'm also changing them in places where similar keys were used (like `poll_question_answer` or `poll/question/answer`). Note that it isn't clear whether we should use `option` or `question_option` in some cases. In order to keep things simple, we're using `option` where we were using `answer` and `question_option` where we were using `question_answer`. Also note we're adding tests for the admin menu component, since at first I forgot to change the `answers` reference there and all tests passed.
javierm
force-pushed
the
rename_question_answer_to_option
branch
from
June 12, 2024 18:17
785e0e4
to
6cb3c14
Compare
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.
Objectives
Poll::Answer
class doesRelease notes
Poll::Question::Answer
model toPoll::Question::Option
. If you've got some custom codes dealing with polls, you might have to update it. For now, we are not renaming the related database tables in order to make the upgrade easier.Sponsored
Functionality developed by