-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an RSS feed for works, to be used by discovery for indexing
- Loading branch information
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
xml.instruct! :xml, version: "1.0" | ||
xml.rss version: "2.0" do | ||
xml.channel do | ||
xml.title "Princeton Data Commons RSS Feed" | ||
xml.description "Princeton Data Commons RSS Feed of approved submissions" | ||
xml.link root_url | ||
|
||
@works.each do |work| | ||
xml.item do | ||
xml.title work.title | ||
xml.url datacite_work_url(work) | ||
xml.date_changed work.updated_at | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
RSpec.describe "RSS feed of approved works, for harvesting and indexing", type: :system, mock_ezid_api: true do | ||
let(:work1) { FactoryBot.create(:draft_work) } | ||
let(:work2) { FactoryBot.create(:draft_work) } | ||
let(:admin) { FactoryBot.create(:super_admin_user) } | ||
let(:user) { FactoryBot.create(:princeton_submitter) } | ||
|
||
before do | ||
stub_datacite(host: "api.datacite.org", body: datacite_register_body(prefix: "10.34770")) | ||
allow(work1).to receive(:publish_doi).and_return(true) | ||
allow(work2).to receive(:publish_doi).and_return(true) | ||
|
||
work1.complete_submission!(admin) | ||
work1.approve!(admin) | ||
|
||
work2.complete_submission!(admin) | ||
work2.approve!(admin) | ||
end | ||
|
||
it "provides a list of approved works, with links to their datacite records" do | ||
sign_in user | ||
visit "/works.rss" | ||
doc = Nokogiri::XML(page.body) | ||
expect(doc.xpath("//item").size).to eq 2 | ||
urls = doc.xpath("//item/url/text()").map(&:to_s) | ||
expect(urls.include?(datacite_work_url(work1))).to eq true | ||
expect(urls.include?(datacite_work_url(work2))).to eq true | ||
end | ||
end |