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

pulibrary / allsearch_api / 842726e7-a026-4fa4-95f6-9644d41e6dd0

02 Jul 2025 06:28PM UTC coverage: 99.507% (+0.01%) from 99.494%
842726e7-a026-4fa4-95f6-9644d41e6dd0

Pull #381

circleci

sandbergja
Refactor RackResponseController so that subclasses don't need to implement #json

Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
Pull Request #381: Rewrite DPUL and FindingAids controllers as rack applications

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

81 existing lines in 19 files now uncovered.

1009 of 1014 relevant lines covered (99.51%)

96.77 hits per line

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

100.0
/app/models/catalog_document.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for getting relevant
4
# metadata from the Catalog's JSON
5
# The document is a Hash
6
class CatalogDocument < Document
3✔
7
  include SolrDocument
3✔
8

9
  private
3✔
10

11
  include Holdings
3✔
12

13
  def service
3✔
14
    'catalog'
97✔
15
  end
16

17
  def title
3✔
18
    document[:title_display]
96✔
19
  end
20

21
  def creator
3✔
22
    document[:author_display]&.first
95✔
23
  end
24

25
  def publisher
3✔
26
    document[:pub_created_display]&.first
95✔
27
  end
28

29
  def type
3✔
30
    document[:format]&.first
95✔
31
  end
32

33
  def description
3✔
34
    # tbd - nothing in the current json that seems relevant
35
  end
36

37
  def doc_keys
3✔
38
    [:first_barcode, :second_barcode, :first_call_number, :second_call_number, :first_library, :second_library,
96✔
39
     :first_status, :second_status, :online_access_count, :resource_url, :resource_url_label]
40
  end
41

42
  def online_access_count
3✔
43
    ea_count = electronic_access&.count || 0
96✔
44
    portfolio_count = document[:electronic_portfolio_s]&.count || 0
96✔
45
    ea_count + portfolio_count
96✔
46
  end
47

48
  def resource_url
3✔
49
    portfolio['url'] || electronic_access&.keys&.first
98✔
50
  end
51

52
  def resource_url_label
3✔
53
    return unless should_display_resource_url_label?
100✔
54

UNCOV
55
    portfolio['title'] || electronic_access&.values&.first&.first || 'Online content'
14✔
56
  end
57

58
  def should_display_resource_url_label?
3✔
59
    portfolio.present? || electronic_access.present?
100✔
60
  end
61

62
  def portfolio
3✔
63
    @portfolio ||= begin
212✔
64
      portfolio_string = document[:electronic_portfolio_s]&.first
102✔
65
      portfolio_string.present? ? JSON.parse(portfolio_string) : {}
102✔
66
    end
67
  end
68

69
  def electronic_access
3✔
70
    @electronic_access ||= begin
271✔
71
      electronic_access_string = document[:electronic_access_1display]
100✔
72
      electronic_access_string.present? ? JSON.parse(electronic_access_string) : {}
100✔
73
    end
74
  end
75

76
  def do_not_sanitize_these_fields
3✔
77
    super + [:resource_url]
1,836✔
78
  end
79
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