Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Test a few more things on oai_pmh feature spec #1285

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions spec/features/oai_pmh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
end

let!(:work) { FactoryGirl.create(:public_work, :with_complete_metadata, :real_public_image) }
let(:public_work_url) { "#{CHF::Env.lookup(:app_url_base)}/works/#{work.id}" }
let!(:collection) { FactoryGirl.create(:public_collection) }
let(:oai_pmh_xsd_path) { Rails.root + "spec/fixtures/xsd/OAI-PMH.xsd" }

it "renders feed with just work" do
visit(oai_pmh_oai_path(verb: "ListRecords", metadataPrefix: "oai_dc"))

expect(page.status_code).to eq 200
expect(page.response_headers["Content-Type"]).to eq("text/xml; charset=utf-8")

# parse strict, so we get an exception if it's not well-formed XML
xml = Nokogiri::XML(page.body) { |config| config.strict }
Expand All @@ -32,11 +34,27 @@

# includes one item, which is the work, not the collection
records = xml.xpath("//oai:record", oai: "http://www.openarchives.org/OAI/2.0/")
expect(records.count).to eq (1)
dc_contributors = xml.xpath("//dc:contributor", dc:"http://purl.org/dc/elements/1.1/").children.map(&:to_s)

expect(records.count).to eq(1)
work_record = records.first

# We just check for a few significant/tricky things, count on oai_dc_serialization_spec.rb to
# be more complete check of serialization.

dc_contributors = work_record.xpath("//dc:contributor", dc:"http://purl.org/dc/elements/1.1/").children.map(&:to_s)

# dc:contributors should include both the plain vanilla "contributor" but also the "editor".
expect(dc_contributors.map).to include("contributorcontributor", "G. Henle Verlag", "John Lennon")
record_id = records.first.at_xpath("./oai:header/oai:identifier", oai: "http://www.openarchives.org/OAI/2.0/")

record_id = work_record.at_xpath("./oai:header/oai:identifier", oai: "http://www.openarchives.org/OAI/2.0/")
expect(record_id.text).to eq("oai:sciencehistoryorg:#{work.id}")

dc_identifiers_str = work_record.xpath("//dc:identifier", dc:"http://purl.org/dc/elements/1.1/").map(&:text)
expect(dc_identifiers_str).to include(public_work_url)

dpla_original_record_str = work_record.xpath("//dpla:originalRecord", dpla: "http://dp.la/about/map/").map(&:text)
expect(dpla_original_record_str).to include(public_work_url)

# TODO: Thumbnail specs?
end
end