diff --git a/app/models/ontology_version/parsing.rb b/app/models/ontology_version/parsing.rb index 127f26925..658a74988 100644 --- a/app/models/ontology_version/parsing.rb +++ b/app/models/ontology_version/parsing.rb @@ -41,7 +41,11 @@ def parse(refresh_cache: false, structure_only: self.fast_parse, ontology.import_version(self, self.user, input_io) retrieve_available_provers_for_self_and_children - update_state! :done + update_state!(:done) + ontology.children.each do |child| + child.versions.where(commit_oid: commit_oid).first.update_state!(:done) + child.versions.where(commit_oid: commit_oid).first.save! + end end files_to_parse_afterwards.each do |path| diff --git a/app/models/ontology_version/states.rb b/app/models/ontology_version/states.rb index 1154da3d1..1c365a5ae 100644 --- a/app/models/ontology_version/states.rb +++ b/app/models/ontology_version/states.rb @@ -45,11 +45,10 @@ def state_message protected def after_update_state - ontology.state = state.to_s + ontology.state = state ontology.save! if ontology.distributed? - ontology.children.update_all state: ontology.state + ontology.children.update_all(state: ontology.state) end end - end diff --git a/spec/hets_helper.rb b/spec/hets_helper.rb index 43c9b25d6..731d16cce 100644 --- a/spec/hets_helper.rb +++ b/spec/hets_helper.rb @@ -67,15 +67,31 @@ def hets_out_body_provers(ontology_fixture) end -def parse_ontology_hets_out(user, ontology, io) - evaluator = Hets::DG::Importer.new(user, ontology, io: io) - evaluator.import +def parse_ontology_hets_out(user, ontology, io, provers_io) + current_version = ontology.current_version + allow(Hets).to receive(:parse_via_api).and_return(io) + allow(Hets).to receive(:provers_via_api) do + provers_io.rewind + provers_io + end + allow(current_version).to receive(:ontology).and_return(ontology) + allow(ontology).to receive(:import_version) do + evaluator = Hets::DG::Importer.new(user, ontology, io: io, + version: ontology.current_version) + evaluator.import + end + + current_version.parse io.close unless io.closed? + provers_io.close unless provers_io.closed? + + allow(Hets).to receive(:parse_via_api).and_call_original end -def parse_ontology(user, ontology, ontology_fixture) +def parse_ontology(user, ontology, ontology_fixture, provers_io = nil) io = StringIO.new(hets_out_body_ontology(ontology_fixture)) - parse_ontology_hets_out(user, ontology, io) + provers_io = StringIO.new(hets_out_body_provers(ontology_fixture)) + parse_ontology_hets_out(user, ontology, io, provers_io) end diff --git a/spec/models/ontology_spec.rb b/spec/models/ontology_spec.rb index ef4954961..57d20d034 100644 --- a/spec/models/ontology_spec.rb +++ b/spec/models/ontology_spec.rb @@ -467,6 +467,10 @@ parse_ontology(user, ontology, 'casl/test2.casl') end + it "should have state 'done'" do + expect(ontology.state).to eq('done') + end + it 'should create all single ontologies' do expect(SingleOntology.count).to eq(4) end @@ -505,12 +509,11 @@ context 'all child ontologies' do it 'should have the same state as the parent' do - ontology.children.each do |child| + ontology.reload.children.each do |child| expect(child.state).to eq(ontology.state) end end end - end context 'Import another distributed Ontology' do