Skip to content

Commit

Permalink
Splitting with lines not working with carriage return
Browse files Browse the repository at this point in the history
emrojo committed Jan 25, 2021
1 parent d4db734 commit 3623d51
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/sequencescape_submission.rb
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ def assets
def extra_barcodes_list
return nil unless extra_barcodes

extra_barcodes.split(/[\n ,]/)
extra_barcodes.split(/[\n ,]+/).map(&:strip).reject(&:empty?)
end

def extra_plates
12 changes: 12 additions & 0 deletions spec/models/sequencescape_submission_spec.rb
Original file line number Diff line number Diff line change
@@ -64,6 +64,18 @@
obj = described_class.new(attributes.merge(extra_barcodes: '1234,5678'))
expect(obj.extra_barcodes_list).to eq(%w[1234 5678])
end
it 'removes any extra whitespaces' do
obj = described_class.new(attributes.merge(extra_barcodes: " 1234 \n 5678 "))
expect(obj.extra_barcodes_list).to eq(%w[1234 5678])
end
it 'splits with carriage return' do
obj = described_class.new(attributes.merge(extra_barcodes: "1234\r\n5678"))
expect(obj.extra_barcodes_list).to eq(%w[1234 5678])
end
it 'allows having empty lines' do
obj = described_class.new(attributes.merge(extra_barcodes: "1234\r\n\r\n5678"))
expect(obj.extra_barcodes_list).to eq(%w[1234 5678])
end
end

describe '#extra_plates' do

0 comments on commit 3623d51

Please sign in to comment.