combination_steps.rb revision 5836ee88700245635cd096f27bdc6279178f4583
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseGiven(/^that I have a valid API\-Key$/) do
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @api_key = FactoryGirl.create :api_key
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @user = @api_key.user
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseGiven(/^that I have an invalid API\-Key$/) do
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @api_key = FactoryGirl.create :invalid_api_key
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @user = @api_key.user
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseGiven(/^I have a repository with path: "([^"]+)"$/) do |path|
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase permission =
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase if @user
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase FactoryGirl.create :permission, subject: @user
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase else
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase FactoryGirl.create :permission
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase end
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @repository = permission.item
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @repository.path = path
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @repository.save!
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseGiven(/^I know of a repository with path: "([^"]+)"$/) do |path|
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @repository = FactoryGirl.create :repository, path: path
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseGiven(/^I have (\d+) ontologies$/) do |number|
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase @ontologies = (1..number.to_i).to_a.
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase map { FactoryGirl.create :ontology }
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseWhen(/^I create a combination via the API of these ontologies$/) do
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase header 'Accept', 'application/json'
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase header 'Content-Type', 'application/json'
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase header Api::V1::Base::API_KEY_HEADER, @api_key.try(:key)
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase request "/#{@repository.path}///combinations",\
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase method: :post,
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase input: {nodes: @ontologies.map { |o| o.locid }}.to_json
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseThen(/^I should get a (\d+) response$/) do |number|
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase expect(last_response.status).to eq(number.to_i)
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase
5836ee88700245635cd096f27bdc6279178f4583Tim ReddehaseThen(/^a location\-header to the combination\-ontology$/) do
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehase expect(last_response.headers["Location"]).to eq(Ontology.last.locid)
5836ee88700245635cd096f27bdc6279178f4583Tim Reddehaseend