-
Notifications
You must be signed in to change notification settings - Fork 120
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
Check for both owner email and requester email for user quota. #230
Check for both owner email and requester email for user quota. #230
Conversation
@miq-bot add_label bug, fine/yes, gaprindashvili/yes, blocker |
@miq-bot assign @gmcculloug |
@tinaafitz Please Review |
0b4d3f9
to
b27ca56
Compare
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.
Overall this looks good, a few cleanup comments.
@@ -70,6 +85,6 @@ def merge_counts(quota_used, quota_active) | |||
end | |||
end | |||
|
|||
if __FILE__ == $PROGRAM_NAME | |||
if $PROGRAM_NAME == __FILE__ |
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.
@billfitzgerald0120 Is there any reason for this change? All other methods that use this line have it the original way and we should remain consistent.
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.
Rubocop didn't like this
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.
ah, yes. Yoda condition it is.
@@ -1,5 +1,5 @@ | |||
# frozen_string_literal: true | |||
# | |||
|
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.
😕 Why?
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.
Rubocop didn't like this
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.
For consistency with other methods I would just add a new-line instead of dropping the comment line:
# frozen_string_literal: true
#
# Description: calculate entity used quota values
#
@miq_provision_request.options[:owner_email] = owner_email | ||
@user.email = requester_email | ||
@miq_provision_request.save | ||
@user.save |
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.
You can update and save each of these objects in a single line.
@miq_provision_request.update(:options => @miq_provision_request.options.merge(:owner_email => owner_email))
@user.update(:email => requester_email)
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.
Changed
@user.save | ||
expect(svc_miq_request).to receive(:check_quota).with(active_method).and_return(active_counts_hash) | ||
described_class.new(ae_service).main | ||
expect(ae_service.root['quota_used']).to include(result_counts_hash) |
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.
Please add a new-line between the test setup and the expect
.
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.
Changed
it "when no owner or requester email" do | ||
@miq_provision_request.options[:owner_email] = nil | ||
@miq_provision_request.save | ||
expect { described_class.new(ae_service).main }.to raise_error(errormsg) |
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.
Same things for this test, Update/save in a single line and add a new-line between setup and expect.
it "when no owner or requester email" do
@miq_provision_request.update(:options => @miq_provision_request.options.merge(:owner_email => nil))
expect { described_class.new(ae_service).main }.to raise_error(errormsg)
end
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.
Changed
b27ca56
to
db64f00
Compare
@gmcculloug Made all changes as requested. Please Review |
db64f00
to
5ca8d0c
Compare
Changed used method to check for owner email or requester email when quota is set to user. Previously the method was only looking for owner_email and when that wasn't available we encountered an error. The method now will raise an error if both are not found. If you are running a service provision which doesn't allow a requester email and the user doesn't have an email address, we will raise this error: ERROR - Owner email not specified for User Quota Added tests for all possible email values for user quota. https://bugzilla.redhat.com/show_bug.cgi?id=1509977
5ca8d0c
to
784d666
Compare
Checked commit billfitzgerald0120@784d666 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
@billfitzgerald0120 Looks good.
Check for both owner email and requester email for user quota. (cherry picked from commit 25317bf) https://bugzilla.redhat.com/show_bug.cgi?id=1530644
Gaprindashvili backport details:
|
Check for both owner email and requester email for user quota. (cherry picked from commit 25317bf) https://bugzilla.redhat.com/show_bug.cgi?id=1531161
Fine backport details:
|
Changed used method to check for owner email or requester email when quota is set to user.
Previously the method was only looking for owner_email and when that wasn't available we encountered an error.
The method now will raise an error if both are not found. If you are running a service provision which doesn't allow a requester email
and the user doesn't have an email address, we will raise this error:
ERROR - Owner email not specified for User Quota
Added tests for all possible email values for user quota.
https://bugzilla.redhat.com/show_bug.cgi?id=1509977