Skip to content

Commit

Permalink
spec for single DOI transfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Aug 27, 2018
1 parent 3912fd2 commit 60010c2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,43 @@
end
end

context 'when we transfer a DOI' do
let(:doi) { create(:doi, doi: "10.24425/119495", client: client, state: "registered") }
let(:new_client) { create(:client, symbol: "#{provider.symbol}.magic", provider: provider, password: ENV['MDS_PASSWORD']) }
let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) }
let(:valid_attributes) do
{
"data" => {
"type" => "dois",
"attributes" => {
"url" => "http://www.bl.uk/pdf/pat.pdf",
"xml" => xml
},
"relationships"=> {
"client"=> {
"data"=> {
"type"=> "clients",
"id"=> new_client.symbol.downcase
}
}
}
}
}
end

before { put "/dois/#{doi.doi}", params: valid_attributes.to_json, headers: admin_headers }

it 'returns no errors' do
puts json
expect(response).to have_http_status(200)
expect(json.dig('data', 'attributes', 'doi')).to eq(doi.doi)
end

it 'updates the client id' do
expect(json.dig('data', 'relationships', 'client','data','id')).to eq(new_client.symbol.downcase)
end
end

context 'when the resource_type_general changes' do
let(:xml) { Base64.strict_encode64(file_fixture('datacite.xml').read) }
let(:resource_type_general) { "data-paper" }
Expand Down

0 comments on commit 60010c2

Please sign in to comment.