X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4bd14ccfa216fe1d115772508ac7d7c64ec59a48..675794872a5d064cf0a8177d662555c04b0dae51:/services/api/test/unit/link_test.rb diff --git a/services/api/test/unit/link_test.rb b/services/api/test/unit/link_test.rb index 72d6017ce7..10f2b5eca5 100644 --- a/services/api/test/unit/link_test.rb +++ b/services/api/test/unit/link_test.rb @@ -4,7 +4,7 @@ class LinkTest < ActiveSupport::TestCase fixtures :all setup do - Thread.current[:user] = users(:active) + set_user_from_auth :admin_trustedclient end test 'name links with the same tail_uuid must be unique' do @@ -45,4 +45,16 @@ class LinkTest < ActiveSupport::TestCase assert a.invalid?, "invalid name was accepted as valid?" end end + + test "cannot delete an object referenced by links" do + ob = Specimen.create + link = Link.create(tail_uuid: users(:active).uuid, + head_uuid: ob.uuid, + link_class: 'test', + name: 'test') + assert_raises(ActiveRecord::DeleteRestrictionError, + "should not delete #{ob.uuid} with link #{link.uuid}") do + ob.destroy + end + end end