Skip to content

Commit

Permalink
handle locked orcid accounts. #613
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 27, 2020
1 parent 39f9914 commit 6a06a80
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 0 deletions.
50 changes: 50 additions & 0 deletions spec/fixtures/vcr_cassettes/Person/find_by_id/account_locked.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions spec/fixtures/vcr_cassettes/Person/find_by_id/found_with_error.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions spec/graphql/types/person_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,64 @@
end
end

describe "find person account locked", elasticsearch: true, vcr: true do
let(:query) do
%(query {
person(id: "https://orcid.org/0000-0003-1315-5960") {
id
name
givenName
familyName
alternateName
description
links {
name
url
}
identifiers {
identifier
identifierType
identifierUrl
}
country {
id
name
}
citationCount
viewCount
downloadCount
works {
totalCount
published {
id
title
count
}
resourceTypes {
id
title
count
}
nodes {
id
titles {
title
}
citationCount
}
}
}
})
end

it "returns error" do
response = LupoSchema.execute(query).as_json
puts response
expect(response.dig("data")).to be_nil
expect(response.dig("errors")).to eq([{"locations"=>[{"column"=>9, "line"=>2}], "message"=>"409 Conflict: The ORCID record is locked and cannot be edited. ORCID https://orcid.org/0000-0003-1315-5960", "path"=>["person"]}])
end
end

describe "query people", elasticsearch: true, vcr: true do
let(:query) do
%(query {
Expand Down
5 changes: 5 additions & 0 deletions spec/models/person_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
expect(person.country).to be_nil
end

it "account locked" do
id = "https://orcid.org/0000-0003-1315-5960"
expect { Person.find_by_id(id) }.to raise_error(Faraday::ClientError, /ORCID record is locked/)
end

it "not found" do
id = "https://orcid.org/xxxxx"
people = Person.find_by_id(id)
Expand Down

0 comments on commit 6a06a80

Please sign in to comment.