-
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
Backup subject's name in case subject is removed #17871
Backup subject's name in case subject is removed #17871
Conversation
e05be1c
to
3f10f63
Compare
I like to be explicit on setters like this |
app/models/notification.rb
Outdated
@@ -40,6 +42,12 @@ def to_h | |||
} | |||
end | |||
|
|||
def backup_subject_name |
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.
Should this be private?
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.
Sure, I can make this private.
app/models/notification.rb
Outdated
def backup_subject_name | ||
return unless subject | ||
backup_name = (subject.try(:name) || subject.try(:description)) | ||
self.options[:subject] = backup_name if backup_name |
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.
Does options[:subject]
get used somewhere?
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.
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
3f10f63
to
e587c5c
Compare
Updated based on @bdunne's feedback. Thanks. |
Checked commit jrafanie@e587c5c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/models/notification.rb
|
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