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

pulibrary / allsearch_api / ed1cefda-f43b-4b58-95dd-12a33b7f1f7a

02 Jul 2025 06:23PM UTC coverage: 96.252% (-3.2%) from 99.494%
ed1cefda-f43b-4b58-95dd-12a33b7f1f7a

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

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

94 existing lines in 20 files now uncovered.

976 of 1014 relevant lines covered (96.25%)

63.21 hits per line

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

92.86
/app/models/library_website.rb
1
# frozen_string_literal: true
2

3
class LibraryWebsite
2✔
4
  include Parsed
2✔
5

6
  attr_reader :query_terms
2✔
7

8
  def initialize(query_terms:)
2✔
UNCOV
9
    @query_terms = query_terms
3✔
UNCOV
10
    @website_config = Rails.application.config_for(:allsearch)[:library_website]
3✔
11
  end
12

13
  def self.library_website_host
2✔
14
    config = LibraryWebsite.website_config
30✔
15
    if Flipper.enabled?(:permanent_host?)
30✔
16
      config[:host]
6✔
17
    else
18
      config[:temporary_host]
24✔
19
    end
20
  end
21

22
  def self.website_config
2✔
23
    @website_config ||= Rails.application.config_for(:allsearch)[:library_website]
30✔
24
  end
25

26
  def documents
2✔
UNCOV
27
    service_response['content'][0..2]
3✔
28
  end
29

30
  def number
2✔
UNCOV
31
    service_response['content'].count
1✔
32
  end
33

34
  def service_response
2✔
UNCOV
35
    response = Net::HTTP.post_form(uri, 'search' => query_terms)
4✔
UNCOV
36
    response_code = response.code
4✔
UNCOV
37
    if response_code.start_with? '5'
4✔
UNCOV
38
      raise AllsearchError.new(msg: "The library website API returned a #{response_code} HTTP status code.")
×
39
    end
40

UNCOV
41
    @service_response ||= JSON.parse(response.body)
4✔
42
  end
43

44
  private
2✔
45

46
  def more_link
2✔
UNCOV
47
    URI::HTTPS.build(host: LibraryWebsite.library_website_host,
×
48
                     path: '/search',
49
                     query: "keys=#{query_terms}")
50
  end
51

52
  def uri
2✔
UNCOV
53
    URI::HTTPS.build(host: LibraryWebsite.library_website_host,
4✔
54
                     path: @website_config[:path])
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