test/models/concept_test.rb in iqvoc-4.11.1 vs test/models/concept_test.rb in iqvoc-4.12.0
- old
+ new
@@ -129,11 +129,11 @@
monkey.save!
monkey.reload
refute monkey.publishable?, 'There should be no duplicates between prefLabel/altLabel'
end
- test 'multiple pref labels' do
+ test 'multiple pref labels of different languages' do
concept = RDFAPI.devour 'bear', 'a', 'skos:Concept'
RDFAPI.devour concept, 'skos:prefLabel', '"Bear"@en'
RDFAPI.devour concept, 'skos:prefLabel', '"Bär"@de'
assert concept.save
@@ -202,7 +202,51 @@
concept.labelings_by_text('labeling_skos_pref_labels', 'en')
assert_equal ['lorem', 'foo, bar', 'ipsum'],
labels_for.call(concept, Labeling::SKOS::AltLabel)
assert_equal 'lorem, "foo, bar", ipsum',
concept.labelings_by_text('labeling_skos_alt_labels', 'en')
+ end
+
+ test 'no narrower and broader concept relation' do
+ bear_concept = RDFAPI.devour 'bear', 'a', 'skos:Concept'
+ RDFAPI.devour bear_concept, 'skos:prefLabel', '"Bear"@en'
+ bear_concept.save
+
+ concept = RDFAPI.devour 'forest', 'a', 'skos:Concept'
+ RDFAPI.devour concept, 'skos:prefLabel', '"Forest"@en'
+ RDFAPI.devour concept, 'skos:narrower', bear_concept
+ RDFAPI.devour concept, 'skos:broader', bear_concept
+ assert concept.save!
+ assert_equal 1, concept.narrower_relations.count
+ assert_equal 1, concept.broader_relations.count
+ refute concept.publishable?
+ error_messages = concept.errors.full_messages_for(:base)
+ assert_equal 1, error_messages.count
+ index = error_messages.first.index(':')
+ assert_equal ": Bear", error_messages.first[index..index + 5]
+ assert_nil error_messages.first.index(',')
+ end
+
+ test 'concept self reference validation' do
+ wolf_concept = RDFAPI.devour 'wolf', 'a', 'skos:Concept'
+ RDFAPI.devour wolf_concept, 'skos:prefLabel', '"Wolf"@en'
+ wolf_concept.save!
+
+ assert wolf_concept.publishable?
+
+ RDFAPI.devour wolf_concept, 'skos:narrower', wolf_concept
+ refute wolf_concept.publishable?
+ assert wolf_concept.errors.full_messages_for(:base).include? I18n.t('txt.models.concept.no_self_reference')
+
+ wolf_concept.relations.delete_all
+ assert wolf_concept.reload.publishable?
+ RDFAPI.devour wolf_concept, 'skos:broader', wolf_concept
+ refute wolf_concept.publishable?
+ assert wolf_concept.errors.full_messages_for(:base).include? I18n.t('txt.models.concept.no_self_reference')
+
+ wolf_concept.relations.delete_all
+ assert wolf_concept.reload.publishable?
+ RDFAPI.devour wolf_concept, 'skos:related', wolf_concept
+ refute wolf_concept.publishable?
+ assert wolf_concept.errors.full_messages_for(:base).include? I18n.t('txt.models.concept.no_self_reference')
end
end