-
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
Ancestry Patch updates/fixes #17511
Ancestry Patch updates/fixes #17511
Conversation
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.
Lookin good
app/models/tenant.rb
Outdated
@@ -184,7 +184,7 @@ def project? | |||
end | |||
|
|||
def visible_domains | |||
MiqAeDomain.where(:tenant_id => ancestor_ids.append(id)).joins(:tenant).order('tenants.ancestry DESC NULLS LAST, priority DESC') | |||
MiqAeDomain.where(:tenant_id => ancestor_ids + [id]).joins(:tenant).order('tenants.ancestry DESC NULLS LAST, priority DESC') |
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.
Think path_ids
is what we want.
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.
Didn't know it was a thing. Will change.
|
||
def parent=(parent) | ||
super | ||
clear_memoized_instance_variables |
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.
would feel a little more comfortable returning the original value since people often type x = y = z
def parent=(parent)
super.tap { clear_memoized_instance_variables }
end
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.
Huh, I guess ruby had my back on this one...
class Foo
attr_reader :bar
def bar= bar_val
@bar = bar_val
puts "IT WORKED!"
end
end
puts (Foo.new.bar = "bar")
puts baz = Foo.new.bar = "baz"
puts "baz = #{baz}"
#=> IT WORKED! <<<<< output from first bar=
#=> bar <<<<< output from first inline puts
#=> IT WORKED! <<<<< output from second bar=
#=> baz <<<<< output from second inline puts
#=> baz = baz <<<<< output from third inline puts
Apparently =
's methods don't behave the same as normal methods and always return the input? TMYK 🌈✨🌠
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.
Anyway, adding a test because this could end up going bad if this is ever NOT the case.
The Tenant#visible_domains method was doing the following: ancestor_ids.append(id) As part of it's query, which would update the memoized value to be incorrect and include itself. Switching it to `path_ids`, which effectively does: ancestor_ids + [id] Makes sure that a new array is created instead of appending to the existing one.
9dc3839
to
3742661
Compare
Clear out the memoization in the lib/patches/ancestry_patch.rb when the parent= or parent_id= methods are called.
@kbrock Should have addressed your comments. Please re-review. |
Checked commits NickLaMuro/manageiq@f75a572~...3742661 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 spec/models/tenant_spec.rb
|
Ancestry Patch updates/fixes (cherry picked from commit c6a6bed) https://bugzilla.redhat.com/show_bug.cgi?id=1593798
Fine backport details:
|
Ancestry Patch updates/fixes (cherry picked from commit c6a6bed) https://bugzilla.redhat.com/show_bug.cgi?id=1593797
Gaprindashvili backport details:
|
Fixes the two issues reported in the original PR for the
ancestry
patches and the memoization of certain methods around it:parent
/parent_id
inmanageiq-ui-classic
: Ancestry Patches #17360 (comment)ancestor_ids
inmanageiq-automation_engine
: Ancestry Patches #17360 (comment)Both issues should be addressed by this PR.
Links
Steps for Testing/QA
Run the specs for both
manageiq-ui-classic
andmanageiq-automation_engine
with this branch checked out and make sure there are not any spec failures.