Skip to content

Commit

Permalink
Merge e7cf376 into cffaf40
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Apr 29, 2019
2 parents cffaf40 + e7cf376 commit bb74dbb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-04-26 16:20:32 -0500 using RuboCop version 0.65.0.
# on 2019-04-29 10:56:27 -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 Expand Up @@ -113,11 +113,12 @@ RSpec/ContextWording:
- 'spec/services/registration_service_spec.rb'
- 'spec/services/version_service_spec.rb'

# Offense count: 2
# Offense count: 3
RSpec/DescribeClass:
Exclude:
- 'spec/requests/about_spec.rb'
- 'spec/requests/metadata_refresh.rb'
- 'spec/requests/metadata_refresh_spec.rb'
- 'spec/requests/metadata_spec.rb'

# Offense count: 32
# Cop supports --auto-correct.
Expand Down Expand Up @@ -190,7 +191,7 @@ RSpec/MessageSpies:
- 'spec/services/registration_service_spec.rb'
- 'spec/services/version_service_spec.rb'

# Offense count: 76
# Offense count: 77
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 8
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/metadata_controller.rb
@@ -0,0 +1,11 @@
# frozen_string_literal: true

# A controller to display derived metadata about an object
class MetadataController < ApplicationController
before_action :load_item

def dublin_core
service = DublinCoreService.new(@item)
render xml: service
end
end
6 changes: 6 additions & 0 deletions config/routes.rb
Expand Up @@ -39,6 +39,12 @@
get 'contents/*path', to: 'content#read', format: false, as: :read_content
end

resources :metadata, only: [] do
collection do
get 'dublin_core'
end
end

resources :versions, only: [:create] do
collection do
get 'current'
Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions spec/requests/metadata_spec.rb
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'Refresh metadata' do
let(:user) { Settings.DOR.SERVICE_USER }
let(:password) { Settings.DOR.SERVICE_PASSWORD }
let(:basic_auth) { ActionController::HttpAuthentication::Basic.encode_credentials(user, password) }
let(:object) { Dor::Item.new(pid: 'druid:1234') }

before do
object.descMetadata.title_info.main_title = 'Hello'
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>'
end
end

0 comments on commit bb74dbb

Please sign in to comment.