Skip to content

AO3-6956 Corrected error message for duplicate comments #5135

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

Merged
merged 8 commits into from
Apr 13, 2025

Conversation

Nick-Raal
Copy link
Contributor

@Nick-Raal Nick-Raal commented Apr 8, 2025

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6956

Purpose

This pull request changes the error message upon posting a duplicate comment from "This comment has already been left on this work. (It may not appear right away for performance reasons." to the more descriptive (and accurate) "You’ve already left this comment here. (It may not appear right away for performance reasons.)"

Credit

niic (he/him)

Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Nick!

Thank you so much for this pull request. I reviewed it with a suggestion for how to i18n the error message. Could you please also add a rspec test for the error message?

I've updated the Jira issue status to In Review, so no one will mistakenly create a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! You can just reply here with the account name and we'll set up the permissions for you. (It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME).")

Thanks again for contributing! If you have any questions, you can contact us at [email protected].

@@ -71,7 +71,7 @@ def check_for_spam
validates :comment_content, uniqueness: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can ignore rubocop's Rails/UniqueValidationWithoutIndex complaint, we don't need the unique index for now.

@Nick-Raal
Copy link
Contributor Author

Still need to fix the test. Don't worry about this right now.

@Nick-Raal Nick-Raal marked this pull request as draft April 8, 2025 09:07
@Nick-Raal
Copy link
Contributor Author

Nick-Raal commented Apr 8, 2025

I hard coded the test case in the spec, which is obviously not ideal. A similar method seems to have been done in the spec for kudos though, which is what I'm basing my decision to do the same in my spec on. I can't for the life of me get I18n to recognize the translation in the context of rspec, despite pouring over a lot of documentation. Either way, thank you so much for your suggestions and my username on Jira is Nick Raal.

@Nick-Raal Nick-Raal marked this pull request as ready for review April 8, 2025 21:14
Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded string is what we always use in tests, that's fine! This way we know that the translation is working.

I've given your Jira account permission to comment on, assign, and transition issues in the future.

expect(second_comment.valid?).to be_falsy
expect(second_comment.errors.attribute_names).to include(:comment_content)
expect(second_comment.errors.full_messages).to include("You've already left this comment here. (It may not appear right away for performance reasons.)")
Copy link
Contributor

@Bilka2 Bilka2 Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear I tested my suggestion locally, sorry about all the annoyances for your first PR 😭 The error is correct when displayed, so just do a partial match here in the test instead of a direct equal

@Nick-Raal Nick-Raal marked this pull request as draft April 10, 2025 08:21
@Nick-Raal Nick-Raal marked this pull request as ready for review April 10, 2025 08:29
@brianjaustin brianjaustin merged commit 720b95d into otwcode:master Apr 13, 2025
47 of 49 checks passed
weeklies pushed a commit to weeklies/otwarchive that referenced this pull request Apr 29, 2025
* AO3-6956 Corrected error message for duplicate comments

* Updated to match suggestions

* Added test case

* Aligned with formatting guidelines

* Fixed test

* Update config/locales/models/en.yml

Co-authored-by: Bilka <[email protected]>

* Updated rspec test to only use partial matching

* Normalized translations

---------

Co-authored-by: Bilka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants