Skip to content

Commit

Permalink
Merge pull request #451 from IU-Libraries-Joint-Development/essi-1631…
Browse files Browse the repository at this point in the history
…_purl_fix

Increasing the scope of matching IDs in PURL resolver to work with legacy schemes
  • Loading branch information
dlpierce authored Jun 21, 2022
2 parents f295e5e + 1eea641 commit ce65ca8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/purl_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def formats

private
FILESET_LOOKUPS = { FileSet => nil }.freeze
DEFAULT_WORK_PATTERN = /^[a-zA-Z\/]{0,}\w{3}\d{4}$/.freeze
DEFAULT_WORK_PATTERN = /^[a-zA-Z\/]{0,}\w{2,}\d{3,}$/.freeze
DEFAULT_WORK_LOOKUPS = Hyrax.config.registered_curation_concern_types.sort.map do |klass|
[klass.constantize, DEFAULT_WORK_PATTERN.dup]
end.to_h.freeze
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/purl_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
source_metadata_identifier: 'BHR9405')
}
let(:paged_resource_path) { Rails.application.routes.url_helpers.hyrax_paged_resource_path(paged_resource) }
let(:legacy_paged_resource) {
FactoryBot.create(:paged_resource,
user: user,
purl: ['http://purl.dlib.indiana.edu/iudl/archives/cushman/P04259'],
source_metadata_identifier: 'P04259')
}
let(:legacy_paged_resource_path) { Rails.application.routes.url_helpers.hyrax_paged_resource_path(legacy_paged_resource) }
let(:file_set) {
FactoryBot.create(:file_set,
user: user,
Expand All @@ -24,6 +31,7 @@
before do
sign_in user
paged_resource
legacy_paged_resource
end
context 'with a matching id' do
shared_examples 'responses for matches' do
Expand Down Expand Up @@ -66,6 +74,20 @@
include_examples 'responses for matches'
end
end
context 'when for a legacy PagedResource' do
let(:target_path) { legacy_paged_resource_path }
let(:manifest_path) { legacy_paged_resource_path + '/manifest' }

context 'matching by source_metadata_identifier' do
let(:id) { legacy_paged_resource.source_metadata_identifier }
include_examples 'responses for matches'
end

context 'matching a full PURL by purl' do
let(:id) { 'iudl/archives/cushman/P04259' }
include_examples 'responses for matches'
end
end
context 'when for a specific page' do
let(:id) { paged_resource.source_metadata_identifier + '-9-0042' }
let(:target_path) { paged_resource_path + '?m=8&cv=41' }
Expand Down

0 comments on commit ce65ca8

Please sign in to comment.