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

pulibrary / allsearch_api / 0400cc50-b3f0-4794-8616-b4382e0acdd0

14 Oct 2025 03:57AM UTC coverage: 94.558% (-5.0%) from 99.514%
0400cc50-b3f0-4794-8616-b4382e0acdd0

Pull #395

circleci

sandbergja
Migrate Library Staff 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%)

93 existing lines in 21 files now uncovered.

973 of 1029 relevant lines covered (94.56%)

71.0 hits per line

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

85.71
/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✔
9
    @query_terms = query_terms
1✔
10
    @website_config = Rails.application.config_for(:allsearch)[:library_website]
1✔
11
  end
12

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

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

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

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

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

41
    @service_response ||= JSON.parse(response.body)
1✔
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✔
53
    URI::HTTPS.build(host: LibraryWebsite.library_website_host,
1✔
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