From 0995d8634d2da1ae0ac77851ecd36a467f94d25d Mon Sep 17 00:00:00 2001 From: Stuart Owen Date: Wed, 21 Aug 2024 10:46:50 +0100 Subject: [PATCH] fix to api test #1973 --- app/models/assay.rb | 5 +++-- app/models/observation_unit.rb | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/assay.rb b/app/models/assay.rb index a1cec65479..c5095524a9 100644 --- a/app/models/assay.rb +++ b/app/models/assay.rb @@ -305,11 +305,12 @@ def self.filter_by_projects(projects) private def study_matches_observation_units_if_present + return if samples.empty? samples.each do |sample| - if sample.observation_unit && sample.observation_unit.study != study + if sample.observation_unit && sample.observation_unit.study != study errors.add(:study, 'must match the associated observation unit') return false - end + end end end diff --git a/app/models/observation_unit.rb b/app/models/observation_unit.rb index 755fbac4f5..182e3c5f2f 100644 --- a/app/models/observation_unit.rb +++ b/app/models/observation_unit.rb @@ -53,6 +53,7 @@ def related_publication_ids private def study_matches_assays_if_present + return if samples.empty? samples.each do |sample| sample.assays.each do |assay| if assay.study != study