-
Notifications
You must be signed in to change notification settings - Fork 26
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
Bad search names #2714
Open
JoeCohen
wants to merge
27
commits into
main
Choose a base branch
from
jdc-2712-indistinct-search_names
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
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.
Open
Bad search names #2714
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
- Prevents saving Name if an indistinct Name already exists - Adds an error message - Temporarily ignores Names without `search_name`
- Revises `create_test_name` utility to update an existing name instead creating an indistinct one - Refactors test_name_spaceship_operator for clarity and non-circularity
30 tasks
- Prevents intermitten failure of test_getting_names_ok_for_export [Example](https://github.com/MushroomObserver/mushroom-observer/actions/runs/13270003060/job/37046955064) ```ruby Minitest::UnexpectedError: ActiveRecord::RecordInvalid: Validation failed: Search name Equivalent name exists Macrocybe test/classes/api2/names_test.rb:259:in `test_getting_names_ok_for_export' ```
- Using `sample` invites intermittent failures. Example: https://github.com/MushroomObserver/mushroom-observer/actions/runs/13270003060/job/37046955064 ```ruby Minitest::UnexpectedError: ActiveRecord::RecordInvalid: Validation failed: Search name Equivalent name exists Macrocybe test/classes/api2/names_test.rb:259:in `test_getting_names_ok_for_export' ``` - As far as I can tell the only function of the removed line is to insures that there's a correctly spelled Name that's ok for export.
No longer needed because - Each fixture & test case has a `search_name` - There's now a validation for `search_name` presence.
- Gathers macros & methods per attribute - revises metod names to reveal intent and for consistency
- better flash error - additional, dryer test case
- Requires author to end only in a (letter or period) plus optional space(s). - Breaks two tests. Both deal with the old style intrageneric Names.
- Both tests deal with merger of old-style infra-generic Names. No such such Names exist in the db: ```ruby foo = Name.where(Name[:author] =~ /\(.*Genus.*\)$/) Name Load (88.1ms) SELECT `names`.* FROM `names` WHERE `names`.`author` REGEXP '\\(.*Genus.*\\)$' /* loading for pp */ LIMIT 11 => [] ```
This Error below occurs only during CI, only during the PR run (and not in the Push run). The fix was suggested by ChatGPT ``` Run bundle exec rake db:schema:load bundle exec rake db:schema:load bundle exec rake db:fixtures:load shell: /usr/bin/bash -e {0} rake aborted! NoMethodError: private method `t' called for an instance of Symbol (NoMethodError) message: :validate_name_author_characters.t ^^ /home/runner/work/mushroom-observer/mushroom-observer/app/models/name.rb:429:in `<class:Name>' /home/runner/work/mushroom-observer/mushroom-observer/app/models/name.rb:331:in `<top (required)>' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require' /home/runner/work/mushroom-observer/mushroom-observer/app/models/comment.rb:115:in `<class:Comment>' /home/runner/work/mushroom-observer/mushroom-observer/app/models/comment.rb:107:in `<top (required)>' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/inflector/methods.rb:290:in `const_get' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/inflector/methods.rb:290:in `constantize' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/inflector/methods.rb:316:in `safe_constantize' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activesupport-7.2.2.1/lib/active_support/core_ext/string/inflections.rb:87:in `safe_constantize' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:803:in `default_fixture_model_class' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:793:in `block (2 levels) in read_fixture_files' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixture_set/file.rb:16:in `open' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:791:in `block in read_fixture_files' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:790:in `each' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:790:in `each_with_object' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:790:in `read_fixture_files' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:721:in `initialize' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:653:in `new' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:653:in `block in read_and_insert' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:651:in `map' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:651:in `read_and_insert' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/fixtures.rb:607:in `create_fixtures' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/railties/databases.rake:434:in `block (3 levels) in <top (required)>' /home/runner/work/mushroom-observer/mushroom-observer/vendor/bundle/ruby/3.3.0/gems/rake-13.2.1/exe/rake:27:in `<top (required)>' /opt/hostedtoolcache/Ruby/3.3.6/x64/bin/bundle:25:in `load' /opt/hostedtoolcache/Ruby/3.3.6/x64/bin/bundle:25:in `<main>' Tasks: TOP => db:fixtures:load ```
|
Seems good to me. In favor of more validations on the model. The class needs refactoring. A lot of |
- Add an assertion - Fix a comment - Improve some assert messages
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.
search_name
author
ends in a bad character. (Can end only in a letter or period.)author
contains a bad character. See my comment below.Some Manual Tests
L
:Boletus L
Expected Result: Redisplays form with flash: "Unable to save changes. Equivalent name exists: Boletus L. (14925)"
Expected Result: Flash error: "Unable to save changes. Name author must end only in a letter or period." Author field is emphasized with red border.
Expected Result: Flash error: "Unable to save changes. Name author must end only in a letter or period." Author field is emphasized with red border.
Note: An author in the form
(Blah)
is incorrect. Parens enclose the author of the basionym, so(Blah)
is missing the names of the authors of the re-classified name, or -- if it hasn't been reclassified -- there should be no parens.