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

AO3-6868 Add language form validation #5005

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

connie-feng
Copy link

@connie-feng connie-feng commented Dec 27, 2024

Pull Request Checklist

Issue

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

Purpose

This adds two form validations to the language form on the /languages/<language abbreviation/edit page:

  • validates that the display name is not a duplicate
  • validates that the abbreviation is 4 characters or fewer

Also:

  • added rake task to check for duplicate language names before running migrations
    • rake db:check_language_name_duplicates
  • fixed some existing tests that were failing on the new validations and rubocop

Testing Instructions

  1. Login as an admin
  2. Go to /languages
  3. Click Edit on any of the languages
  4. Change the display name to one that already exists
  5. Change the abbreviation to something with more than 5 characters
  6. Click Update Language and form validations should appear
Screenshot 2024-12-27 at 10 37 58 AM

Credit

Connie Feng, she/her
(JIRA account)

@github-actions github-actions bot added the Has Migrations Contains migrations and therefore needs special attention when deploying label Dec 27, 2024
@connie-feng connie-feng marked this pull request as draft December 27, 2024 17:31
@connie-feng connie-feng marked this pull request as ready for review December 27, 2024 18:56
@brianjaustin brianjaustin changed the title A03-6868 Add language form validation AO3-6868 Add language form validation Dec 27, 2024
Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

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

Hi, Connie, thanks for the pull request!

A couple small comments for you, and noting for myself that we'll want to run a query before the migration is run to check for duplicate language names. (If you feel confident in writing a Before rake task to do that, it would be helpful but the query should be easy by hand as well so don't worry about it either way!)

I've assigned the Jira issue to you and set its status to In Review so no one will mistakenly create a duplicate pull request. I've also given your account permission to comment on, assign, and transition issues in the future.

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

db/migrate/20241227165942_add_unique_index_to_languages.rb Outdated Show resolved Hide resolved
@Bilka2
Copy link
Contributor

Bilka2 commented Dec 27, 2024

Please revert the update to schema.rb, we prefer not to update the schema dump in unrelated PRs (refer to #4677).

@connie-feng
Copy link
Author

Please revert the update to schema.rb, we prefer not to update the schema dump in unrelated PRs (refer to #4677).

Hi @Bilka2! I've reverted the update to schema.rb, but it does cause rubocop to fail (example: https://github.com/otwcode/otwarchive/actions/runs/12519083042) -- should I disable rubocop for those specific lines?

@connie-feng
Copy link
Author

Hi, Connie, thanks for the pull request!

A couple small comments for you, and noting for myself that we'll want to run a query before the migration is run to check for duplicate language names. (If you feel confident in writing a Before rake task to do that, it would be helpful but the query should be easy by hand as well so don't worry about it either way!)

Hi @brianjaustin -- thanks! I will add the Before rake task :)

@Bilka2
Copy link
Contributor

Bilka2 commented Dec 28, 2024

Hi @Bilka2! I've reverted the update to schema.rb, but it does cause rubocop to fail (example: https://github.com/otwcode/otwarchive/actions/runs/12519083042) -- should I disable rubocop for those specific lines?

You technically fixed the failure with the migration so it's fine to just keep it enabled. We'll ignore the failure when reviewing this PR since it's clear that it was addressed.

Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

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

Thanks for the rake task! Just 1 thing I missed on my first review, otherwise looks good!

app/models/language.rb Outdated Show resolved Hide resolved
Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Migrations Contains migrations and therefore needs special attention when deploying Priority: Low Reviewed: Ready to Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants