Skip to content

Commit

Permalink
Merge pull request #725 from sul-dlss/rename-collection
Browse files Browse the repository at this point in the history
Rename collection to containing_collection
  • Loading branch information
jcoyne authored Oct 24, 2023
2 parents 3dcc1e2 + 9ce8fe0 commit 69f66bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions app/models/purl_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def public_xml
@public_xml ||= PublicXml.new(public_xml_document)
end

def collection
@collection ||= public_xml.relations('isMemberOfCollection').first
# @return [String] the identifier of the collection this item is a member of
def containing_collection
@containing_collection ||= public_xml.relations('isMemberOfCollection').first
end

delegate :rights_metadata, to: :public_xml
Expand Down
3 changes: 2 additions & 1 deletion app/views/purl/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<% end %>
<%= tag :link, rel: "alternate", title: "MODS XML", type: 'application/xml', href: purl_url(@purl, format: 'mods') if @purl.mods? %>
<%= tag :link, rel: "alternate", title: "IIIF Manifest", type: 'application/json', href: iiif_manifest_url(@purl) if @purl.iiif_manifest? %>
<%= tag :link, rel: "up", href: purl_url(@purl.collection) if @purl.collection.present? %>
<%= tag :link, rel: "up", href: purl_url(@purl.containing_collection) if @purl.containing_collection.present? %>
<%= tag :meta, name: 'citation_doi', content: @purl.doi_id if @purl.doi.present? %>

<% end %>

<% keywords(@purl.mods.subject.compact.map(&:values).join(',')) if @purl.mods? && @purl.mods.subject %>
Expand Down
11 changes: 6 additions & 5 deletions spec/model/purl_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@
end
end

describe '#collection' do
it 'pulls the collection value from the RELS-EXT data' do
allow(subject).to receive(:public_xml_body).and_return <<-EOF
describe '#containing_collection' do
subject { instance.containing_collection }
before do
allow(instance).to receive(:public_xml_body).and_return <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<publicObject>
<rdf:RDF xmlns:fedora="info:fedora/fedora-system:def/relations-external#" xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:hydra="http://projecthydra.org/ns/relations#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
Expand All @@ -218,9 +219,9 @@
</rdf:RDF>
</publicObject>
EOF

expect(subject.collection).to eq 'jw357py5564'
end

it { is_expected.to eq 'jw357py5564' }
end

describe '#catalog_key' do
Expand Down

0 comments on commit 69f66bf

Please sign in to comment.