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

Check for both owner email and requester email for user quota. #230

Merged
merged 1 commit into from
Dec 20, 2017

Conversation

billfitzgerald0120
Copy link
Contributor

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

@billfitzgerald0120
Copy link
Contributor Author

@miq-bot add_label bug, fine/yes, gaprindashvili/yes, blocker

@billfitzgerald0120
Copy link
Contributor Author

@miq-bot assign @gmcculloug

@billfitzgerald0120
Copy link
Contributor Author

@tinaafitz Please Review

Copy link
Member

@gmcculloug gmcculloug left a 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__
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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
#

Copy link
Member

Choose a reason for hiding this comment

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

😕 Why?

Copy link
Contributor Author

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

Copy link
Member

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
Copy link
Member

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)

Copy link
Contributor Author

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)
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@billfitzgerald0120
Copy link
Contributor Author

@gmcculloug Made all changes as requested. Please Review

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
@miq-bot
Copy link
Member

miq-bot commented Dec 19, 2017

Checked commit billfitzgerald0120@784d666 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Member

@tinaafitz tinaafitz left a comment

Choose a reason for hiding this comment

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

@billfitzgerald0120 Looks good.

@gmcculloug gmcculloug merged commit 25317bf into ManageIQ:master Dec 20, 2017
@gmcculloug gmcculloug added this to the Sprint 76 Ending Jan 1, 2018 milestone Dec 20, 2017
simaishi pushed a commit that referenced this pull request Jan 3, 2018
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
@simaishi
Copy link
Contributor

simaishi commented Jan 3, 2018

Gaprindashvili backport details:

$ git log -1
commit 9c904b621f5f20a7919bf271f90a3341057b496a
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Dec 20 09:19:11 2017 -0500

    Merge pull request #230 from billfitzgerald0120/user_quota_email
    
    Check for both owner email and requester email for user quota.
    (cherry picked from commit 25317bff448819df562122d670999db6b2813b94)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1530644

simaishi pushed a commit that referenced this pull request Jan 4, 2018
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
@simaishi
Copy link
Contributor

simaishi commented Jan 4, 2018

Fine backport details:

$ git log -1
commit 5bb99090f2599cbd7138047d5ad9698d17a4b588
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Dec 20 09:19:11 2017 -0500

    Merge pull request #230 from billfitzgerald0120/user_quota_email
    
    Check for both owner email and requester email for user quota.
    (cherry picked from commit 25317bff448819df562122d670999db6b2813b94)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1531161

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.

5 participants