Skip to content

Commit

Permalink
Merge pull request #1464 from sanger/dpl-812-2-missing-values-fix
Browse files Browse the repository at this point in the history
DPL-812.2: repair undefined method 'value' for nil:NilClass
  • Loading branch information
StephenHulme authored Nov 16, 2023
2 parents 01ae90e + 495c056 commit 979a6ed
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/views/exports/pbmc_bank_tubes_content_report.csv.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
child_tube_v2.barcode, # FluidX barcode
child_tube_v2.created_at, # Extraction and freeze date
destination, # Sequencing or contingency
source_well.latest_live_cell_count.value, # Cell count
source_well.latest_cell_viability.value, # Viability
source_well.latest_live_cell_count&.value, # Cell count
source_well.latest_cell_viability&.value, # Viability
volume, # Volume
source_well.aliquots.first.study.name, # Study name
source_well.aliquots.first.sample.sample_metadata&.collected_by # Collection site
Expand Down
36 changes: 36 additions & 0 deletions spec/views/exports/pbmc_bank_tubes_content_report.csv.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,42 @@
CSV.parse(render).each { |row| expect(row).to eq(expected_content.shift) }
end

context 'when some data is missing' do
# qc results, no viability_qc
let(:live_cell_count_qc) { create(:qc_result, key: 'live_cell_count', value: nil, units: 'cells/ml') }
let(:qc_results) { [live_cell_count_qc] }

# expected file content
let(:expected_content) do
[
['Workflow', workflow_name],
[],
[
'Well name',
'Donor ID',
'Stock barcode',
'FluidX barcode',
'Extraction and freeze date',
'Sequencing or contingency',
'Cell count (cells/ml)',
'Viability (%)',
'Volume (µl)',
'Study name',
'Collection site'
],
['DN1S:A1', 'Donor1', 'NT1O', 'FX4B', created_at, 'Sequencing', '', '', '135', study_name, 'Sanger'],
['DN1S:B1', '', 'NT2P', 'FX7E', created_at, 'Sequencing', '', '', '135', study_name, 'Sanger'],
['DN1S:A2', 'Donor1', 'NT1O', 'FX5C', created_at, 'Contingency', '', '', '135', study_name, 'Sanger'],
['DN1S:B2', '', 'NT2P', 'FX8F', created_at, 'Contingency', '', '', '135', study_name, 'Sanger'],
['DN1S:A3', 'Donor1', 'NT1O', 'FX6D', created_at, 'Contingency', '', '', '135', study_name, 'Sanger'],
['DN1S:B3', '', 'NT2P', 'FX9G', created_at, 'Contingency', '', '', '135', study_name, 'Sanger']
]
end
it 'shows blanks in the missing columns, row by row' do
CSV.parse(render).each { |row| expect(row).to eq(expected_content.shift) }
end
end

context 'when transfers are not done yet' do
# source wells
let(:src_well_a1) { create(:v2_well, location: 'A1', aliquots: [src_aliquot1_s1], downstream_tubes: []) }
Expand Down

0 comments on commit 979a6ed

Please sign in to comment.