diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index cbcf60e8..ec256348 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -85,10 +85,14 @@ def wrap_paragraphs_in_html(paragraphs) end def wrap_in_paragraph(value) - if value.start_with?("<") - value + if value.is_a?(String) + if value.start_with?("<") + value + else + ActionController::Base.helpers.content_tag(:p, value) + end else - ActionController::Base.helpers.content_tag(:p, value) + value end end end diff --git a/spec/models/solr_document_spec.rb b/spec/models/solr_document_spec.rb index 4a3af88f..46db930d 100644 --- a/spec/models/solr_document_spec.rb +++ b/spec/models/solr_document_spec.rb @@ -208,5 +208,23 @@ expect(notes_value).to eq ["
Testing
"] end end + + context "when note doesn't contain text" do + subject(:notes_value) do + document.extract_notes_by_header("biog") + end + + let(:document) { + described_class.new( + note_json_ssm: [ + "{\"head\":\"Biographical Note\",\"p\":{\"chronlist\":{\"listhead\":{\"head01\":\"Date\",\"head02\":\"Event\"},\"chronitem\":[{\"date\":1925,\"event\":\"Born in Yarram, Victoria, on 26 October\"},{\"date\":\"1942-1943\",\"event\":\"Student teacher, Department of Education, Victoria\"},{\"date\":\"1943-1946\",\"event\":\"Navigator, Royal Australian Air Force\"},{\"date\":1948,\"event\":\"Bachelor of Arts (Honours), University of Melbourne\"},{\"date\":\"1949-1951\",\"event\":\"Tutor in History, University of Melbourne\"},{\"date\":1951,\"event\":\"Master of Arts (Honours), University of Melbourne\"},{\"date\":\"\",\"event\":\"Inaugural Archbishop Mannix Travelling Scholar\"},{\"date\":\"1951-1953\",\"event\":\"Australian National University Research Scholar, University of Cambridge\"},{\"date\":1953,\"event\":\"Bachelor of Arts, University of Cambridge\"},{\"date\":\"1953-1958\",\"event\":\"Lecturer in History, University of Melbourne\"},{\"date\":\"1959-1964\",\"event\":\"Senior Lecturer in History, University of Melbourne\"},{\"date\":1960,\"event\":\"Master of Arts, University of Cambridge\"},{\"date\":1961,\"event\":\"Foundation Member, Australian Institute of Aboriginal Studies\"},{\"date\":\"\",\"event\":\"Nuffield Foundation Dominion Fellow, Institute of Archaeology (London)\"},{\"date\":1963,\"event\":\"Royal Society of Victoria Research Medal\"},{\"date\":\"1964-1980\",\"event\":\"Council Member, Australian Institute of Aboriginal Studies\"},{\"date\":\"1965-1970\",\"event\":\"Senior Fellow in Prehistory, Research School of Pacific Studies, Australian National University\"},{\"date\":\"1965-1976\",\"event\":\"Executive Member, Australian Institute of Aboriginal Studies\"},{\"date\":1969,\"event\":\"Australian Literature Society Dame Mary Gilmore Medal\"},{\"date\":1970,\"event\":\"Doctor of Philosophy, University of Cambridge\"},{\"date\":\"\",\"event\":\"Fellow, Australian Academy of the Humanities\"},{\"date\":1971,\"event\":\"Acting Principal, Australian Institute of Aboriginal Studies\"},{\"date\":\"1971-1985\",\"event\":\"Foundation Professor of Prehistory, Faculty of Arts, Australian National University\"},{\"date\":\"1972-1974\",\"event\":\"Council Member, Australian Academy of the Humanities\"},{\"date\":\"1972-1976\",\"event\":\"Deputy Chairman, Australian Institute of Aboriginal Studies\"},{\"date\":\"1974-1975\",\"event\":\"Member, Committee of Inquiry into Museums and National Collections\"},{\"date\":1975,\"event\":\"Chairman, Planning Committee, Gallery of Aboriginal Australia\"},{\"date\":\"1975-1976\",\"event\":\"Deputy Chairman, Museums Association, Canberra Division\"},{\"date\":\"1976-1977\",\"event\":\"Commonwealth Visiting Professor, University of Cambridge\"},{\"date\":\"1976-1982\",\"event\":\"Australian Heritage Commissioner\"},{\"date\":1977,\"event\":\"Fellow, Society of Antiquaries of London\"},{\"date\":1981,\"event\":\"President, Section 25A (Archaeology), ANZAAS Conference\"},{\"date\":\"1981-1983\",\"event\":\"Member, Interim Council of the Museum of Australia\"},{\"date\":1982,\"event\":\"Companion of the Order of St Michael and St George\"},{\"date\":\"1982-1984\",\"event\":\"Chairman, Australian Institute of Aboriginal Studies\"},{\"date\":1983,\"event\":\"Corresponding Fellow of the British Academy\"},{\"date\":\"1984-1985\",\"event\":\"Visiting Professor in Australian Studies, Harvard University\"},{\"date\":1985,\"event\":\"Whitely Book Award for biography, Royal Zoological Society (NSW)\"},{\"date\":1986,\"event\":\"Emeritus Professor of Prehistory, Australian National University\"},{\"date\":1986,\"event\":\"Honorary Member, Australian Archaeological Association\"},{\"date\":\"\",\"event\":\"Victorian Premier's Literary Award for Australian Studies (with J. H. Calaby)\"},{\"date\":\"1986-1988\",\"event\":\"Chairman, ACT Heritage Committee\"},{\"date\":\"1986-1990\",\"event\":\"Honorary Fellow, Department of History, Research School of Pacific Studies, Australian National University\"},{\"date\":\"1987-1990\",\"event\":\"Honorary Fellow, Museum of Victoria\"},{\"date\":1988,\"event\":\"ANZAAS Medal\"},{\"date\":\"1989-1992\",\"event\":\"Member, Editorial Board, Australian Institute of Aboriginal Studies\"},{\"date\":\"1989-1996\",\"event\":\"Secretary, Australian Academy of the Humanities\"},{\"date\":1990,\"event\":\"Honorary Member, Indo-Pacific Prehistory Association\"},{\"date\":\"\",\"event\":\"Honorary Member, Prehistoric Society (London)\"},{\"date\":1991,\"event\":\"Order of Australia\"},{\"date\":1996,\"event\":\"Honorary Fellow, Royal Anthropological Institute\"},{\"date\":\"1997-1998\",\"event\":\"Ashley Fellow, Trent University (Canada)\"},{\"date\":1999,\"event\":\"Grahame Clark Medal, British Academy\"},{\"date\":2001,\"event\":\"Australian Centenary Medal\"},{\"date\":2004,\"event\":\"Rhys Jones Medal, Australian Archaeological Association\"}]},\"bibref\":\"Prehistory to Politics : John Mulvaney, the humanities and the public intellectual, edited by Tim Bonyhady and Tom Griffiths. Carlton South, Victoria : Melbourne University Press, 1996.\"}}" + ] + ) + } + + it "doesn't try to wrap the content" do + expect(notes_value).not_to be_a(String) + end + end end end