-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
categorize client types. datacite/datacite#796
- Loading branch information
Martin Fenner
committed
Jul 27, 2019
1 parent
b591edd
commit 29e4622
Showing
7 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddClientTypeColumn < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :datacentre, :client_type, :string, limit: 191 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ | |
"symbol" => provider.symbol + ".IMPERIAL", | ||
"name" => "Imperial College", | ||
"contactName" => "Madonna", | ||
"contactEmail" => "[email protected]" | ||
"contactEmail" => "[email protected]", | ||
"clientType" => "repository" | ||
}, | ||
"relationships": { | ||
"provider": { | ||
|
@@ -82,13 +83,8 @@ | |
it 'returns the client' do | ||
get "/clients/#{client.uid}", nil, headers | ||
|
||
expect(json.dig('data', 'attributes', 'name')).to eq(client.name) | ||
end | ||
|
||
it 'returns status code 200' do | ||
get "/clients/#{client.uid}", nil, headers | ||
|
||
expect(last_response.status).to eq(200) | ||
expect(json.dig('data', 'attributes', 'name')).to eq(client.name) | ||
end | ||
end | ||
|
||
|
@@ -97,11 +93,6 @@ | |
get "/clients/xxx", nil, headers | ||
|
||
expect(last_response.status).to eq(404) | ||
end | ||
|
||
it 'returns a not found message' do | ||
get "/clients/xxx", nil, headers | ||
|
||
expect(json["errors"].first).to eq("status"=>"404", "title"=>"The resource you are looking for doesn't exist.") | ||
end | ||
end | ||
|
@@ -112,19 +103,15 @@ | |
it 'creates a client' do | ||
post '/clients', params, headers | ||
|
||
expect(last_response.status).to eq(201) | ||
attributes = json.dig('data', 'attributes') | ||
expect(attributes["name"]).to eq("Imperial College") | ||
expect(attributes["contactName"]).to eq("Madonna") | ||
expect(attributes["clientType"]).to eq("repository") | ||
|
||
relationships = json.dig('data', 'relationships') | ||
expect(relationships.dig("provider", "data", "id")).to eq(provider.symbol.downcase) | ||
end | ||
|
||
it 'returns status code 201' do | ||
post '/clients', params, headers | ||
|
||
expect(last_response.status).to eq(201) | ||
end | ||
end | ||
|
||
context 'when the request is invalid' do | ||
|