Skip to content

Commit

Permalink
Merge pull request #461 from nla/feat/blac-673_bibref-structure
Browse files Browse the repository at this point in the history
fix: handle case where bibref is a Hash
  • Loading branch information
yetti authored Jun 19, 2024
2 parents 86577ee + 1633c47 commit 0e0b64f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/presenters/rendering/bibref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def render_bibref
# Sometimes the value is a single string instead of an array of strings
Array.wrap(values).each do |value|
doc.li do |list_item|
list_item << value
list_item << if value.is_a?(Hash)
value["content"]
else
value
end
end
end
}
Expand Down
6 changes: 6 additions & 0 deletions spec/files/notes/bibref_content.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"bibref": {
"persname": "Sexton, Christopher",
"content": "<span class='persname'>Sexton, Christopher</span>. <a href=\"http://nla.gov.au/nla.cat-vn1619352\"><em>Peggy van Praagh, a life of dance</em>.</a> South Melbourne : Macmillan, 1985."
}
}
15 changes: 15 additions & 0 deletions spec/presenters/rendering/bibref_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,20 @@
expect(rendered).to have_css("em", text: "Who's who in Australia")
end
end

context "when the bibref contains a hash" do
let(:note) { JSON.parse(IO.read("spec/files/notes/bibref_content.json")) }
let(:values) { note["bibref"] }

it "renders the bibref" do
expect(rendered).to have_css("h4", text: "Bibliographic Reference(s)")
expect(rendered).to have_css("ul.list-unstyled")
expect(rendered).to have_css("li", count: 1)
end

it "inserts the existing HTML" do
expect(rendered).to have_css("span.persname", text: "Sexton, Christopher")
end
end
end
end

0 comments on commit 0e0b64f

Please sign in to comment.