-
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.
align validations with validations in frontend. #334
- Loading branch information
Martin Fenner
committed
Aug 7, 2019
1 parent
291d31b
commit c768210
Showing
9 changed files
with
50 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,9 +205,10 @@ | |
|
||
factory :provider do | ||
system_email { "[email protected]" } | ||
sequence(:symbol) { |n| "TEST#{n}" } | ||
sequence(:symbol, 'A') { |n| "TEST#{n}" } | ||
name { "My provider" } | ||
display_name { "My provider" } | ||
website { Faker::Internet.url } | ||
country_code { "DE" } | ||
password_input { "12345" } | ||
twitter_handle { "@egaTwitterlac" } | ||
|
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 |
---|---|---|
|
@@ -201,7 +201,7 @@ | |
let(:params) do | ||
{ "data" => { "type" => "clients", | ||
"attributes" => { | ||
"symbol" => client.symbol + "MegaCLient", | ||
"symbol" => client.symbol + "M", | ||
"email" => "[email protected]", | ||
"name" => "Imperial College"}} } | ||
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"systemEmail" => "[email protected]", | ||
"website" => "https://www.bl.uk", | ||
"country" => "GB" } } } | ||
end | ||
let(:headers) { {'HTTP_ACCEPT'=>'application/vnd.api+json', 'HTTP_AUTHORIZATION' => 'Bearer ' + token } } | ||
|
@@ -56,7 +57,7 @@ | |
end | ||
|
||
context 'get provider type ROLE_CONTRACTUAL_PROVIDER and check it works ' do | ||
let(:provider) { create(:provider, role_name: "ROLE_CONTRACTUAL_PROVIDER", name: "Contractor", symbol: "CONTRACT_SLASH") } | ||
let(:provider) { create(:provider, role_name: "ROLE_CONTRACTUAL_PROVIDER", name: "Contractor", symbol: "CONTRCTR") } | ||
|
||
it 'get provider' do | ||
get "/providers/#{provider.symbol.downcase}", nil, headers | ||
|
@@ -103,6 +104,7 @@ | |
"symbol" => "BL", | ||
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"website" => "https://www.bl.uk", | ||
"salesforceId" => "abc012345678901234", | ||
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
|
@@ -147,6 +149,7 @@ | |
"displayName" => "Figshare", | ||
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
"website" => "https://www.bl.uk", | ||
"memberType" => "contractual_member", | ||
"country" => "GB" } } } | ||
end | ||
|
@@ -171,6 +174,7 @@ | |
"displayName" => "Figshare", | ||
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
"website" => "https://www.bl.uk", | ||
"memberType" => "consortium_organization", | ||
"country" => "GB" }, | ||
"relationships": { | ||
|
@@ -225,6 +229,7 @@ | |
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
"memberType" => "provider", | ||
"website" => "https://www.bl.uk", | ||
"country" => "GB" }, | ||
"relationships": { | ||
"consortium": { | ||
|
@@ -257,6 +262,7 @@ | |
"displayName" => "Figshare", | ||
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
"website" => "https://www.bl.uk", | ||
"memberType" => "consortium_organization", | ||
"country" => "GB" }, | ||
"relationships": { | ||
|
@@ -293,6 +299,7 @@ | |
"joined"=>"", | ||
"keepPassword"=>"[FILTERED]", | ||
"logoUrl"=>"", | ||
"website" => "https://www.bl.uk", | ||
"name"=>"Carnegie Mellon University", | ||
"displayName"=>"Carnegie Mellon University", | ||
"organizationType"=>"academicInstitution", | ||
|
@@ -309,9 +316,8 @@ | |
"postCode"=>"122dc" | ||
}, | ||
"region"=>"", | ||
"symbol"=>"CMfddff33333dd111d111113f4d", | ||
"updated"=>"", | ||
"website"=>"" | ||
"symbol"=>"CM", | ||
"updated"=>"" | ||
} | ||
} | ||
} | ||
|
@@ -320,18 +326,13 @@ | |
it 'creates a provider' do | ||
post '/providers', params, headers | ||
|
||
expect(last_response.status).to eq(200) | ||
expect(json.dig('data', 'attributes', 'systemEmail')).to eq("[email protected]") | ||
expect(json.dig('data', 'attributes', 'billingInformation',"state")).to eq("Rennes") | ||
expect(json.dig('data', 'attributes', 'billingInformation',"postCode")).to eq("122dc") | ||
expect(json.dig('data', 'attributes', 'twitterHandle')).to eq("@meekakitty") | ||
expect(json.dig('data', 'attributes', 'rorId')).to eq("https://ror.org/05njkjr15") | ||
end | ||
|
||
it 'returns status code 201' do | ||
post '/providers', params, headers | ||
|
||
expect(last_response.status).to eq(200) | ||
end | ||
end | ||
|
||
context 'request is valid with contact information' do | ||
|
@@ -382,17 +383,18 @@ | |
"familyName"=> "Dasler" | ||
}, | ||
"region"=>"", | ||
"symbol"=>"CMfddff33333dd111d111113f4d", | ||
"symbol"=>"CM", | ||
"updated"=>"", | ||
"website"=>"" | ||
"website" => "https://www.bl.uk" | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'creates a provider' do | ||
post '/providers', params, headers | ||
|
||
|
||
expect(last_response.status).to eq(200) | ||
expect(json.dig('data', 'attributes', 'technicalContact',"email")).to eq("[email protected]") | ||
expect(json.dig('data', 'attributes', 'technicalContact',"givenName")).to eq("Kristian") | ||
expect(json.dig('data', 'attributes', 'technicalContact',"familyName")).to eq("Garza") | ||
|
@@ -409,12 +411,6 @@ | |
expect(json.dig('data', 'attributes', 'votingContact',"givenName")).to eq("Robin") | ||
expect(json.dig('data', 'attributes', 'votingContact',"familyName")).to eq("Dasler") | ||
end | ||
|
||
it 'returns status code 201' do | ||
post '/providers', params, headers | ||
|
||
expect(last_response.status).to eq(200) | ||
end | ||
end | ||
|
||
context 'request for admin provider with meta' do | ||
|
@@ -437,10 +433,14 @@ | |
"organizationType" => "academicInstitution", | ||
"focusArea" => "general", "logoUrl" => "", | ||
"systemEmail" => "[email protected]", | ||
"website" => "", "isActive" => true, | ||
"passwordInput" => "@change", "hasPassword" => false, | ||
"keepPassword" => false, "joined" => "" | ||
}, "type" => "providers" | ||
"website" => "https://www.bl.uk", | ||
"isActive" => true, | ||
"passwordInput" => "@change", | ||
"hasPassword" => false, | ||
"keepPassword" => false, | ||
"joined" => "" | ||
}, | ||
"type" => "providers" | ||
} | ||
} | ||
|
||
|
@@ -467,6 +467,7 @@ | |
"symbol" => "ADMIN", | ||
"name" => "Admin", | ||
"displayName" => "Admin", | ||
"website" => "https://www.bl.uk", | ||
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
"country" => "GB" } } } | ||
|
@@ -492,6 +493,7 @@ | |
"symbol" => "BL", | ||
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"website" => "https://www.bl.uk", | ||
"region" => "EMEA", | ||
"systemEmail" => "[email protected]", | ||
"country" => "GB" } } } | ||
|
@@ -520,6 +522,7 @@ | |
"symbol" => "BL", | ||
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"website" => "https://www.bl.uk", | ||
"country" => "GB" } } } | ||
end | ||
|
||
|
@@ -539,6 +542,7 @@ | |
"systemEmail" => "timAus", | ||
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"website" => "https://www.bl.uk", | ||
"country" => "GB" } } | ||
end | ||
|
||
|
@@ -561,6 +565,7 @@ | |
"attributes" => { | ||
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"website" => "https://www.bl.uk", | ||
"region" => "Americas", | ||
"systemEmail" => "[email protected]", | ||
"country" => "GB" } } } | ||
|
@@ -597,6 +602,7 @@ | |
"displayName" => "British Library", | ||
"region" => "Americas", | ||
"systemEmail" => "[email protected]", | ||
"website" => "https://www.bl.uk", | ||
"country" => "GB" } } } | ||
end | ||
let(:admin) { create(:provider, symbol: "ADMIN", role_name: "ROLE_ADMIN", password_input: "12345") } | ||
|
@@ -618,6 +624,7 @@ | |
"name" => "British Library", | ||
"displayName" => "British Library", | ||
"region" => "Americas", | ||
"website" => "https://www.bl.uk", | ||
"systemEmail" => "[email protected]", | ||
"country" => "GB" } } } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,7 +178,7 @@ | |
let(:params) do | ||
{ "data" => { "type" => "repositories", | ||
"attributes" => { | ||
"symbol" => client.symbol + "MegaCLient", | ||
"symbol" => client.symbol + "M", | ||
"email" => "[email protected]", | ||
"name" => "Imperial College"}} } | ||
end | ||
|