Skip to content

Commit

Permalink
Merge pull request ManageIQ#16693 from tinaafitz/miq_provision_email_fix
Browse files Browse the repository at this point in the history
Fix email issue in miq_provision_quota_mixin active_provision by_owner method.
(cherry picked from commit 748ba9b)

https://bugzilla.redhat.com/show_bug.cgi?id=1531161
  • Loading branch information
gmcculloug authored and d-m-u committed Jun 6, 2018
1 parent c5f47b2 commit 545839d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/models/mixins/miq_provision_quota_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ def quota_find_prov_request_by_group(options)
end

def quota_find_active_prov_request_by_owner(options)
email = get_option(:owner_email).to_s.strip
quota_find_active_prov_request(options).select { |p| email.casecmp(p.request_owner_email(p)).zero? }
quota_find_active_prov_request(options).select { |p| request_owner_email(self).casecmp(p.request_owner_email(p)).zero? }
end

def request_owner_email(request)
service_request?(request) ? request.requester.email : request.get_option(:owner_email).to_s.strip
service_request?(request) ? request.requester.email : request.get_option(:owner_email)
end

def service_request?(request)
Expand Down
6 changes: 6 additions & 0 deletions spec/models/miq_provision_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ def queue(requests)
{:count => 4, :memory => 4.gigabytes, :cpu => 8, :storage => 2.gigabytes}
end
it_behaves_like "check_quota"

it "fails without owner_email option" do
load_queue
request.options = {}
expect { request.check_quota(quota_method) }.to raise_error(NoMethodError)
end
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/models/service_template_provision_request_quota_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def create_service_bundle(user, items, options = {})
{:count => 3, :memory => 3.gigabytes, :cpu => 8, :storage => 1_610_612_736}
end
it_behaves_like "check_quota"

it "fails without requester.email" do
load_queue
@vmware_user1.update_attributes(:email => nil)
expect { request.check_quota(quota_method) }.to raise_error(NoMethodError)
end
end
end

Expand Down

0 comments on commit 545839d

Please sign in to comment.