diff --git a/README.md b/README.md index 5a3f75dfb..365ee3306 100755 --- a/README.md +++ b/README.md @@ -164,6 +164,14 @@ foo@bar:~$ bundle exec rspec spec/controllers/hyrax/users_controller_spec.rb --s ``` * Copy the output of this to the sample_solr_documents file. Add a unique `:timestamp` value to the hash (e.g. `:timestamp => "2021-11-23T16:05:33.033Z"`) so that the `spec/requests/oai_pmh_endpoint_spec.rb` tests to continue to pass. +#### Debugging database not found +If tests fail with an error like `FATAL: database "hyrax_test" does not exist` then you will likely need to create the test database manually: + +``` +docker compose exec web bash +rails db:create RAILS_ENV=test +``` + #### Debugging Capybara feature and javascript tests * Save a screenshot * Put `page.save_screenshot('screenshot.png')` on the line before the failing test (you can use a different name for the file if that's helpful) diff --git a/app/overrides/models/concerns/blacklight/document/dublin_core_override.rb b/app/overrides/models/concerns/blacklight/document/dublin_core_override.rb index c412dc4c1..b91000a8f 100644 --- a/app/overrides/models/concerns/blacklight/document/dublin_core_override.rb +++ b/app/overrides/models/concerns/blacklight/document/dublin_core_override.rb @@ -26,6 +26,8 @@ def export_as_oai_dc_xml array_of_values = values_as_array(values) if field_s == 'source' add_source_to_xml(xml, array_of_values) + elsif field_s == 'description' + array_of_values.each { |v| add_field_to_xml(xml, field_s, ActionController::Base.helpers.strip_tags(v)) } else array_of_values.each { |v| add_field_to_xml(xml, field_s, v) } end diff --git a/spec/models/concerns/blacklight/document/dublin_core_spec.rb b/spec/models/concerns/blacklight/document/dublin_core_spec.rb index 4c1af7ac1..7fc3c829a 100644 --- a/spec/models/concerns/blacklight/document/dublin_core_spec.rb +++ b/spec/models/concerns/blacklight/document/dublin_core_spec.rb @@ -91,6 +91,19 @@ end end + context 'with abstract containing html' do + let(:work) { Article.new(id: '123456', title: ['Testing HTML'], + abstract: ['This abstract contains html'] + ) + } + + it 'returns xml document with html tables sanitized from abstract' do + xml_doc = Nokogiri::XML(document.export_as_oai_dc_xml) + desc = xml_doc.xpath('//dc:description', 'dc' => 'http://purl.org/dc/elements/1.1/').map(&:text) + expect(desc).to eq ['This abstract contains html'] + end + end + context 'with thumbnail' do let(:work) { Article.new(id: '123456', title: ['654321']) } before do