Skip to content

Commit

Permalink
Merge pull request #1624 from ontohub/1591-child_ontologies_are_indef…
Browse files Browse the repository at this point in the history
…initely_pending

1591 child ontologies are indefinitely pending
  • Loading branch information
eugenk committed Mar 15, 2016
2 parents 6163e6c + 9affa8a commit 3aa9e3f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
6 changes: 5 additions & 1 deletion app/models/ontology_version/parsing.rb
Expand Up @@ -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|
Expand Down
5 changes: 2 additions & 3 deletions app/models/ontology_version/states.rb
Expand Up @@ -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
26 changes: 21 additions & 5 deletions spec/hets_helper.rb
Expand Up @@ -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


Expand Down
7 changes: 5 additions & 2 deletions spec/models/ontology_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3aa9e3f

Please sign in to comment.