diff --git a/app/models/miq_report_result.rb b/app/models/miq_report_result.rb index a513e3c7236..9aa09a69e9e 100644 --- a/app/models/miq_report_result.rb +++ b/app/models/miq_report_result.rb @@ -73,7 +73,16 @@ def status if miq_task miq_task.human_status else - report_results.blank? ? "Error" : "Complete" + report_results_blank? ? "Error" : "Complete" + end + end + + # This method doesn't run through all binary blob parts to determine if it has any + def report_results_blank? + if binary_blob + binary_blob.parts.zero? + elsif report.kind_of?(MiqReport) + report.blank? end end diff --git a/spec/models/miq_report_result_spec.rb b/spec/models/miq_report_result_spec.rb index d7262e1c5d9..9580a15a187 100644 --- a/spec/models/miq_report_result_spec.rb +++ b/spec/models/miq_report_result_spec.rb @@ -190,6 +190,25 @@ end end + describe '#report_results_blank?' do + let(:report_result) { FactoryBot.create(:miq_report_result) } + subject { report_result.report_results_blank? } + + context 'report has a binary blob' do + let(:binary_blob) { FactoryBot.create(:binary_blob) } + before { report_result.binary_blob = binary_blob } + + context 'binary blob is empty' do + it { is_expected.to be_truthy } + end + + context 'binary blob has parts' do + before { binary_blob.binary = "foo" } + it { is_expected.to be_falsey } + end + end + end + describe "serializing and deserializing report results" do it "can serialize and deserialize an MiqReport" do report = FactoryBot.build(:miq_report)