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

Correctly recurse over nested field associations #18890

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Jun 18, 2019

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1720617

This originally caught (and returned) only the first of multiple nested fields that are linked via the dialog associations:
[fieldname_being_triggered, associations[fieldname_being_triggered].first]
and that's wrong, see the test case which was distilled straight from the bug.

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 18, 2019

@miq-bot add_label bug
@miq-bot assign @tinaafitz
@miq-bot add_reviewer @eclarizio

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 18, 2019

@miq-bot add_label hammer/yes

@miq-bot miq-bot added the bug label Jun 18, 2019
@miq-bot miq-bot requested a review from eclarizio June 18, 2019 17:49
@d-m-u d-m-u force-pushed the fixing_field_association_recursion branch 2 times, most recently from 1f8cd07 to 2ece9be Compare June 18, 2019 18:13
@miq-bot
Copy link
Member

miq-bot commented Jun 18, 2019

Checked commit d-m-u@2ece9be with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

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

👍

path.flatten!
fieldname_being_triggered = path.last
while associations[fieldname_being_triggered]
return [fieldname_being_triggered, (path & associations[fieldname_being_triggered]).first] if (path & associations[fieldname_being_triggered]).present?
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if this is useful, but maybe we extract path & associations[fieldname_being_triggered] into a local variable? & is already pretty performant as far as I know, so even if both of the arrays are large that shouldn't be a big deal, it would really just be to understand exactly what path & associations[fieldname_being_triggered] represents.

It's not necessary though, I'm going to approve regardless.

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 19, 2019

@bdunne any chance i could also con you into merging this one, please?

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 25, 2019

can i get someone to review this or whatever again please

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

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

@d-m-u Did something else change? I don't see anything that looks out of place. 👍

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 25, 2019

sorry, Erik, nothing changed, I just, no one other than you's looking at this and I'd like to get it in

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 26, 2019

@bdunne please review

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 26, 2019

@tinaafitz please review

@d-m-u d-m-u force-pushed the fixing_field_association_recursion branch from 2ece9be to 186004f Compare June 27, 2019 13:18
@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 28, 2019

hey @bdunne I'm getting asked to speed this one up, could you please review?

@d-m-u d-m-u force-pushed the fixing_field_association_recursion branch 2 times, most recently from de87e95 to d0d7941 Compare June 28, 2019 13:15
Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

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

👍 LGTM. This looks much simpler. Thanks for taking this on!

@bdunne
Copy link
Member

bdunne commented Jun 28, 2019

@eclarizio can you re-review?

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

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

All of your it block names seem kind of weird, they don't really describe what the test is testing (it "false" and then the test is ensuring the return value is nil? or that it doesn't blow up? You have two it "trivial case" blocks, one of them is expecting a nil return and the other is expecting an error), but as far as the actual code goes, it looks good to me.

Is there a reason we got rid of the specs in dialog_import_validator_spec.rb around the circular reference stuff though?

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 28, 2019

Sure, I mean, since I'm not raising in the import validator any longer, the dialog_field_association_validator test cases handle the error stuff and I'm not sure what the import validator is supposed to be testing now.

@d-m-u d-m-u force-pushed the fixing_field_association_recursion branch from d0d7941 to 65b0e26 Compare June 28, 2019 16:10
@eclarizio
Copy link
Member

Sure, I mean, since I'm not raising in the import validator any longer, the dialog_field_association_validator test cases handle the error stuff and I'm not sure what the import validator is supposed to be testing now.

True, the error handling isn't there anymore, but right now you could comment out the entire line that delegates to the circular reference checker and the tests would all still pass because nothing is ensuring we go in there, I think.

I think either a spec should be added to ensure work is being delegated to it, or maybe you feed it a circular reference and allow it to run through and bubble up expecting the error.

@d-m-u d-m-u force-pushed the fixing_field_association_recursion branch from 65b0e26 to efa01bf Compare June 28, 2019 17:24
@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 28, 2019

Could I get you all to look again at this, please? It's subject to escalation at the moment

@d-m-u
Copy link
Contributor Author

d-m-u commented Jun 28, 2019

@lfu @bdunne @jrafanie @eclarizio
I don't know who else to ask for review but this needs in pronto

@bdunne bdunne merged commit b7f78ba into ManageIQ:master Jun 28, 2019
@bdunne bdunne added this to the Sprint 115 Ending Jul 8, 2019 milestone Jun 28, 2019
@bdunne bdunne assigned bdunne and unassigned tinaafitz Jun 28, 2019
d-m-u added a commit to d-m-u/manageiq-ui-classic that referenced this pull request Jul 1, 2019
simaishi pushed a commit that referenced this pull request Jul 1, 2019
Correctly recurse over nested field associations

(cherry picked from commit b7f78ba)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1725894
@simaishi
Copy link
Contributor

simaishi commented Jul 1, 2019

Hammer backport details:

$ git log -1
commit 8bffceb80bcd559bd723b127965f340b5a7e299b
Author: Brandon Dunne <[email protected]>
Date:   Fri Jun 28 16:03:23 2019 -0400

    Merge pull request #18890 from d-m-u/fixing_field_association_recursion
    
    Correctly recurse over nested field associations
    
    (cherry picked from commit b7f78ba0696d2d7f60d1175727276b8cd2c3cb27)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1725894

d-m-u added a commit to d-m-u/manageiq-ui-classic that referenced this pull request Jul 1, 2019
@d-m-u d-m-u deleted the fixing_field_association_recursion branch September 26, 2019 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants