22f8827cd8892a298f9764ce862db6867307828dEugen Kuksadef build_version_for(ontology)
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa commit_oid = '1'*40
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa ontology.versions.build(
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa {commit_oid: commit_oid,
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa commit: FactoryGirl.create(:commit, commit_oid: commit_oid),
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa basepath: File.basepath(ontology.path),
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa file_extension: File.extname(ontology.path),
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa fast_parse: false},
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa {without_protection: true})
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksaend
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen KuksaGiven(/^I have uploaded a(.*) ontology$/) do |type|
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa steps %Q{
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa Given I have an account
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa And I am logged in
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa And there is a#{type} ontology
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa And I have permissions to edit the ontology
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa And there is an ontology file
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa }
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksaend
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen KuksaGiven(/^Children of the ontology have been deleted$/i) do
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @deleted_child = @ontology.children.last
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @deleted_child.present = false
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @deleted_child.save!
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa build_version_for(@ontology).save!
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @ontology.children.each do |child|
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa build_version_for(child).save!
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa end
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksaend
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen KuksaGiven(/^Children of the ontology have been restored$/i) do
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @deleted_child.present =true
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @deleted_child.save!
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa build_version_for(@ontology).save!
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @ontology.children.each do |child|
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa build_version_for(child).save!
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa end
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksaend
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen KuksaWhen(/^I visit the file view of the ontology$/i) do
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa # The request object does not contain a requested mime type, so we need to
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa # stub this.
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa allow_any_instance_of(FilesController).
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa to receive(:existing_file_requested_as_html?).
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa and_return(true)
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa visit repository_tree_path(@ontology.repository, path: @ontology.path)
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksaend
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen KuksaThen(/^I should see all the file's ontologies$/i) do
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa # The file defines the DistributedOntolgy and its children.
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa number = 1 + @ontology.children.count
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa expect(page.find('#ontology-list-headline').text).to match(/\s+#{number}\s+/)
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa expect(page).to have_selector('ul.ontology-list > li', count: number)
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksaend