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

Fixes #7665 - added manage command to user mail notifications #513

Merged
merged 1 commit into from
May 14, 2020

Conversation

yifatmakias
Copy link
Contributor

This PR is blocked by another PR:
theforeman/foreman#7549

@yifatmakias
Copy link
Contributor Author

@shiramax @ofedoren Now that the API changes are merged can you review this PR?

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Thanks, @yifatmakias for keeping this going! Commands seem to be working.

Few inline suggestions though.

lib/hammer_cli_foreman/user_mail_notification.rb Outdated Show resolved Hide resolved
lib/hammer_cli_foreman/user_mail_notification.rb Outdated Show resolved Hide resolved
lib/hammer_cli_foreman/user_mail_notification.rb Outdated Show resolved Hide resolved
field :name, _('Name')
field :description, _('Description')
field :interval, _('Interval')
field :mail_query, _('Mail query') unless :mail_query.nil?
Copy link
Member

Choose a reason for hiding this comment

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

What exactly you want to achieve here?

:mail_query.nil? is always false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only with one type of mail notification, there is a mail query field so I thought this way it will show the field only when it is relevant. In a second check, the column will appear all the time, if there is a mail query it will appear in the column, if not it will be empty.
long story short - I removed the unless part it was redundant.

@@ -0,0 +1,32 @@
require File.join(File.dirname(__FILE__), 'test_helper')

Copy link
Member

Choose a reason for hiding this comment

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

❤️

I'd also prefer to write just one test per PR, but if we've got updated test data and more than one command, then it will be nice to cover them as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added more tests to all of the commands. You are definitely right there should be at least one test to each command.

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Thanks, @yifatmakias! Few more little nitpicks and I stop bothering you :D

lib/hammer_cli_foreman/user_mail_notification.rb Outdated Show resolved Hide resolved
lib/hammer_cli_foreman/user_mail_notification.rb Outdated Show resolved Hide resolved
lib/hammer_cli_foreman/user_mail_notification.rb Outdated Show resolved Hide resolved
field :name, _('Name')
field :description, _('Description')
field :interval, _('Interval')
field :mail_query, _('Mail query')
Copy link
Member

Choose a reason for hiding this comment

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

Actually, if you want to hide mail_query field you can specify hide_blank option:
field :mail_query, _('Mail query'), Fields::Field, hide_blank: true. This will hide the field if value for it is nil. Although it doesn't work for table output. So, it's up to you whether have it or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a reason to add this if it does not work for table output. Do you?

Copy link
Member

Choose a reason for hiding this comment

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

Well, it works for base, csv and other outputs, which are used more for automation purposes. I don't see much usage of this option in the project anyway, so we can leave it as it is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me :)

@ofedoren
Copy link
Member

Thanks, @yifatmakias! All seems to be ready for merge, so merging this one.

@ofedoren ofedoren merged commit 4bcbcd7 into theforeman:master May 14, 2020
ofedoren pushed a commit that referenced this pull request May 29, 2020
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