diff --git a/app/models/tag.rb b/app/models/tag.rb index 308240861e..3b1abc83a6 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -25,6 +25,8 @@ def untag! broadcast_with_warren + validates :oligo, length: { maximum: 30 }, allow_blank: true + scope :sorted, -> { order(:map_id) } def name diff --git a/app/sample_manifest_excel/sample_manifest_excel/tags/validator/formatting.rb b/app/sample_manifest_excel/sample_manifest_excel/tags/validator/formatting.rb index 3dfbcbbd06..ca7ad7598a 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/tags/validator/formatting.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/tags/validator/formatting.rb @@ -14,6 +14,7 @@ def check_formatting return if value.blank? errors.add(:tag, 'must be a combination of A,C,G,T or N') unless value.match?(/\A[acgtnACGTN]+\z/) + errors.add(:tag, 'length must not exceed 30 characters') if value.length > 30 end end end diff --git a/spec/data/sample_manifest_excel/columns.yml b/spec/data/sample_manifest_excel/columns.yml index 83329b9978..fedeeae1ab 100644 --- a/spec/data/sample_manifest_excel/columns.yml +++ b/spec/data/sample_manifest_excel/columns.yml @@ -31,7 +31,7 @@ i7: options: type: :textLength operator: :lessThanOrEqual - formula1: "255" + formula1: "30" allowBlank: false showInputMessage: true promptTitle: "i7" @@ -45,7 +45,7 @@ i5: options: type: :textLength operator: :lessThanOrEqual - formula1: "255" + formula1: "30" allowBlank: false showInputMessage: true promptTitle: "i5" diff --git a/spec/models/tag_group/form_object_spec.rb b/spec/models/tag_group/form_object_spec.rb index 0f3671900a..a13d5fa058 100644 --- a/spec/models/tag_group/form_object_spec.rb +++ b/spec/models/tag_group/form_object_spec.rb @@ -100,6 +100,13 @@ expect(tag_group_form_object.tag_group.tags.first.oligo).to eq('ACCTTGGA') end end + + context 'when the oligos entered are longer than 30 charcters' do + it 'the model is invalid' do + tag_group_form_object.oligos_text = 'AAAAAAASACCCGGGTTTTTAAAAAATTTTTT' + expect(tag_group_form_object).not_to be_valid + end + end end context 'when no name is entered' do