Skip to content

Commit

Permalink
specs for globus_uuid. datacite/datacite#936
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 23, 2020
1 parent 8b5cb99 commit 4db2935
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/factories/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"given_name": "Martin",
"family_name": "Fenner"
}}
globus_uuid { "bc7d0274-3472-4a79-b631-e4c7baccc667" }
sequence(:symbol) { |n| provider.symbol + ".TEST#{n}" }
name { "My data center" }
role_name { "ROLE_DATACENTRE" }
Expand Down Expand Up @@ -240,6 +241,7 @@
factory :provider do
system_email { "[email protected]" }
sequence(:symbol, 'A') { |n| "TEST#{n}" }
globus_uuid { "53d8d984-450d-4b1d-970b-67faff28db1c" }
name { "My provider" }
display_name { "My provider" }
website { Faker::Internet.url }
Expand Down
32 changes: 32 additions & 0 deletions spec/requests/clients_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

expect(last_response.status).to eq(200)
expect(json.dig('data', 'attributes', 'name')).to eq(client.name)
expect(json.dig('data', 'attributes', 'globusUuid')).to eq("bc7d0274-3472-4a79-b631-e4c7baccc667")
end
end

Expand Down Expand Up @@ -181,6 +182,37 @@
end
end

context 'removes the globus_uuid' do
let(:params) do
{ "data" => { "type" => "clients",
"attributes" => {
"globusUuid" => nil }} }
end

it 'updates the record' do
put "/clients/#{client.symbol}", params, headers

expect(last_response.status).to eq(200)
expect(json.dig('data', 'attributes', 'name')).to eq("My data center")
expect(json.dig('data', 'attributes', 'globusUuid')).to be_nil
end
end

context 'invalid globus_uuid' do
let(:params) do
{ "data" => { "type" => "clients",
"attributes" => {
"globusUuid" => "abc" }} }
end

it 'updates the record' do
put "/clients/#{client.symbol}", params, headers

expect(last_response.status).to eq(422)
expect(json["errors"].first).to eq("source"=>"globus_uuid", "title"=>"Abc is not a valid UUID")
end
end

context 'using basic auth', vcr: true do
let(:params) do
{ "data" => { "type" => "clients",
Expand Down
31 changes: 31 additions & 0 deletions spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,37 @@
end
end

context 'removes globus_uuid' do
let(:params) do
{ "data" => { "type" => "providers",
"attributes" => {
"globusUuid" => nil } } }
end

it 'updates the record' do
put "/providers/#{provider.symbol}", params, headers

expect(last_response.status).to eq(200)
expect(json.dig('data', 'attributes', 'displayName')).to eq("My provider")
expect(json.dig('data', 'attributes', 'globusUuid')).to be_nil
end
end

context 'invalid globus_uuid' do
let(:params) do
{ "data" => { "type" => "providers",
"attributes" => {
"globusUuid" => "abc" } } }
end

it 'updates the record' do
put "/providers/#{provider.symbol}", params, headers

expect(last_response.status).to eq(422)
expect(json["errors"].first).to eq("source"=>"globus_uuid", "title"=>"Abc is not a valid UUID")
end
end

context 'ror_id in wrong format' do
let(:params) do
{ "data" => { "type" => "providers",
Expand Down
32 changes: 32 additions & 0 deletions spec/requests/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

expect(last_response.status).to eq(200)
expect(json.dig('data', 'attributes', 'name')).to eq(client.name)
expect(json.dig('data', 'attributes', 'globusUuid')).to eq("bc7d0274-3472-4a79-b631-e4c7baccc667")
end
end

Expand Down Expand Up @@ -158,6 +159,37 @@
end
end

context 'removes the globus_uuid' do
let(:params) do
{ "data" => { "type" => "repositories",
"attributes" => {
"globusUuid" => nil }} }
end

it 'updates the record' do
put "/repositories/#{client.symbol}", params, headers

expect(last_response.status).to eq(200)
expect(json.dig('data', 'attributes', 'name')).to eq("My data center")
expect(json.dig('data', 'attributes', 'globusUuid')).to be_nil
end
end

context 'invalid globus_uuid' do
let(:params) do
{ "data" => { "type" => "repositories",
"attributes" => {
"globusUuid" => "abc" }} }
end

it 'updates the record' do
put "/repositories/#{client.symbol}", params, headers

expect(last_response.status).to eq(422)
expect(json["errors"].first).to eq("source"=>"globus_uuid", "title"=>"Abc is not a valid UUID")
end
end

context 'using basic auth', vcr: true do
let(:params) do
{ "data" => { "type" => "repositories",
Expand Down

0 comments on commit 4db2935

Please sign in to comment.