-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1595 from sanger/DPL-1054-Add-Vac-tube-barcode-to…
…-the-Aliquot-tube-labels DPL-1054 Add Vac tube barcode to the Aliquot tube labels
- Loading branch information
Showing
7 changed files
with
112 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/sequencescape/sequencescape/api/v2/shared/has_workline_identifier.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
# This was refactored as a concern so that it could be included in the Tube model (as well as Plae), | ||
# because one tube used a plate label and needed to use the alternative_workline_identifier config option. | ||
module Sequencescape::Api::V2::Shared | ||
# Include in API endpoints that have barcodes to add a few standard methods | ||
module HasWorklineIdentifier | ||
extend ActiveSupport::Concern | ||
|
||
# Finds a relevant related labware in order to include its barode on the barcode label. | ||
# Existing use at time of writing is in the top right part of plate labels. | ||
# In future it could also be included on tube labels if needed. | ||
# Uses alternative_workline_identifier from the purpose config if present, otherwise uses the stock plate. | ||
def workline_reference | ||
alternative_workline_identifier_purpose = SearchHelper.alternative_workline_reference_name(self) | ||
return stock_plate if alternative_workline_identifier_purpose.nil? | ||
|
||
ancestors.where(purpose_name: alternative_workline_identifier_purpose).last | ||
end | ||
|
||
def workline_identifier | ||
workline_reference&.barcode&.human | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# frozen_string_literal: true | ||
RSpec.shared_examples 'a labware with a workline identifier' do | ||
describe '#workline_identifier' do | ||
it 'displays the barcode of the workline_reference element' do | ||
plate2 = create :v2_plate | ||
allow(the_labware).to receive(:workline_reference).and_return(plate2) | ||
expect(the_labware.workline_identifier).to eq(plate2.barcode.human) | ||
end | ||
|
||
it 'does not break if there is no workline reference' do | ||
allow(the_labware).to receive(:workline_reference).and_return(nil) | ||
expect(the_labware.workline_identifier).to eq(nil) | ||
end | ||
end | ||
|
||
describe '#workline_reference' do | ||
let(:stock_plate_names) { ['Stock stuff', 'Some other stock stuff'] } | ||
let(:ancestors_scope) { double('ancestors_scope') } | ||
|
||
before do | ||
allow(the_labware).to receive(:ancestors).and_return(ancestors_scope) | ||
allow(the_labware).to receive(:stock_plate).and_return(stock_plate) | ||
allow(SearchHelper).to receive(:stock_plate_names).and_return(stock_plate_names) | ||
allow(ancestors_scope).to receive(:where).with(purpose_name: stock_plate_names).and_return(stock_plates) | ||
end | ||
|
||
context 'when the plate has no stock plates' do | ||
let(:stock_plates) { [] } | ||
let(:stock_plate) { nil } | ||
it 'returns nil' do | ||
expect(the_labware.workline_reference).to be_nil | ||
end | ||
end | ||
|
||
context 'when the plate has one stock plate' do | ||
let(:stock_plates) { create_list :v2_plate, 1 } | ||
let(:stock_plate) { stock_plates.last } | ||
it 'returns the stock plate' do | ||
expect(the_labware.workline_reference).to eq(stock_plates.last) | ||
end | ||
end | ||
|
||
context 'when the plate has more than one stock plate' do | ||
let(:stock_plates) { create_list :v2_plate, 2 } | ||
let(:stock_plate) { stock_plates.last } | ||
|
||
context 'when there are no alternative workline purpose references' do | ||
before do | ||
allow(SearchHelper).to receive(:alternative_workline_reference_name).with(the_labware).and_return(nil) | ||
allow(ancestors_scope).to receive(:where).with(purpose_name: []).and_return([]) | ||
end | ||
|
||
it 'returns the last stock plate' do | ||
expect(the_labware.workline_reference).to eq(stock_plates.last) | ||
end | ||
end | ||
|
||
context 'when there is a list of alternative workline purpose references' do | ||
let(:alternative_workline_reference_plates) { create_list :v2_plate, 2 } | ||
let(:alternative_workline_name) { 'Some other plate with some stuff inside' } | ||
|
||
before do | ||
allow(SearchHelper).to receive(:alternative_workline_reference_name) | ||
.with(the_labware) | ||
.and_return(alternative_workline_name) | ||
allow(ancestors_scope).to receive(:where) | ||
.with(purpose_name: alternative_workline_name) | ||
.and_return(alternative_workline_reference_plates) | ||
end | ||
|
||
it 'returns the last alternative workline reference' do | ||
expect(the_labware.workline_reference).to eq(alternative_workline_reference_plates.last) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters