• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_discovery / 690cdacb-3a8f-4cde-a7ee-3cf61aea4fb0

06 Sep 2023 06:32PM UTC coverage: 91.203% (-5.4%) from 96.597%
690cdacb-3a8f-4cde-a7ee-3cf61aea4fb0

push

circleci

bess
Override show action

6 of 6 new or added lines in 1 file covered. (100.0%)

2229 of 2444 relevant lines covered (91.2%)

178.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.31
/spec/requests/catalog_spec.rb
1
# frozen_string_literal: true
2
require 'rails_helper'
1✔
3

4
RSpec.describe "Catalog", type: :request do
1✔
5
  context "when indexing from DSpace" do
1✔
6
    let(:dspace_fixtures) { File.read(File.join(fixture_path, 'spherical_torus.xml')) }
5✔
7
    let(:indexer) do
1✔
8
      DspaceIndexer.new(dspace_fixtures)
4✔
9
    end
10
    before do
1✔
11
      indexer.index
4✔
12
    end
13

14
    describe "GET /doi/:doi" do
1✔
15
      let(:doi) { "doi:10.1088/0029-5515/57/1/016034" }
2✔
16
      let(:document_id) { "84912" }
3✔
17

18
      it "retrieves Solr Documents using a given DOI" do
1✔
19
        get "/doi/#{doi}"
1✔
20
        expect(response).to redirect_to(solr_document_path(id: document_id))
1✔
21
      end
22

23
      context "when passing only a segment of the DOI" do
1✔
24
        let(:doi) { "10.1088/0029-5515/57/1/016034" }
2✔
25

26
        it "retrieves Solr Documents using a given DOI" do
1✔
27
          get "/doi/#{doi}"
1✔
28
          expect(response).to redirect_to(solr_document_path(id: document_id))
1✔
29
        end
30
      end
31
    end
32

33
    describe "GET /ark/:ark" do
1✔
34
      let(:ark) { "http://arks.princeton.edu/ark:/88435/dsp01kd17cw34n" }
2✔
35
      let(:document_id) { "84912" }
3✔
36
      it "retrieves Solr Documents using a given ARK" do
1✔
37
        get "/ark/#{ark}"
1✔
38
        expect(response).to redirect_to(solr_document_path(id: document_id))
1✔
39
      end
40

41
      context "when passing only a segment of the ARK" do
1✔
42
        let(:ark) { "88435/dsp01kd17cw34n" }
2✔
43

44
        it "retrieves Solr Documents using a given ARK" do
1✔
45
          get "/ark/#{ark}"
1✔
46
          expect(response).to redirect_to(solr_document_path(id: document_id))
1✔
47
        end
48
      end
49
    end
50
  end
51

52
  context "when indexing from PDC Describe" do
1✔
53
    context "when two DOI values are present" do
1✔
54
      let(:resource1) { file_fixture("sowing_the_seeds.json").read }
2✔
55
      let(:bitklavier_binaural_json) { file_fixture("bitklavier_binaural.json").read }
2✔
56
      let(:bitklavier_binaural) do
1✔
57
        response_body = bitklavier_binaural_json
1✔
58
        json_response = JSON.parse(response_body)
1✔
59
        json_resource = json_response["resource"]
1✔
60
        json_titles = json_resource["titles"]
1✔
61
        json_title = json_titles.first
1✔
62
        json_title["title"] = "test title"
1✔
63
        json_response.to_json
1✔
64
      end
65
      let(:doi) { "10.34770/r75s-9j74" }
2✔
66
      let(:document_id) { "doi-10-34770-r75s-9j74" }
2✔
67
      let(:rss_feed) { file_fixture("works.rss").read }
2✔
68
      let(:rss_url_string) { "https://pdc-describe-prod.princeton.edu/describe/works.rss" }
2✔
69
      let(:indexer) { DescribeIndexer.new(rss_url: rss_url_string) }
2✔
70

71
      before do
1✔
72
        Blacklight.default_index.connection.delete_by_query("*:*")
1✔
73
        Blacklight.default_index.connection.commit
1✔
74
        stub_request(:get, "https://pdc-describe-prod.princeton.edu/describe/works.rss")
1✔
75
          .to_return(status: 200, body: rss_feed)
76
        stub_request(:get, "https://pdc-describe-prod.princeton.edu/describe/works/6.json")
1✔
77
          .to_return(status: 200, body: resource1, headers: {})
78
        stub_request(:get, "https://pdc-describe-prod.princeton.edu/describe/works/20.json")
1✔
79
          .to_return(status: 200, body: bitklavier_binaural, headers: {})
80

81
        indexer.index
1✔
82
      end
83

84
      it "defaults to the Solr Documents with 'pdc_describe' within the 'data_source' field" do
1✔
85
        get "/doi/#{doi}"
1✔
86
        expect(response).to redirect_to(solr_document_path(id: document_id))
1✔
87
        follow_redirect!
1✔
88
        expect(response.body).to include("test title")
×
89
      end
90
    end
91
  end
92
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc