Skip to content

Commit

Permalink
temporarily comment out tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 25, 2018
1 parent bd75963 commit 340c1af
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
12 changes: 12 additions & 0 deletions spec/models/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
end
end

# describe "prefixes" do
# let(:client) { create(:client, provider: provider) }
# let!(:prefix) { create(:prefix, prefix: "10.5072") }

# it "automatically adds 10.5072 prefix" do
# prefix = client.prefixes
# expect(client.prefixes.count).to eq(2)
# end
# end

describe "methods" do
it "should not update the symbol" do
client.update_attributes :symbol => client.symbol+'foo.bar'
Expand All @@ -40,6 +50,8 @@
# expect(Doi.where(datacentre: client.id).count).to eq(5)
# expect(Doi.where(datacentre: target.id).count).to eq(0)
# client.target_id = target.symbol
# client.save
# sleep 1
# expect(Doi.where(datacentre: client.id).count).to eq(0)
# expect(Doi.where(datacentre: target.id).count).to eq(5)
# end
Expand Down
47 changes: 25 additions & 22 deletions spec/requests/clients_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,47 +100,51 @@
end
end

# Test suite for POST /clients
describe 'POST /clients' do
# context 'when the request is valid' do
# before { post '/clients', params: params.to_json, headers: headers }
#
# it 'creates a client' do
# expect(json.dig('data', 'attributes')).to eq("Imperial College")
# end
#
# it 'returns status code 201' do
# expect(response).to have_http_status(201)
# end
# end
context 'when the request is valid' do
before { post '/clients', params: params.to_json, headers: headers }

it 'creates a client' do
attributes = json.dig('data', 'attributes')
expect(attributes["name"]).to eq("Imperial College")
expect(attributes["contact-name"]).to eq("Madonna")

relationships = json.dig('data', 'relationships')
expect(relationships.dig("provider", "data", "id")).to eq(provider.symbol.downcase)
end

it 'returns status code 201' do
expect(response).to have_http_status(201)
end
end

context 'when the request is invalid' do
let(:params) do
{ "data" => { "type" => "clients",
"attributes" => {
"symbol" => provider.symbol + ".IMPERIAL",
"name" => "Imperial College"},
"name" => "Imperial College",
"contact-name" => "Madonna"
},
"relationships": {
"provider": {
"data":{
"data": {
"type": "providers",
"id": provider.symbol
"id": provider.symbol.downcase
}
}
} }
}} }
end

before { post '/clients', params: params.to_json, headers: headers }

it 'returns status code 500' do
expect(response).to have_http_status(500)
it 'returns status code 422' do
expect(response).to have_http_status(422)
end

# it 'returns a validation failure message' do
# expect(json["errors"]).to eq("id"=>"contact_name", "title"=>"Contact name can't be blank")
# end
it 'returns a validation failure message' do
expect(json["errors"]).to eq([{"source"=>"contact_email", "title"=>"Can't be blank"}, {"source"=>"contact_email", "title"=>"Is invalid"}])
end
end
end

Expand Down Expand Up @@ -206,7 +210,6 @@
end
end

# Test suite for DELETE /clients/:id
describe 'DELETE /clients/:id' do
before { delete "/clients/#{client.uid}", headers: headers }

Expand Down
6 changes: 4 additions & 2 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
expect(json.dig('data', 'attributes', 'title')).to eq("Eating your own Dog Food")
expect(json.dig('data', 'attributes', 'schema-version')).to eq("http://datacite.org/schema/kernel-4")
expect(json.dig('data', 'attributes', 'source')).to eq("test")
# expect(json.dig('data', 'relationships', 'resource-type')).to eq(2)
expect(json.dig('data', 'relationships', 'resource-type', 'data', 'id')).to eq("text")

xml = Maremma.from_xml(Base64.decode64(json.dig('data', 'attributes', 'xml'))).fetch("resource", {})
expect(xml.dig("resourceType")).to eq("resourceTypeGeneral"=>"Text", "__content__"=>"BlogPosting")
Expand Down Expand Up @@ -815,6 +815,7 @@
# end

# it 'returns status code 201' do
# expect(response.body).to eq(2)
# expect(response).to have_http_status(201)
# end

Expand Down Expand Up @@ -906,11 +907,12 @@
# end

# it 'returns status code 201' do
# expect(response.body).to eq(2)
# expect(response).to have_http_status(201)
# end

# it 'sets state to registered' do
# #expect(json.dig('data', 'attributes', 'state')).to eq("draft")
# expect(json.dig('data', 'attributes', 'state')).to eq("draft")
# end
end

Expand Down

0 comments on commit 340c1af

Please sign in to comment.