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

pulibrary / tigerdata-app / f9562a31-daa0-4ff5-8719-49e56addc432

03 Nov 2025 07:22PM UTC coverage: 91.397% (-0.003%) from 91.4%
f9562a31-daa0-4ff5-8719-49e56addc432

push

circleci

web-flow
Adjusted breadcrumbs on draft request show page (#2138)

Closes #2109

0 of 1 new or added line in 1 file covered. (0.0%)

883 existing lines in 49 files now uncovered.

2826 of 3092 relevant lines covered (91.4%)

488.47 hits per line

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

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

11
  helper_method :breadcrumbs
5✔
12

13
  def new_session_path(_scope)
5✔
14
    new_user_session_path
×
15
  end
16

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

22
  def require_admin_user
5✔
23
    head :forbidden unless current_user&.eligible_sysadmin?
4✔
24
  end
25

26
  def breadcrumbs
5✔
27
    @breadcrumbs ||= []
825✔
28
  end
29

30
  def add_breadcrumb(name, path = nil)
5✔
31
    breadcrumbs << Breadcrumb.new(name, path)
477✔
32
  end
33

34
  # Render a 404 page for any undefined route
35
  def render_not_found
5✔
36
    render file: Rails.public_path.join("404.html").to_s, layout: false, status: :not_found
1✔
37
  end
38

39
  private
5✔
40

41
    def mediaflux_session
5✔
42
      logger.debug "Application Session #{session[:mediaflux_session]} cas: #{session[:active_web_user]}"
537✔
43
      unless ["passthru", "cas"].include?(action_name)
537✔
44
        current_user&.mediaflux_from_session(session)
531✔
45
      end
46
    end
47

48
    def mediaflux_session_errors
5✔
49
      yield
537✔
50
    rescue ActionView::Template::Error, Mediaflux::SessionExpired => e
UNCOV
51
      raise unless e.is_a?(Mediaflux::SessionExpired) || e.cause.is_a?(Mediaflux::SessionExpired)
6✔
UNCOV
52
      if session[:active_web_user]
6✔
UNCOV
53
        redirect_to mediaflux_passthru_path(path: request.path)
3✔
UNCOV
54
      elsif session_error_handler
3✔
UNCOV
55
        retry
2✔
56
      else
UNCOV
57
        raise
1✔
58
      end
59
    end
60

61
    def mediaflux_login_errors
5✔
62
      yield
537✔
63
    rescue Mediaflux::SessionError
64
      if session_error_handler
×
65
        retry
×
66
      else
67
        raise
×
68
      end
69
    end
70

71
    def session_error_handler
5✔
UNCOV
72
      @retry_count ||= 0
3✔
UNCOV
73
      @retry_count += 1
3✔
74

UNCOV
75
      current_user.clear_mediaflux_session(session)
3✔
UNCOV
76
      current_user.mediaflux_from_session(session)
3✔
UNCOV
77
      @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
3✔
78
    end
79

80
    def emulate_user
5✔
81
      return if Rails.env.production?
537✔
82
      return if current_user.blank? || !current_user.trainer
507✔
83

UNCOV
84
      if session[:emulation_role]
42✔
UNCOV
85
        if session[:emulation_role] == "Eligible Data Sponsor"
19✔
UNCOV
86
          emulate_sponsor
3✔
UNCOV
87
        elsif session[:emulation_role] == "Eligible Data Manager"
16✔
UNCOV
88
          emulate_manager
3✔
UNCOV
89
        elsif session[:emulation_role] == "System Administrator"
13✔
UNCOV
90
          emulate_sysadmin
12✔
UNCOV
91
        elsif session[:emulation_role] == "Eligible Data User"
1✔
UNCOV
92
          emulate_data_user
1✔
93
        elsif session[:emulation_role] == "Return to Self"
×
94
          return_to_self
×
95
        end
96
      end
97
    end
98

99
    def emulate_sponsor
5✔
UNCOV
100
      current_user.eligible_sponsor = true
3✔
UNCOV
101
      current_user.eligible_manager = false
3✔
UNCOV
102
      current_user.sysadmin = false
3✔
103
    end
104

105
    def emulate_manager
5✔
UNCOV
106
      current_user.eligible_manager = true
3✔
UNCOV
107
      current_user.eligible_sponsor = false
3✔
UNCOV
108
      current_user.sysadmin = false
3✔
109
    end
110

111
    def emulate_sysadmin
5✔
UNCOV
112
      current_user.sysadmin = true
12✔
UNCOV
113
      current_user.eligible_manager = false
12✔
UNCOV
114
      current_user.eligible_sponsor = false
12✔
115
    end
116

117
    def emulate_data_user
5✔
UNCOV
118
      current_user.eligible_sponsor = false
1✔
UNCOV
119
      current_user.eligible_manager = false
1✔
UNCOV
120
      current_user.sysadmin = false
1✔
UNCOV
121
      current_user.trainer = false
1✔
122
    end
123

124
    def return_to_self
5✔
125
      current_user.eligible_sponsor = false
×
126
      current_user.eligible_manager = false
×
127
      current_user.sysadmin = false
×
128
    end
129

130
    def downtime_check
5✔
131
      if Flipflop.disable_login?
507✔
UNCOV
132
        if current_user&.eligible_sysadmin?
3✔
UNCOV
133
          flash[:notice] = I18n.t(:only_sysadmin_users)
2✔
134
        else
UNCOV
135
          redirect_to root_path
1✔
UNCOV
136
          flash[:notice] = I18n.t(:no_login_currently)
1✔
137
        end
138
      end
139
    end
140
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