22f8827cd8892a298f9764ce862db6867307828dEugen KuksaGiven(/^there is a distributed ontology$/i) do
792e63782d113aa39e658471cf466863e97b852bTim Reddehase @distributed_ontology = FactoryGirl.create :distributed_ontology, :with_versioned_children
07807241a75892ff388800cf87fb40c0224cc0e0Tim Reddehase @ontology = @distributed_ontology
22f8827cd8892a298f9764ce862db6867307828dEugen Kuksa @ontology_version = @ontology.current_version
792e63782d113aa39e658471cf466863e97b852bTim Reddehaseend
792e63782d113aa39e658471cf466863e97b852bTim Reddehase
22f8827cd8892a298f9764ce862db6867307828dEugen KuksaGiven(/^there is an ontology file$/i) do
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrke repository = @ontology.repository
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrke user = repository.permissions.first.subject
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrke Tempfile.create('testfile') do |f|
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrke repository.save_file_only(f.path, @ontology.path, 'add ontology file', user)
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrke end
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrkeend
ff5afcf3b8fafaf548d638855881f710ba2e0fb1Tom Gehrke
792e63782d113aa39e658471cf466863e97b852bTim ReddehaseWhen(/^i visit the versions tab of a child ontology$/) do
792e63782d113aa39e658471cf466863e97b852bTim Reddehase @ontology = @distributed_ontology.children.first
792e63782d113aa39e658471cf466863e97b852bTim Reddehase
792e63782d113aa39e658471cf466863e97b852bTim Reddehase visit repository_ontology_ontology_versions_path(@ontology.repository, @ontology)
792e63782d113aa39e658471cf466863e97b852bTim Reddehaseend
792e63782d113aa39e658471cf466863e97b852bTim Reddehase
792e63782d113aa39e658471cf466863e97b852bTim ReddehaseThen(/^i should see the corresponding versions$/) do
792e63782d113aa39e658471cf466863e97b852bTim Reddehase id = @ontology.versions.first.id
6cf7dfa3f4a9dd506fc39a1aed4dc0c29ea814d2Eugen Kuksa selector = %(.evaluation-state[data-id="#{id}"][data-klass="OntologyVersion"])
792e63782d113aa39e658471cf466863e97b852bTim Reddehase expect(page).to have_css(selector)
792e63782d113aa39e658471cf466863e97b852bTim Reddehaseend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeWhen(/^I visit the versions tab of the ontology$/) do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke visit repository_ontology_ontology_versions_path(@ontology.repository, @ontology)
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeThen(/^I should see a "(.*?)" button for each version$/) do |text|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke within(:css, '#ontology_versions') do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke all(:css, 'tbody > tr').each do |row|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke expect(row).to have_link(text)
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeThen(/^I shouldn't see a "(.*?)" button for each version$/) do |text|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke within(:css, '#ontology_versions') do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke all(:css, 'tbody > tr').each do |row|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke expect(row).not_to have_link(text)
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeGiven(/^I have an account$/) do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke @user = FactoryGirl.create :user
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeGiven(/^I have permissions to edit the ontology$/) do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke perm = FactoryGirl.create :permission, subject: @user, item: @ontology.repository
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeThen(/^I should see a "(.*?)" button for the latest version$/) do |text|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke within(:css, '#ontology_versions') do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke @edit_button = first(:css, 'tbody > tr').find_link(text)
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke expect(first(:css, 'tbody > tr')).to have_link(text)
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeThen(/^I should see a "(.*?)" button for every other version$/) do |text|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke within(:css, '#ontology_versions') do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke all(:css, 'tbody > tr:nth-of-type(n+2)').each do |row|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke expect(row).to have_link(text)
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke end
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeGiven(/^there is a newer "(.*?)" version$/) do |state|
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke @ontology_version = FactoryGirl.create :ontology_version, state: state, ontology: @ontology
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke @ontology.state = state
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke @ontology.save!
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeWhen(/^I click the edit button$/) do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke @edit_button.click
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom GehrkeThen(/^I should see edit page of the ontology$/) do
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrke expect(page).to have_content('Edit mode')
13aeda174b4d9b5850ccc2c04d02e0def35ca634Tom Gehrkeend