Skip to content

Commit f5f8f71

Browse files
committed
Make description required for AdminPolicy
1 parent cf233ca commit f5f8f71

6 files changed

Lines changed: 20 additions & 22 deletions

File tree

lib/cocina/models/admin_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AdminPolicy < Struct
1818
attribute :version, Types::Strict::Integer
1919
# Administrative properties for an AdminPolicy
2020
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
21-
attribute? :description, Description.optional
21+
attribute(:description, Description.default { Description.new })
2222
end
2323
end
2424
end

lib/cocina/models/admin_policy_with_metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AdminPolicyWithMetadata < Struct
1919
attribute :version, Types::Strict::Integer
2020
# Administrative properties for an AdminPolicy
2121
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
22-
attribute? :description, Description.optional
22+
attribute(:description, Description.default { Description.new })
2323
# When the object was created.
2424
attribute? :created, Types::Params::DateTime
2525
# When the object was modified.

schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
"administrative",
122122
"externalIdentifier",
123123
"type",
124-
"version"
124+
"version",
125+
"description"
125126
]
126127
},
127128
"AdminPolicy": {

spec/cocina/generator/schema_ref_spec.rb

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
administrative: {
1616
hasAdminPolicy: 'druid:bc123df4567',
1717
hasAgreement: 'druid:bc123df4567'
18+
},
19+
description: {
20+
title: [{ value: 'An APO' }],
21+
purl: 'https://purl.stanford.edu/bc123df4567'
1822
}
1923
}, false, false)
2024
end
@@ -38,23 +42,4 @@
3842
end
3943
end
4044
end
41-
42-
context 'when referenced schema is not required' do
43-
# AdminPolicy.description is an optional Description
44-
let(:policy) do
45-
Cocina::Models::AdminPolicy.new({
46-
externalIdentifier: 'druid:bc123df4567',
47-
type: Cocina::Models::ObjectType.admin_policy,
48-
version: 1,
49-
administrative: {
50-
hasAdminPolicy: 'druid:bc123df4567',
51-
hasAgreement: 'druid:bc123df4567'
52-
}
53-
}, false, false)
54-
end
55-
56-
it 'handles omittable' do
57-
expect(policy.description).to be_nil
58-
end
59-
end
6045
end

spec/cocina/generator/schema_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
hasAdminPolicy: 'druid:bc123df4567',
7373
hasAgreement: 'druid:bc123df4567',
7474
accessTemplate: {}
75+
},
76+
description: {
77+
title: [{ value: 'An APO Title'}],
78+
purl: 'https://purl.stanford.edu/bc123df4567'
7579
}
7680
)
7781
end

spec/cocina/models/validators/json_schema_validator_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
hasAdminPolicy: 'druid:bc123df4567',
1717
hasAgreement: 'druid:bc123df4567',
1818
accessTemplate: {}
19+
},
20+
description: {
21+
title: [{ value: 'A Title'}],
22+
purl: 'https://purl.stanford.edu/bc123df4567'
1923
}
2024
}
2125
end
@@ -54,6 +58,10 @@
5458
hasAdminPolicy: 'druid:bc123df4567',
5559
hasAgreement: 'druid:bc123df4567',
5660
releaseTags: [{to: 'Searchworks', who: 'mjgiarlo', what: 'self', release: true}]
61+
},
62+
description: {
63+
title: [{ value: 'An APO Title'}],
64+
purl: 'https://purl.stanford.edu/bc123df4567'
5765
}
5866
}
5967
end

0 commit comments

Comments
 (0)