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

pulibrary / pdc_discovery / 5af13607-7741-41ac-b110-c94c8a3ee0f0

pending completion
5af13607-7741-41ac-b110-c94c8a3ee0f0

Pull #441

circleci

hectorcorrea
Better error handling
Pull Request #441: Indexing to a new collection

99 of 99 new or added lines in 3 files covered. (100.0%)

1816 of 2220 relevant lines covered (81.8%)

95.45 hits per line

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

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

4
RSpec.describe "PPPL has a harvest endpoint", type: :request do
1✔
5
  let(:pppl1) { File.read(File.join(fixture_path, 'files', 'pppl1.json')) }
3✔
6
  let(:pppl2) { File.read(File.join(fixture_path, 'files', 'pppl2.json')) }
1✔
7
  let(:pppl3) { File.read(File.join(fixture_path, 'files', 'pppl3.json')) }
1✔
8
  let(:pppl4) { File.read(File.join(fixture_path, 'files', 'pppl4.json')) }
1✔
9

10
  let(:other_data) { File.read(File.join(fixture_path, 'files', 'bitklavier_binaural.json')) }
1✔
11
  let(:indexer) { DescribeIndexer.new }
3✔
12

13
  before do
1✔
14
    Blacklight.default_index.connection.delete_by_query('*:*')
2✔
15
    Blacklight.default_index.connection.commit
2✔
16
    indexer.index_one(pppl1)
2✔
17
    indexer.index_one(pppl2)
×
18
    indexer.index_one(other_data)
×
19
    indexer.index_one(pppl3)
×
20

21
    # Note that pppl4 should have the most recent timestamp, since it was indexed last
22
    indexer.index_one(pppl4)
×
23
  end
24

25
  # We provide the entire PDC Describe JSON record in the solr field pdc_describe_json_ss
26
  it "provides PDC Describe JSON records for OSTI reporting" do
1✔
27
    get "/pppl_reporting_feed.json"
×
28
    expect(response).to have_http_status(:success)
×
29
    results = JSON.parse(response.body)
×
30
    # There should be 5 records in the index, but only 4 of them are from PPPL
31
    expect(results.count).to eq 4
×
32
    # The most recently indexed item (pppl4) should be first
33
    first_doi_url = JSON.parse(results.first["pdc_describe_json_ss"])["resource"]["doi"]
×
34
    expect(first_doi_url).to match(JSON.parse(pppl4)["resource"]["doi"])
×
35
  end
36

37
  it "can paginate through multiple pages of responses" do
1✔
38
    get "/pppl_reporting_feed.json?per_page=2"
×
39
    results = JSON.parse(response.body)
×
40

41
    # The first item on the first page is pppl4 because it was indexed most recently
42
    doi1 = JSON.parse(results.first["pdc_describe_json_ss"])["resource"]["doi"]
×
43
    expect(doi1).to match(JSON.parse(pppl4)["resource"]["doi"])
×
44

45
    # Because we set the per_page parameter to 2, we should see two results on the first page
46
    expect(results.count).to eq 2
×
47

48
    get "/pppl_reporting_feed.json?per_page=2&page=2"
×
49
    results = JSON.parse(response.body)
×
50
    expect(results.count).to eq 2
×
51

52
    # The first item on the second page should be pppl2
53
    doi2 = JSON.parse(results.first["pdc_describe_json_ss"])["resource"]["doi"]
×
54
    expect(doi2).to match(JSON.parse(pppl2)["resource"]["doi"])
×
55
  end
56
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