Skip to content

Commit

Permalink
Don't load BinaryBlobParts when determining if MiqReportResult is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jul 31, 2019
1 parent 4082da3 commit 24ce8f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/models/miq_report_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions spec/models/miq_report_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@
end
end

describe '#report_results_blank?' do
let(:report_result) { FactoryBot.create(:miq_report_result) }
subject { report_result.report_result_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.data = "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)
Expand Down

0 comments on commit 24ce8f4

Please sign in to comment.