Skip to content

Commit

Permalink
fix: handle case where bibref is a Hash
Browse files Browse the repository at this point in the history
  • Loading branch information
yetti committed Jun 19, 2024
1 parent 86577ee commit 1633c47
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 1633c47

Please sign in to comment.