-
Notifications
You must be signed in to change notification settings - Fork 897
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
Tags without a classification cause errors #18177
Tags without a classification cause errors #18177
Conversation
@miq-bot add_label bug, gaprindashvili/yes |
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.
@juliancheal This looks good but it would be best to add a quick test with a tag without a classification before merging
@gtanzillo Yes sure, meant to ask you about that yesterday. |
@miq-bot add_label blocker |
@juliancheal please also add the hammer/yes label |
@miq-bot add_label hammer/yes |
Higher level question... Why would a tag not have a classification? That seems like a case that shouldnt happen. cc @kbrock as I know you've looked at this from a performance perspective before |
@juliancheal can you also fix the rubocop issue? |
@Fryguy Right, we shouldn't but from the BZ they do. |
Tests for situations where classification is nil, yet tag.show is true
cc0b8d5
to
8bb45d6
Compare
Checked commits juliancheal/manageiq@7a2aad3~...8bb45d6 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
To summarise the offline conversation I had with @gtanzillo. The customer has a situation where they have However at the same time, there is no This "fix" makes it so the code doesn't 💣 out, but it would be good to find the reason we're in this situation. |
I was facing with this cases on CUs's DBs also (#17883) |
@Fryguy ugh - late to the party Maybe the custom attribute stuff? |
…ations_errors Tags without a classification cause errors (cherry picked from commit 3217a89) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1632901
Hammer backport details:
|
…ations_errors Tags without a classification cause errors (cherry picked from commit 3217a89) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1648948
Gaprindashvili backport details:
|
@@ -103,6 +103,18 @@ | |||
expect(categorization).to eq(expected_categorization) | |||
end | |||
|
|||
it "tag with nil classification" do | |||
@tag.classification = nil |
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.
Shouldn't this have been @tag.classification.delete
?
If I do this and issue @tag.reload
, I get:
1) Tag categorization tag with nil classification
Failure/Error: expect(@tag.show).to eq(true)
expected: true
got: nil
(compared using ==)
# ./spec/models/tag_spec.rb:117:in `block (3 levels) in <top (required)>'
Note, I'm here because rails 5.0 looks to have been returning a cached classification when @tag.categorization
calls @tag.category
in show
. Because this was failing, I changed my tests locally to do @tag.classification.delete
and it fails as shown above in both rails 5.0 and 5.1.
I'm not sure how any of the @category
expectations are set, such as @category.name
below:
To get to the category, you need to navigate through using @tag.classification.parent
(what category does I think). If the classification is nil or deleted, category should also be nil, which would cause show
to be nil.
😕
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.
In other words, I believe we're relying on @tag.category
to return the cached parent of the classification's parent. If you delete the classification, it fails. If you upgrade to rails 5.1, the classification is nil so the category (classification parent) is also nil.
I believe this test is wrong. I think.
…lassifications_errors Tags without a classification cause errors (cherry picked from commit 3217a89) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1648948
This fixes BZ https://bugzilla.redhat.com/show_bug.cgi?id=1632901