Skip to content

Commit

Permalink
Merge pull request #6105 from avalonmediasystem/display_section_title
Browse files Browse the repository at this point in the history
Use structure_title for populating structure list
  • Loading branch information
masaball authored Nov 11, 2024
2 parents 20b0843 + 35cd919 commit bf27f8c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
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

0 comments on commit bf27f8c

Please sign in to comment.