Skip to content

Commit

Permalink
Merge pull request #72 from samvera/add-rights-property
Browse files Browse the repository at this point in the history
Add rights property
  • Loading branch information
cjcolvar authored Oct 3, 2022
2 parents 1d4e3d0 + 6c4220a commit 0c014de
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/iiif_manifest/v3/manifest_builder/iiif_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def rendering=(rendering)
end

def rights=(rights)
inner_hash['rights'] = rights
inner_hash['rights'] = Array(rights).first
end

def homepage=(homepage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def setup_manifest_from_record(manifest, record)
manifest['id'] = record.manifest_url.to_s
manifest.label = ManifestBuilder.language_map(record.to_s) if record.to_s.present?
manifest.summary = ManifestBuilder.language_map(record.description) if record.try(:description).present?
manifest.rights = record.rights_statement if record.try(:rights_statement).present?
manifest.behavior = viewing_hint if viewing_hint.present?
manifest.metadata = metadata_from_record(record) if metadata_from_record(record).present?
manifest.viewing_direction = viewing_direction if viewing_direction.present?
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/iiif_manifest/v3/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,28 @@ def sequence_rendering
end
end

context 'when there are no rights on the presenter' do
it 'does not have a rights element' do
allow(book_presenter).to receive(:rights_statement).and_return(nil)
expect(result.key?('rights')).to be false
end
end

context 'when there are a rights on the presenter' do
it 'does have a rights element as a String' do
allow(book_presenter).to receive(:rights_statement).and_return('the rights')
expect(result['rights'].class).to eq String
end

context 'when the rights on the presenter is an Array' do
it 'still has a rights element as a String' do
allow(book_presenter).to receive(:rights_statement).and_return(['the rights'])
expect(result['rights'].class).not_to eq Array
expect(result['rights'].class).to eq String
end
end
end

context 'when there is no manifest_metadata method' do
let(:file_presenter) { DisplayImagePresenter.new }

Expand Down

0 comments on commit 0c014de

Please sign in to comment.