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

pulibrary / pdc_discovery / 529bb1cf-d0bf-4901-97c6-12679aea8117

17 Aug 2023 01:30PM UTC coverage: 90.265% (-6.3%) from 96.544%
529bb1cf-d0bf-4901-97c6-12679aea8117

Pull #478

circleci

carolyncole
Updates to css to fix tests after bundle update
Also ran rubocop -A && Prettier
Pull Request #478: Switching to selenium to fix CI

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

2142 of 2373 relevant lines covered (90.27%)

93.35 hits per line

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

90.41
/spec/models/solr_document_spec.rb
1
# frozen_string_literal: true
2

3
require 'rails_helper'
1✔
4

5
# rubocop:disable Metrics/BlockLength
6
# rubocop:disable RSpec/ExampleLength
7
RSpec.describe SolrDocument do
1✔
8
  describe "#authors_et_al" do
1✔
9
    it "handles multiple authors" do
1✔
10
      doc = described_class.new({ id: "1", author_tesim: [] })
1✔
11
      expect(doc.authors_et_al).to eq ""
1✔
12

13
      doc = described_class.new({ id: "1", author_tesim: ["Eve Tuck"] })
1✔
14
      expect(doc.authors_et_al).to eq "Eve Tuck"
1✔
15

16
      doc = described_class.new({ id: "1", author_tesim: ["Eve Tuck", "K. Wayne Yang"] })
1✔
17
      expect(doc.authors_et_al).to eq "Eve Tuck & K. Wayne Yang"
1✔
18

19
      doc = described_class.new({ id: "1", author_tesim: ["Eve Tuck", "K. Wayne Yang", "Jane Smith"] })
1✔
20
      expect(doc.authors_et_al).to eq "Eve Tuck et al."
1✔
21
    end
22
  end
23

24
  describe "#icons_css" do
1✔
25
    it "handles icons for known genres" do
1✔
26
      doc = described_class.new({ id: "1", genre_ssim: ["Dataset"] })
1✔
27
      expect(doc.icon_css).to eq "bi-stack"
1✔
28

29
      doc = described_class.new({ id: "1", genre_ssim: ["moving image"] })
1✔
30
      expect(doc.icon_css).to eq "bi-film"
1✔
31
    end
32

33
    it "handles icon for an unknown genre" do
1✔
34
      doc = described_class.new({ id: "1", genre_ssim: ["unknown genre"] })
1✔
35
      expect(doc.icon_css).to eq "bi-file-earmark-fill"
1✔
36
    end
37
  end
38

39
  describe "#file_counts" do
1✔
40
    it "detects documents with no files attached" do
1✔
41
      doc = described_class.new({ id: "1" })
1✔
42
      expect(doc.file_counts.count).to eq 0
1✔
43
    end
44

45
    it "calculates file counts and sorts data descending by count" do
1✔
46
      files = [{ name: "file1.zip" }, { name: "data.csv" }, { name: "file2.zip" }]
1✔
47
      doc = described_class.new({ id: "1", files_ss: files.to_json })
1✔
48
      zip_group = { extension: "zip", file_count: 2 }
1✔
49
      csv_group = { extension: "csv", file_count: 1 }
1✔
50
      expect(doc.file_counts[0]).to eq zip_group
1✔
51
      expect(doc.file_counts[1]).to eq csv_group
1✔
52
    end
53
  end
54

55
  describe "#authors_ordered" do
1✔
56
    it "handles order for PDC Describe records" do
1✔
57
      pdc_describe_data = JSON.parse(File.read(File.join(fixture_path, 'files', 'pppl1.json')))
1✔
58
      pdc_authors = pdc_describe_data["resource"]["creators"].to_json
×
59
      doc = described_class.new({ id: "1", authors_json_ss: pdc_authors })
×
60
      expect(doc.authors_ordered.first.sequence).to eq 1
×
61
      expect(doc.authors_ordered.first.value).to eq "Wang, Yin"
×
62
      expect(doc.authors_ordered.last.sequence).to eq 5
×
63
      expect(doc.authors_ordered.last.value).to eq "Ji, Hantao"
×
64
      expect(doc.authors_ordered.count).to eq 5
×
65
    end
66

67
    it "returns the authors unordered for DataSpace records" do
1✔
68
      doc = described_class.new({ id: "1", author_tesim: ["Eve Tuck", "K. Wayne Yang"] })
1✔
69
      expect(doc.authors_ordered.first.sequence).to eq 0
1✔
70
      expect(doc.authors_ordered.last.sequence).to eq 0
1✔
71
      expect(doc.authors_ordered.any? { |author| author.value == "Eve Tuck" }).to eq true
2✔
72
      expect(doc.authors_ordered.count).to eq 2
1✔
73
    end
74
  end
75

76
  describe "#globus_uri" do
1✔
77
    let(:globus_uri_ssi) { "https://app.globus.org/file-manager?origin_id=xx&origin_path=%2Ffoldern%2Ffile.txt" }
2✔
78
    let(:uri_ssim) { ["https://princeton.edu", "https://app.globus.org/something/something"] }
3✔
79
    it "returns the indexed value when available" do
1✔
80
      doc = described_class.new({ id: "1", globus_uri_ssi: globus_uri_ssi, uri_ssim: uri_ssim })
1✔
81
      expect(doc.globus_uri).to eq "https://app.globus.org/file-manager?origin_id=xx&origin_path=%2Ffoldern%2Ffile.txt"
1✔
82
    end
83

84
    it "returns the value from the URIs" do
1✔
85
      doc = described_class.new({ id: "1", uri_ssim: uri_ssim })
1✔
86
      expect(doc.globus_uri).to eq "https://app.globus.org/something/something"
1✔
87
    end
88
  end
89

90
  describe "#globus_uri_from_description" do
1✔
91
    it "returns nil when no Globus URI available in the description" do
1✔
92
      doc = described_class.new({ id: "1", author_tesim: [] })
1✔
93
      expect(doc.globus_uri_from_description).to be nil
1✔
94

95
      doc = described_class.new({ id: "1", description_tsim: ["no globus URI in here"] })
1✔
96
      expect(doc.globus_uri_from_description).to be nil
1✔
97
    end
98

99
    it "returns the Globus URI when it is available in the description" do
1✔
100
      doc = described_class.new({ id: "1", description_tsim: ["xxx https://app.globus.org/file-manager?origin_id=dc43f461-0ca7-4203-848c-33a9fc00a464&origin_path=%2F yyy"] })
1✔
101
      expect(doc.globus_uri_from_description).to eq "https://app.globus.org/file-manager?origin_id=dc43f461-0ca7-4203-848c-33a9fc00a464&origin_path=%2F"
1✔
102
    end
103
  end
104

105
  describe "#subjects" do
1✔
106
    it "returns the values for PDC Describe records" do
1✔
107
      doc = described_class.new({ id: "1", data_source_ssi: "pdc_describe", subject_all_ssim: ["subject1", "subject2"] })
1✔
108
      expect(doc.subject.sort).to eq ["subject1", "subject2"]
1✔
109
    end
110

111
    it "returns the values for DataSpace records" do
1✔
112
      doc = described_class.new({ id: "1", subject_tesim: ["subject1", "subject2"] })
1✔
113
      expect(doc.subject.sort).to eq ["subject1", "subject2"]
1✔
114
    end
115
  end
116
end
117
# rubocop:enable Metrics/BlockLength
118
# rubocop:enable RSpec/ExampleLength
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