From 7de622587cc1a162178b6ccf9d78f2188522d3f9 Mon Sep 17 00:00:00 2001 From: Greg McCullough Date: Tue, 9 Jan 2018 15:30:37 -0500 Subject: [PATCH] Merge pull request #16769 from tinaafitz/quota_mixin_service_template_fix Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template. (cherry picked from commit 8aa881f53bfa3ae2517921bbd061d82d01ccd600) https://bugzilla.redhat.com/show_bug.cgi?id=1534589 --- app/models/mixins/miq_provision_quota_mixin.rb | 1 + .../models/service_template_provision_request_quota_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/models/mixins/miq_provision_quota_mixin.rb b/app/models/mixins/miq_provision_quota_mixin.rb index 7a194cbf5ce..e175a62712d 100644 --- a/app/models/mixins/miq_provision_quota_mixin.rb +++ b/app/models/mixins/miq_provision_quota_mixin.rb @@ -320,6 +320,7 @@ def vm_quota_values(pr, result) end def service_quota_values(request, result) + return unless request.service_template request.service_template.service_resources.each do |sr| if request.service_template.service_type == 'composite' bundle_quota_values(sr, result) diff --git a/spec/models/service_template_provision_request_quota_spec.rb b/spec/models/service_template_provision_request_quota_spec.rb index d80f88fd954..766b314ebf0 100644 --- a/spec/models/service_template_provision_request_quota_spec.rb +++ b/spec/models/service_template_provision_request_quota_spec.rb @@ -104,6 +104,12 @@ def create_service_bundle(user, items, options = {}) context "active_provisions_by_tenant," do let(:quota_method) { :active_provisions_by_tenant } it_behaves_like "check_quota" + + it "invalid service_template does not raise error" do + requests = load_queue + requests.first.update_attributes(:service_template => nil) + expect { request.check_quota(quota_method) }.not_to raise_error + end end context "active_provisions_by_group," do