Skip to content

Commit

Permalink
Expose the descriptive metadata as an endpoint
Browse files Browse the repository at this point in the history
This will be consumed by common-accessioning and argo.
We can then move that class to dor-services from dor-services-app
  • Loading branch information
jcoyne committed May 1, 2019
1 parent 5594e9a commit 2a105f5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-05-01 10:13:09 -0500 using RuboCop version 0.65.0.
# on 2019-05-01 14:31:04 -0500 using RuboCop version 0.65.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/metadata_controller.rb
Expand Up @@ -8,4 +8,9 @@ def dublin_core
service = DublinCoreService.new(@item)
render xml: service
end

def descriptive
service = Dor::PublicDescMetadataService.new(@item)
render xml: service
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -42,6 +42,7 @@
resources :metadata, only: [] do
collection do
get 'dublin_core'
get 'descriptive'
end
end

Expand Down
29 changes: 23 additions & 6 deletions spec/requests/metadata_spec.rb
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

RSpec.describe 'Refresh metadata' do
RSpec.describe 'Display metadata' do
let(:user) { Settings.DOR.SERVICE_USER }
let(:password) { Settings.DOR.SERVICE_PASSWORD }
let(:basic_auth) { ActionController::HttpAuthentication::Basic.encode_credentials(user, password) }
Expand All @@ -13,10 +13,27 @@
allow(Dor).to receive(:find).and_return(object)
end

it 'returns the DC xml' do
get '/v1/objects/druid:mk420bs7601/metadata/dublin_core',
headers: { 'Authorization' => basic_auth }
expect(response).to be_successful
expect(response.body).to include '<dc:title>Hello</dc:title>'
describe 'dublin core' do
it 'returns the DC xml' do
get '/v1/objects/druid:mk420bs7601/metadata/dublin_core',
headers: { 'Authorization' => basic_auth }
expect(response).to be_successful
expect(response.body).to include '<dc:title>Hello</dc:title>'
end
end

describe 'descriptive' do
it 'returns the DC xml' do
get '/v1/objects/druid:mk420bs7601/metadata/descriptive',
headers: { 'Authorization' => basic_auth }
expect(response).to be_successful
expect(response.body).to be_equivalent_to <<~XML
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.6" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd">
<titleInfo>
<title>Hello</title>
</titleInfo>
</mods>
XML
end
end
end

0 comments on commit 2a105f5

Please sign in to comment.