-
Notifications
You must be signed in to change notification settings - Fork 898
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
Skip seeding of categories if their creation is invalid #16568
Skip seeding of categories if their creation is invalid #16568
Conversation
Warning: This is somewhat hacky and definitely an exception in what we've deemed 'standard practice' with our unusual seeding procedure. This change skips seeding of categories in the event that creating them would be invalid - and they would be invalid because people would like to use their own categories with the same name. Because categories here in seeding are looked up via name (delegated to tag), a new category with the same name is attempted to be made, fails silently, and gives a weird error when entries are attempted to be added to an initialized but unpersisted category record. https://bugzilla.redhat.com/show_bug.cgi?id=1507240
Checked commit chrisarcand@b093eda with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 app/models/classification.rb
spec/models/classification_spec.rb
|
Thanks @chrisarcand 👍 |
# This tests that if seeding category and it's invalid (due to uniqueness constraints) | ||
# then seeding still doesn't fail. | ||
cat = Classification.find_by!(:description => "Cost Center", :parent_id => 0) | ||
allow(YAML).to receive(:load_file).and_call_original |
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.
☝️ 😆 Good times.
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.
😬
Looks like code. |
Skip seeding of categories if their creation is invalid (cherry picked from commit 48846ec) https://bugzilla.redhat.com/show_bug.cgi?id=1519875
Gaprindashvili backport details:
|
Skip seeding of categories if their creation is invalid (cherry picked from commit 48846ec) https://bugzilla.redhat.com/show_bug.cgi?id=1523402
Fine backport details:
|
…-seeding Skip seeding of categories if their creation is invalid (cherry picked from commit 48846ec) https://bugzilla.redhat.com/show_bug.cgi?id=1523402
Warning: This is somewhat hacky and definitely an exception in what we've deemed 'standard practice' with our unusual seeding procedure.
This change skips seeding of categories in the event that creating them would be invalid - and they would be invalid because people would like to use their own categories with the same name. Because categories here in seeding are looked up via name (delegated to tag), a new category with the same name is attempted to be made, fails silently, and gives a weird error when entries are attempted to be added to an initialized but unpersisted category record.
https://bugzilla.redhat.com/show_bug.cgi?id=1507240
cc/ @jrafanie