Skip to content

Commit bb6d21d

Browse files
committed
Exclude notspecified licenses from Bioschemas output. Fixes #1168
1 parent 7ab91a0 commit bb6d21d

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/bioschemas/learning_resource_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def self.bioschemas_profile
3232
LicenceDictionary.instance.lookup_value(material.licence, 'reference') ||
3333
LicenceDictionary.instance.lookup_value(material.licence, 'url') ||
3434
material.licence
35-
}
35+
}, condition: -> (material) { material.licence != 'notspecified' }
3636
property :educationalLevel, :difficulty_level,
3737
condition: -> (material) { material.difficulty_level != 'notspecified' }
3838
property :competencyRequired, -> (material) {

test/models/material_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,15 @@ class MaterialTest < ActiveSupport::TestCase
630630
@material.node_names = ['ignore me', 'test node', ' WeSTeRoS', 'Ignore me', '']
631631
assert_equal ['Test Node', 'Westeros'], @material.nodes.map(&:name)
632632
end
633+
634+
test 'excludes notspecified licence from bioschemas json' do
635+
m = Material.new(title: 'Hello', licence: 'cc-by-4.0')
636+
637+
bioschemas = m.to_bioschemas.first.generate
638+
assert_equal 'https://spdx.org/licenses/CC-BY-4.0.html', bioschemas[:license]
639+
640+
m.licence = 'notspecified'
641+
bioschemas = m.to_bioschemas.first.generate
642+
refute bioschemas.key?(:license)
643+
end
633644
end

0 commit comments

Comments
 (0)