Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use structure_title for populating structure list #6105

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(master_file:, stream_info:, media_fragment: nil)
delegate :derivative_ids, :id, to: :master_file

def to_s
master_file.display_title
master_file.structure_title
end

def range
Expand Down
27 changes: 27 additions & 0 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,33 @@
end
end

describe "#to_s" do
subject { presenter.to_s }

context 'single-section item' do
it 'prioritizes MediaObject#title for section title' do
expect(subject).to eq master_file.structure_title
expect(subject).to eq media_object.title
expect(subject).to_not eq master_file.display_title
end
end

context 'multi-section item' do
let(:second) { FactoryBot.build(:master_file, media_object: media_object, derivatives: [derivative]) }

before :each do
media_object.sections = [master_file, second]
media_object.save!
end

it 'prioritizes MasterFile#display_title for section titles' do
expect(subject).to eq master_file.structure_title
expect(subject).to eq master_file.display_title
expect(subject).to_not eq media_object.title
end
end
end

describe '#display_content' do
subject { presenter.display_content.first }

Expand Down