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

pulibrary / allsearch_api / 2edd1296-888c-4592-8789-a3202a060f6a

14 Oct 2025 05:48PM UTC coverage: 99.9% (+0.6%) from 99.32%
2edd1296-888c-4592-8789-a3202a060f6a

push

circleci

web-flow
Merge pull request #398 from pulibrary/replace-all-controllers

Replace all of our Rails controllers with Rack applications

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

116 existing lines in 19 files now uncovered.

995 of 996 relevant lines covered (99.9%)

115.81 hits per line

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

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

3
class LibraryWebsite
3✔
4
  include Parsed
3✔
5

6
  attr_reader :query_terms
3✔
7

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

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

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

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

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

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

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

44
  private
3✔
45

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

52
  def uri
3✔
UNCOV
53
    URI::HTTPS.build(host: LibraryWebsite.library_website_host,
11✔
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