-
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
Add nil check to serializer for invalid categories #16951
Conversation
@miq-bot add_label bug |
@@ -23,7 +23,7 @@ def serialize(dialog_field, all_attributes = false) | |||
|
|||
if dialog_field.type == "DialogFieldTagControl" | |||
category = Category.find_by(:id => dialog_field.category) | |||
dialog_field.options.merge!(:category_name => category.name, :category_description => category.description) | |||
dialog_field.options.merge!(:category_name => category.name, :category_description => category.description) if category.present? |
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.
The present?
shouldn't be necessary since find_by
will return either a record or nil
Checked commit d-m-u@60fde31 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Add nil check to serializer for invalid categories (cherry picked from commit 0e35ec3) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1542606
Gaprindashvili backport details:
|
Fixes issue with dialog editor not loading on import of dialogs with invalid tag controls.
Fixes 1/2 of https://bugzilla.redhat.com/show_bug.cgi?id=1540713
This bz is two issues: the editor won't load because https://github.com/ManageIQ/manageiq/blob/master/app/models/dialog_field_serializer.rb#L26 returns nil for non-valid categories which this PR fixes, and the editor doesn't correctly save changed, valid categories which is an editor problem (because I can replicate it with the import piece taken out, that is, creating a new dialog with a tag control that has a category, saving it, then editing that dialog and changing the category results in the new category not saving as it should.)