From ff13711642080b9141154f37f30bf3ad8248e7ba Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Wed, 20 Dec 2023 08:44:34 +0100 Subject: [PATCH] fix unit tests --- test/unit/sample_type_test.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/test/unit/sample_type_test.rb b/test/unit/sample_type_test.rb index 4fc68f2e78..10be47796e 100644 --- a/test/unit/sample_type_test.rb +++ b/test/unit/sample_type_test.rb @@ -1012,9 +1012,8 @@ def setup assert sample_type.valid? # Adding attribute - sample_type.sample_attributes.build(title: 'test 123') - refute sample_type.valid? - assert sample_type.errors.added?(:sample_attributes, 'cannot be added, new attributes are not allowed (test 123)') + sample_type.sample_attributes.build(title: 'test 123', sample_attribute_type: FactoryBot.build(:string_sample_attribute_type)) + assert sample_type.valid? sample_type.reload assert sample_type.valid? @@ -1029,8 +1028,7 @@ def setup # Changing attribute title sample_type.sample_attributes.last.title = 'banana' - refute sample_type.valid? - assert sample_type.errors.added?(:'sample_attributes.title', 'cannot be changed (patient)') + assert sample_type.valid? sample_type.reload assert sample_type.valid? @@ -1041,16 +1039,15 @@ def setup project_ids: @person.project_ids) end sample_type.sample_attributes.last.required = true - refute sample_type.valid? - assert sample_type.errors.added?(:'sample_attributes.required', 'cannot be changed (patient)') + assert sample_type.valid? sample_type.reload assert sample_type.valid? # Changing "title" attribute + sample_type.sample_attributes.first.is_title = false sample_type.sample_attributes.last.is_title = true - refute sample_type.valid? - assert sample_type.errors.added?(:'sample_attributes.is_title', 'cannot be changed (patient)') + assert sample_type.valid? sample_type.reload assert sample_type.valid? @@ -1092,8 +1089,7 @@ def setup assert sample_type.valid? attr = sample_type.sample_attributes.detect { |t| t.accessor_name == 'weight' } attr.unit = FactoryBot.create(:unit) - refute sample_type.valid? - assert sample_type.errors.added?(:'sample_attributes.unit', 'cannot be changed (weight)') + assert sample_type.valid? end private