Skip to content

Commit

Permalink
test should fail if samples
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Oct 22, 2024
1 parent d107a7b commit 07da6a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/unit/samples/sample_type_editing_constraints_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 07da6a1

Please sign in to comment.