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

Backup subject's name in case subject is removed #17871

Conversation

jrafanie
Copy link
Member

Fixes a bug where notifications look like the following if the subject
vm has been removed:

'Virtual Machine %{subject} has been provisioned.'

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

@jrafanie jrafanie force-pushed the backup_notification_subject_in_case_subject_removed branch from e05be1c to 3f10f63 Compare August 17, 2018 01:50
@jrafanie
Copy link
Member Author

  • Line 48, Col 5 - Style/RedundantSelf - Redundant self detected.

I like to be explicit on setters like this

@@ -40,6 +42,12 @@ def to_h
}
end

def backup_subject_name
Copy link
Member

Choose a reason for hiding this comment

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

Should this be private?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can make this private.

def backup_subject_name
return unless subject
backup_name = (subject.try(:name) || subject.try(:description))
self.options[:subject] = backup_name if backup_name
Copy link
Member

Choose a reason for hiding this comment

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

Does options[:subject] get used somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, it's quite non-obvious.

The UI calls #to_h. This calls text_bindings which calls text_bindings_dynamic which walks options key/values and will be used when the subject (vm or thing the notification is based on) is no longer existing. See line 90 👇

I was debating rewriting this to make this more clear but the changes were too complicated for this bug fix.

Fixes a bug where notifications look like the following if the subject
vm has been removed:

'Virtual Machine %{subject} has been provisioned.'

https://bugzilla.redhat.com/show_bug.cgi?id=1469372
@jrafanie jrafanie force-pushed the backup_notification_subject_in_case_subject_removed branch from 3f10f63 to e587c5c Compare August 21, 2018 01:27
@jrafanie
Copy link
Member Author

Updated based on @bdunne's feedback. Thanks.

@miq-bot
Copy link
Member

miq-bot commented Aug 21, 2018

Checked commit jrafanie@e587c5c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 1 offense detected

app/models/notification.rb

@bdunne bdunne merged commit 11229c9 into ManageIQ:master Aug 21, 2018
@bdunne bdunne self-assigned this Aug 21, 2018
@bdunne bdunne added this to the Sprint 93 Ending Aug 27, 2018 milestone Aug 21, 2018
@jrafanie jrafanie deleted the backup_notification_subject_in_case_subject_removed branch August 21, 2018 15:59
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.

3 participants