Skip to content

Commit

Permalink
Differentiate between the two kinds of PDC Discovery URLs we use (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
bess authored Aug 16, 2023
1 parent 65563c9 commit b614a0b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,13 @@ def has_rights?(rights_id)
resource.rights_many.index { |rights| rights.identifier == rights_id } != nil
end

# This is the solr id / work show page in PDC Discovery
def pdc_discovery_url
"https://datacommons.princeton.edu/discovery/catalog/doi-#{doi.tr('/', '-').tr('.', '-')}"
end

# This is the url that should be used for ARK and DOI redirection. It will search the
# index for the DOI and redirect the use appropriately.
def doi_attribute_url
"https://datacommons.princeton.edu/discovery/doi/#{doi}"
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/works/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<% if @work.resource.doi %>
<dt>Discovery URL</dt>
<dd>
<%= link_to(@work.doi_attribute_url, @work.doi_attribute_url) %>
<%= link_to(@work.pdc_discovery_url, @work.pdc_discovery_url) %>
</dd>
<% end %>
Expand Down
7 changes: 7 additions & 0 deletions spec/models/work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@
expect { work.state = "sorry" }.to raise_error(StandardError, /Invalid state 'sorry'/)
end

it "calculates the urls that PDC discovery will use" do
# this is the actual PDC Discovery URL
expect(work.pdc_discovery_url).to eq "https://datacommons.princeton.edu/discovery/catalog/doi-10-34770-123-abc"
# this also works, but will cause PDC Discovery to search by the DOI
expect(work.doi_attribute_url).to eq "https://datacommons.princeton.edu/discovery/doi/10.34770/123-abc"
end

describe "#editable_by?" do
subject(:work) { FactoryBot.create(:tokamak_work) }
let(:submitter) { work.created_by_user }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/work_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
it "shows the PDC Discovery URL" do
sign_in user
visit work_path(work)
expect(page).to have_link("https://datacommons.princeton.edu/discovery/doi/10.34770/r2dz-ys12")
expect(page).to have_link("https://datacommons.princeton.edu/discovery/catalog/doi-10-34770-r2dz-ys12")
end

it "copies DOI to the clipboard" do
Expand Down

0 comments on commit b614a0b

Please sign in to comment.