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

pulibrary / tigerdata-app / 2757569b-a064-4cee-9331-aad3bf7cbc86

12 Sep 2024 05:16PM UTC coverage: 85.949% (-4.3%) from 90.227%
2757569b-a064-4cee-9331-aad3bf7cbc86

push

circleci

web-flow
Use circleci orb to report coverage (#918)

4 of 4 branches covered (100.0%)

2147 of 2498 relevant lines covered (85.95%)

295.77 hits per line

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

87.27
/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
  around_action :mediaflux_session
1✔
6
  before_action :emulate_user
1✔
7

8
  def new_session_path(_scope)
1✔
9
    new_user_session_path
×
10
  end
11

12
  def require_admin_user
1✔
13
    head :forbidden unless current_user&.eligible_sysadmin?
4✔
14
  end
15

16
  private
1✔
17

18
    def mediaflux_session
1✔
19
      # this requires a connection to mediaflux... for ease of development we do not want to require this
20
      # current_user&.mediaflux_from_session(session)
21
      yield
216✔
22
    rescue Mediaflux::SessionExpired
23
      @retry_count ||= 0
4✔
24
      @retry_count += 1
4✔
25
      current_user.clear_mediaflux_session(session)
4✔
26
      current_user.mediaflux_from_session(session)
4✔
27
      if @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
4✔
28
        retry
3✔
29
      else
30
        raise
1✔
31
      end
32
    end
33

34
    def emulate_user
1✔
35
      return if Rails.env.production?
216✔
36
      return if current_user.blank? || !current_user.trainer
216✔
37

38
      if session[:emulation_role]
20✔
39
        if session[:emulation_role] == "Eligible Data Sponsor"
9✔
40
          emulate_sponsor
3✔
41
        elsif session[:emulation_role] == "Eligible Data Manager"
6✔
42
          emulate_manager
3✔
43
        elsif session[:emulation_role] == "System Administrator"
3✔
44
          emulate_sysadmin
2✔
45
        elsif session[:emulation_role] == "Eligible Data User"
1✔
46
          emulate_data_user
1✔
47
        elsif session[:emulation_role] == "Return to Self"
×
48
          return_to_self
×
49
        end
50
      end
51
    end
52

53
    def emulate_sponsor
1✔
54
      current_user.eligible_sponsor = true
3✔
55
      current_user.eligible_manager = false
3✔
56
      current_user.sysadmin = false
3✔
57
    end
58

59
    def emulate_manager
1✔
60
      current_user.eligible_manager = true
3✔
61
      current_user.eligible_sponsor = false
3✔
62
      current_user.sysadmin = false
3✔
63
    end
64

65
    def emulate_sysadmin
1✔
66
      current_user.sysadmin = true
2✔
67
      current_user.eligible_manager = false
2✔
68
      current_user.eligible_sponsor = false
2✔
69
    end
70

71
    def emulate_data_user
1✔
72
      current_user.eligible_sponsor = false
1✔
73
      current_user.eligible_manager = false
1✔
74
      current_user.trainer = false
1✔
75
      current_user.sysadmin = false
1✔
76
    end
77

78
    def return_to_self
1✔
79
      current_user.trainer = true
×
80
      current_user.eligible_sponsor = false
×
81
      current_user.eligible_manager = false
×
82
      current_user.sysadmin = false
×
83
    end
84
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