Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't load BinaryBlobParts when determining if MiqReportResult is blank #19082

Merged
merged 1 commit into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_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)
Expand Down