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

tulibraries / tul_cob / 56162cb7-e89e-40c8-9207-c10dd9b4cbdf

22 Nov 2023 04:51PM UTC coverage: 85.508% (-0.09%) from 85.594%
56162cb7-e89e-40c8-9207-c10dd9b4cbdf

push

circleci

web-flow
Merge pull request #4084 from tulibraries/dependabot/bundler/faraday-2.7.12

Bump faraday from 2.7.11 to 2.7.12

2956 of 3457 relevant lines covered (85.51%)

55.86 hits per line

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

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

3
# Application Controller.
4
class ApplicationController < ActionController::Base
1✔
5
  # Adds a few additional behaviors into the application controller
6
  include Blacklight::Controller
1✔
7
  include Blacklight::BlacklightHelperBehavior
1✔
8
  include Blacklight::ConfigurationHelperBehavior
1✔
9
  include JsonLogger
1✔
10

11
  layout "blacklight"
1✔
12

13
  protect_from_forgery with: :exception
1✔
14

15
  before_action :get_manifold_alerts, only: [
1✔
16
    :index, :show, :not_found, :internal_server_error,
17
    :account, :librarian_view, :citation, :email, :facet
18
  ]
19

20
  rescue_from ActionController::InvalidAuthenticityToken,
1✔
21
    with: :redirect_to_referer
22

23
  # Rails 5.1 and above requires permitted params to be defined in the Controller
24
  # BL doesn't do that, but might in the future. This allows us to use the pre 5.1
25
  # behavior until we can define all possible param  in the future.
26
  ActionController::Parameters.permit_all_parameters = true
1✔
27

28
  helper_method :should_show_spellcheck_suggestions?
1✔
29

30
  # Overrides Devise::Controllers::Helpers#after_sign_out_path_for
31
  #
32
  # We want to make sure user actually gets signed out.
33
  # @see BL-224
34
  def after_sign_out_path_for(resource_or_scope)
1✔
35
    if request.params[:type] == "sso"
2✔
36
      Rails.configuration.devise[:sign_out_redirect_url]
2✔
37
    else
38
      super
×
39
    end
40
  end
41

42
  def redirect_to_referer
1✔
43
    flash[:notice] = "Your search results page had to be reloaded. Please try again."
×
44
    redirect_to request.referer
×
45
  end
46

47
  def get_manifold_alerts
1✔
48
    alert_url = "https://library.temple.edu/alerts.json"
259✔
49

50
    @manifold_alerts_thread ||= Thread.new {
259✔
51
      Rails.cache.fetch("manifold_alerts", expires_in: 5.minutes) do
258✔
52
        resp = begin
53
                 HTTParty.get(alert_url, timeout: 1)
258✔
54
               rescue => e
55
                 Honeybadger.notify(e)
×
56
                 Thread.new { sleep 0.25; Rails.cache.delete("manifold_alerts") }
×
57
                 {}
×
58
               end
59
        resp["data"] || []
258✔
60
      end
61
    }
62
  end
63

64
  protected
1✔
65

66
    def no_cache
1✔
67
      response.set_header("X-Robots-Tag", "noindex")
13✔
68
      response.set_header("Cache-Control", "private, no-store")
13✔
69
      response.headers["Pragma"] = "no-cache"
13✔
70
      response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
13✔
71
    end
72

73
    # ensure that rails treats request as xhr
74
    def xhr!
1✔
75
      request.headers["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest"
12✔
76
    end
77
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