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

boston-library / ark-manager / 583

27 Oct 2025 02:55PM UTC coverage: 74.227%. Remained the same
583

push

travis-pro

bbarberBPL
Updated everything to use ruby 3.3.10

Fixed rack deprecation warnings

1 of 4 new or added lines in 2 files covered. (25.0%)

360 of 485 relevant lines covered (74.23%)

22.43 hits per line

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

83.87
/app/controllers/application_controller.rb
1
# frozen_string_literal: true
2

3
class ApplicationController < ActionController::API
1✔
4
  APP_INFO = {
1✔
5
    app_name: 'ark-manager',
6
    author: 'Ben Barber',
7
    organization: 'Boston Public Library',
8
    version: '2',
9
  }.freeze
10

11
  NOT_FOUND_ERROR_CLASSES = [
1✔
12
    'ActiveRecord::RecordNotFound',
13
    'ActionController::RoutingError',
14
    'PreviewController::ImageNotFound',
15
    'TextController::TextNotFound'
16
  ].freeze
17

18
  UNPROCESSABLE_CONTENT_CLASSES = [
1✔
19
    'ActiveRecord::RecordInvalid',
20
    'ActiveRecord::RecordNotSaved'
21
  ].freeze
22

23
  include ActionController::ImplicitRender
1✔
24
  include ActionView::Layouts
1✔
25
  include ActionController::Caching
1✔
26

27
  rescue_from StandardError, with: :handle_error
1✔
28

29
  def app_info
1✔
30
    render json: Oj.dump(APP_INFO), status: :ok
×
31
  end
32

33
  def route_not_found
1✔
34
    raise ActionController::RoutingError, 'No Route Matches This Url'
14✔
35
  end
36

37
  protected
1✔
38

39
  def handle_error(e)
1✔
40
    Rails.logger.error '============================================='
45✔
41
    Rails.logger.error e.class&.name
45✔
42
    Rails.logger.error e&.message
45✔
43
    Rails.logger.error e&.backtrace&.first(5)
45✔
44
    Rails.logger.error '============================================='
45✔
45

46
    status = case e&.class&.name
45✔
47
             when 'PreviewController::PreviewServiceError', 'TextController::TextPlainServiceError'
48
               e&.status || :internal_server_error
×
49
             when 'ActionController::UnknownFormat'
50
               :not_acceptable
×
51
             when *NOT_FOUND_ERROR_CLASSES
52
               :not_found
45✔
53
             when *UNPROCESSABLE_CONTENT_CLASSES
NEW
54
               :unprocessable_content
×
55
             else
56
               :internal_server_error
×
57
             end
58

59
    head status and return if !request.format.json?
45✔
60

61
    response_body = build_error_response(status.to_s.humanize, e&.message, status, request.env['PATH_INFO'])
11✔
62
    render json: Oj.dump(response_body), status: status
11✔
63
  end
64

65
  # def authenticate!
66
  #   # TODO
67
  # end
68

69
  private
1✔
70

71
  def build_error_response(title, message, status, pointer)
1✔
72
    {
73
      errors: [{
11✔
74
        title: title,
75
        status: Rack::Utils.status_code(status),
76
        detail: message,
77
        source: {
78
          pointer: pointer
79
        }
80
      }]
81
    }.as_json
82
  end
83
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

© 2026 Coveralls, Inc