3 class LinkTest < ActiveSupport::TestCase
7 set_user_from_auth :admin_trustedclient
10 test 'name links with the same tail_uuid must be unique' do
11 a = Link.create!(tail_uuid: groups(:afolder).uuid,
12 head_uuid: specimens(:owned_by_active_user).uuid,
15 assert a.valid?, a.errors.to_s
16 assert_raises ActiveRecord::RecordNotUnique do
17 b = Link.create!(tail_uuid: groups(:afolder).uuid,
18 head_uuid: specimens(:owned_by_active_user).uuid,
24 test 'name links with different tail_uuid need not be unique' do
25 a = Link.create!(tail_uuid: groups(:afolder).uuid,
26 head_uuid: specimens(:owned_by_active_user).uuid,
29 assert a.valid?, a.errors.to_s
30 b = Link.create!(tail_uuid: groups(:asubfolder).uuid,
31 head_uuid: specimens(:owned_by_active_user).uuid,
34 assert b.valid?, b.errors.to_s
35 assert_not_equal(a.uuid, b.uuid,
36 "created two links and got the same uuid back.")
39 [nil, '', false].each do |name|
40 test "name links cannot have name=#{name.inspect}" do
41 a = Link.create(tail_uuid: groups(:afolder).uuid,
42 head_uuid: specimens(:owned_by_active_user).uuid,
45 assert a.invalid?, "invalid name was accepted as valid?"
49 test "cannot delete an object referenced by links" do
51 link = Link.create(tail_uuid: users(:active).uuid,
55 assert_raises(ActiveRecord::DeleteRestrictionError,
56 "should not delete #{ob.uuid} with link #{link.uuid}") do