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

pulibrary / allsearch_api / e0a6c222-0dc3-4fcb-b553-f858b12393b7

14 Oct 2025 02:46AM UTC coverage: 97.765% (-1.7%) from 99.514%
e0a6c222-0dc3-4fcb-b553-f858b12393b7

Pull #395

circleci

sandbergja
Migrate Library Website Controller away from ActionController
Pull Request #395: Migrate a few more controllers away from Rails

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

79 existing lines in 18 files now uncovered.

1006 of 1029 relevant lines covered (97.76%)

66.78 hits per line

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

91.67
/app/models/art_museum.rb
1
# frozen_string_literal: true
2

3
# This class is responsible for querying the Art Museum API
4
class ArtMuseum
2✔
5
  include ActiveModel::API
2✔
6
  include Parsed
2✔
7
  attr_reader :service, :service_response
2✔
8

9
  def initialize(query_terms:)
2✔
10
    @query_terms = query_terms
12✔
11
    @service = 'artmuseum'
12✔
12
    @service_response = art_museum_service_response
12✔
13
  end
14

15
  def query_terms
2✔
16
    @query_terms.truncate(220, omission: '', separator: /\s/)
37✔
17
  end
18

19
  private
2✔
20

21
  def art_museum_service_response
2✔
22
    uri = URI::HTTPS.build(host: 'data.artmuseum.princeton.edu', path: '/search',
12✔
23
                           query: "q=#{query_terms}&type=all&size=3")
24
    response = Net::HTTP.get(uri)
12✔
25
    begin
26
      JSON.parse(response, symbolize_names: true)
12✔
27
    rescue JSON::ParserError
UNCOV
28
      handle_parser_error response
×
29
    end
30
  end
31

32
  def number
2✔
33
    service_response.dig(:hits, :total)
11✔
34
  end
35

36
  def more_link
2✔
37
    URI::HTTPS.build(host: 'artmuseum.princeton.edu', path: '/search/collections',
22✔
38
                     query: "mainSearch=\"#{query_terms}\"")
39
  end
40

41
  def documents
2✔
42
    @documents ||= service_response.dig(:hits, :hits)
11✔
43
  end
44

45
  def handle_parser_error(response)
2✔
UNCOV
46
    raise AllsearchError.new(
×
47
      problem: 'UPSTREAM_ERROR',
48
      msg: "Query to upstream failed with #{ActionController::Base.helpers.strip_tags(response)}"
49
    )
50
  end
51
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