diff --git a/app/models/mixins/miq_provision_quota_mixin.rb b/app/models/mixins/miq_provision_quota_mixin.rb index b0c4c1cac71..267969ecabf 100644 --- a/app/models/mixins/miq_provision_quota_mixin.rb +++ b/app/models/mixins/miq_provision_quota_mixin.rb @@ -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) diff --git a/spec/models/miq_provision_request_spec.rb b/spec/models/miq_provision_request_spec.rb index a5aff39cfae..ce630f70b3e 100644 --- a/spec/models/miq_provision_request_spec.rb +++ b/spec/models/miq_provision_request_spec.rb @@ -266,6 +266,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 diff --git a/spec/models/service_template_provision_request_quota_spec.rb b/spec/models/service_template_provision_request_quota_spec.rb index 60663b423f4..77b8894658d 100644 --- a/spec/models/service_template_provision_request_quota_spec.rb +++ b/spec/models/service_template_provision_request_quota_spec.rb @@ -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