ontology_spec.rb revision 85740b8f9c770963a1fe3a993c1745fb4f4f5ea8
require 'spec_helper'
let(:dgnode_name) { "https://raw.github.com/ontohub/OOR_Ontohub_API/master/Domain_Fields_Core.owl" }
end
end
end
end
end
params << distributed_ontology.to_param
ontology.destroy_with_parent(user)
params.each do |param|
expect { Ontology.find(param) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
context 'a distributed ontology' do
let (:ontology) { create :distributed_ontology }
it 'should delete the child ontologies as well' do
params = ontology.children.map(&:to_param)
params << ontology.to_param
ontology.destroy_with_parent(user)
params.each do |param|
expect { Ontology.find(param) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
context 'an imported ontology' do
let(:ontology) { create :ontology }
it 'should not be allowed' do
importing = create :ontology
create :import_link, target: importing, source: ontology
expect { ontology.destroy_with_parent(user) }.to raise_error(Ontology::DeleteError)
end
end
end
context 'when trying to get the imported ontologies' do
let!(:ontology) { create :ontology }
let!(:imported_ontology) do
imported = create :single_ontology
create :import_link, target: ontology, source: imported
imported
end
it 'should fetch immediately imported ontologies' do
expect(ontology.imported_ontologies).to include(imported_ontology)
expect(ontology.imported_ontologies.size).to be(1)
end
context 'which have imports themselves' do
let!(:imported_imported_ontology) do
imported = create :single_ontology
create :import_link, target: imported_ontology, source: imported
imported
end
it 'should fetch all imported ontologies' do
expect(ontology.imported_ontologies).to include(imported_ontology)
expect(ontology.imported_ontologies).
to include(imported_imported_ontology)
expect(ontology.imported_ontologies.size).to be(2)
end
end
end
context 'when parsing an ontology which contains logic translations' do
let(:repository) { create :repository }
let(:version) { add_fixture_file(repository, 'dol/double_mapped_logic_translated_blendoid.dol') }
let(:ontology) { version.ontology.children.find_by_name('DMLTB-TheClifOne') }
context 'the logically translated ontology' do
before do
version.parse
end
it 'should contain imported sentences' do
expect(ontology.imported_sentences).to_not be_empty
end
it 'should contain logic translations' do
expect(ontology.contains_logic_translations?).to be_true
end
end
end
end