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

pulibrary / tigerdata-app / 6a411f67-4d90-4835-b588-71c43f14ed4a

29 Aug 2025 06:38PM UTC coverage: 73.704% (-14.4%) from 88.118%
6a411f67-4d90-4835-b588-71c43f14ed4a

Pull #1801

circleci

JaymeeH
test parallelism with 3 executors
Pull Request #1801: 1586 request mailer

10 of 10 new or added lines in 2 files covered. (100.0%)

423 existing lines in 40 files now uncovered.

2133 of 2894 relevant lines covered (73.7%)

104.61 hits per line

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

44.16
/app/controllers/application_controller.rb
1
# frozen_string_literal: true
2
class ApplicationController < ActionController::Base
1✔
3
  protect_from_forgery with: :exception
1✔
4
  before_action :authenticate_user!
1✔
5
  before_action :mediaflux_session
1✔
6
  around_action :mediaflux_session_errors
1✔
7
  around_action :mediaflux_login_errors
1✔
8
  before_action :emulate_user
1✔
9

10
  helper_method :breadcrumbs
1✔
11

12
  def new_session_path(_scope)
1✔
13
    new_user_session_path
×
14
  end
15

16
  def after_sign_in_path_for(_resource)
1✔
UNCOV
17
    mediaflux_passthru_path
×
18
    # "/users/#{@user.id}"
19
  end
20

21
  def require_admin_user
1✔
UNCOV
22
    head :forbidden unless current_user&.eligible_sysadmin?
×
23
  end
24

25
  def breadcrumbs
1✔
26
    @breadcrumbs ||= []
322✔
27
  end
28

29
  def add_breadcrumb(name, path = nil)
1✔
30
    breadcrumbs << Breadcrumb.new(name, path)
161✔
31
  end
32

33
  private
1✔
34

35
    def mediaflux_session
1✔
36
      logger.debug "Application Session #{session[:mediaflux_session]} cas: #{session[:active_web_user]}"
161✔
37
      unless ["passthru", "cas"].include?(action_name)
161✔
38
        current_user&.mediaflux_from_session(session)
161✔
39
      end
40
    end
41

42
    def mediaflux_session_errors
1✔
43
      yield
161✔
44
    rescue ActionView::Template::Error, Mediaflux::SessionExpired => e
UNCOV
45
      raise unless e.is_a?(Mediaflux::SessionExpired) || e.cause.is_a?(Mediaflux::SessionExpired)
×
UNCOV
46
      if session[:active_web_user]
×
UNCOV
47
        redirect_to mediaflux_passthru_path(path: request.path)
×
UNCOV
48
      elsif session_error_handler
×
UNCOV
49
        retry
×
50
      else
UNCOV
51
        raise
×
52
      end
53
    end
54

55
    def mediaflux_login_errors
1✔
56
      yield
161✔
57
    rescue Mediaflux::SessionError
58
      if session_error_handler
×
59
        retry
×
60
      else
61
        raise
×
62
      end
63
    end
64

65
    def session_error_handler
1✔
UNCOV
66
      @retry_count ||= 0
×
UNCOV
67
      @retry_count += 1
×
68

UNCOV
69
      current_user.clear_mediaflux_session(session)
×
UNCOV
70
      current_user.mediaflux_from_session(session)
×
UNCOV
71
      @retry_count < 3 # If the session is expired we should not have to retry more than once, but let's have a little wiggle room
×
72
    end
73

74
    def emulate_user
1✔
75
      return if Rails.env.production?
161✔
76
      return if current_user.blank? || !current_user.trainer
161✔
77

78
      if session[:emulation_role]
7✔
UNCOV
79
        if session[:emulation_role] == "Eligible Data Sponsor"
×
UNCOV
80
          emulate_sponsor
×
UNCOV
81
        elsif session[:emulation_role] == "Eligible Data Manager"
×
UNCOV
82
          emulate_manager
×
UNCOV
83
        elsif session[:emulation_role] == "System Administrator"
×
UNCOV
84
          emulate_sysadmin
×
UNCOV
85
        elsif session[:emulation_role] == "Eligible Data User"
×
UNCOV
86
          emulate_data_user
×
87
        elsif session[:emulation_role] == "Return to Self"
×
88
          return_to_self
×
89
        end
90
      end
91
    end
92

93
    def emulate_sponsor
1✔
UNCOV
94
      current_user.eligible_sponsor = true
×
UNCOV
95
      current_user.eligible_manager = false
×
UNCOV
96
      current_user.sysadmin = false
×
97
    end
98

99
    def emulate_manager
1✔
UNCOV
100
      current_user.eligible_manager = true
×
UNCOV
101
      current_user.eligible_sponsor = false
×
UNCOV
102
      current_user.sysadmin = false
×
103
    end
104

105
    def emulate_sysadmin
1✔
UNCOV
106
      current_user.sysadmin = true
×
UNCOV
107
      current_user.eligible_manager = false
×
UNCOV
108
      current_user.eligible_sponsor = false
×
109
    end
110

111
    def emulate_data_user
1✔
UNCOV
112
      current_user.eligible_sponsor = false
×
UNCOV
113
      current_user.eligible_manager = false
×
UNCOV
114
      current_user.sysadmin = false
×
UNCOV
115
      current_user.trainer = false
×
116
    end
117

118
    def return_to_self
1✔
119
      current_user.eligible_sponsor = false
×
120
      current_user.eligible_manager = false
×
121
      current_user.sysadmin = false
×
122
    end
123
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