From 0d6e97436173326912dd8fdd6e121bf8fed9ca53 Mon Sep 17 00:00:00 2001 From: Tina Fitzgerald Date: Mon, 8 Jan 2018 14:33:58 -0500 Subject: [PATCH] Prevent quota error for invalid service_template. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1531914 --- 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 267969ecabf..f64f06a22a1 100644 --- a/app/models/mixins/miq_provision_quota_mixin.rb +++ b/app/models/mixins/miq_provision_quota_mixin.rb @@ -319,6 +319,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 77b8894658d..9674e03c991 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