Skip to content
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

Merged
merged 8 commits into from
Jun 14, 2024

Conversation

javierm
Copy link
Member

@javierm javierm commented May 13, 2024

Objectives

  • Make it possible to remember what the Poll::Answer class does
  • Make it easier to add an association between poll question options and poll answers

Release notes

⚠️ In order to try to help developers to avoid losing their sanity, we've renamed the Poll::Question::Answer model to Poll::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

@javierm javierm self-assigned this May 13, 2024
@javierm javierm added this to Reviewing in Consul Democracy May 13, 2024
@javierm javierm force-pushed the rename_question_answer_to_option branch from 433ed8f to a4779f5 Compare May 13, 2024 23:20
@javierm javierm force-pushed the rename_question_answer_to_option branch from a4779f5 to 3284871 Compare May 17, 2024 20:50
@taitus taitus self-assigned this Jun 7, 2024
@javierm javierm force-pushed the rename_question_answer_to_option branch 2 times, most recently from 87540aa to 0e31139 Compare June 7, 2024 19:42
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.
We added the code indicating the table in commit 673ec07 because back
then we had a `title` column in both the `poll_question_answers` table
and the `poll_question_answer_translations` table.

Since that's no longer the case since commit 7a78776, we can simplify
the code.
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 javierm force-pushed the rename_question_answer_to_option branch 2 times, most recently from 5d5e5b2 to 785e0e4 Compare June 12, 2024 17:42
@javierm javierm force-pushed the rename_question_answer_to_option branch 4 times, most recently from 49ac93b to eb8b66b Compare June 13, 2024 14:50
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.
Since we've renamed the class to `Option`, having variables, methods and
texts refering to it as `answer` was confusing.
Since now poll question answers have been renamed to poll question
options, using HTML IDs, classes and data attributes named `answer` was
confusing.
@javierm javierm force-pushed the rename_question_answer_to_option branch from 8d6cece to 8420ea1 Compare June 13, 2024 17:13
Consul Democracy automation moved this from Reviewing to Testing Jun 13, 2024
The code for Poll::PairAnswer was removed in commit af7c376.
@javierm javierm force-pushed the rename_question_answer_to_option branch from 8420ea1 to ca8329d Compare June 13, 2024 17:38
@javierm javierm merged commit cd82a05 into master Jun 14, 2024
13 checks passed
Consul Democracy automation moved this from Testing to Release 2.2.0 Jun 14, 2024
@javierm javierm deleted the rename_question_answer_to_option branch June 14, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Consul Democracy
  
Release 2.2.0
Development

Successfully merging this pull request may close these issues.

None yet

2 participants