From 07da6a16ebc5e0c4c18620b6af53549cf8b2d823 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Tue, 22 Oct 2024 17:01:59 +0200 Subject: [PATCH] test should fail if samples --- test/unit/samples/sample_type_editing_constraints_test.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/unit/samples/sample_type_editing_constraints_test.rb b/test/unit/samples/sample_type_editing_constraints_test.rb index 05bb63423e..e16a9912d7 100644 --- a/test/unit/samples/sample_type_editing_constraints_test.rb +++ b/test/unit/samples/sample_type_editing_constraints_test.rb @@ -32,7 +32,8 @@ class SampleTypeEditingConstraintsTest < ActiveSupport::TestCase attr = c.sample_type.sample_attributes.detect { |t| t.accessor_name == 'address' } refute_nil attr refute c.allow_name_change?(attr) - assert c.allow_name_change?(nil) + # Not OK if attribute = nil and the sample type has samples + refute c.allow_name_change?(nil) # OK if there are no samples st2 = FactoryBot.create(:simple_sample_type) @@ -41,6 +42,7 @@ class SampleTypeEditingConstraintsTest < ActiveSupport::TestCase attr = c.sample_type.sample_attributes.detect { |t| t.accessor_name == 'the_title' } refute_nil attr assert c.allow_name_change?(attr) + # OK if attribute = nil and the sample type has no samples assert c.allow_name_change?(nil) # OK if user has editing permission over all samples @@ -51,7 +53,8 @@ class SampleTypeEditingConstraintsTest < ActiveSupport::TestCase attr = c.sample_type.sample_attributes.detect { |t| t.accessor_name == 'address' } refute_nil attr assert c.allow_name_change?(attr) - assert c.allow_name_change?(nil) + # Not OK if attribute = nil and the sample type has samples + refute c.allow_name_change?(nil) end end