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

pulibrary / tigerdata-app / 778e066a-b504-426e-bca7-26699613f04c

31 Oct 2024 07:02PM UTC coverage: 83.794% (-0.5%) from 84.27%
778e066a-b504-426e-bca7-26699613f04c

Pull #875

circleci

carolyncole
Allow UI to load eve if mediaflux is down
Pull Request #875: Getting an extra cas ticket that we could theoretically pass along to mediaflux

4 of 4 branches covered (100.0%)

7 of 23 new or added lines in 3 files covered. (30.43%)

9 existing lines in 3 files now uncovered.

2182 of 2604 relevant lines covered (83.79%)

297.69 hits per line

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

88.71
/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
  helper_method :breadcrumbs
1✔
9

10
  def new_session_path(_scope)
1✔
UNCOV
11
    new_user_session_path
×
12
  end
13

14
  def after_sign_in_path_for(_resource)
1✔
15
    mediaflux_passthru_path
1✔
16
    # "/users/#{@user.id}"
17
  end
18

19
  def require_admin_user
1✔
20
    head :forbidden unless current_user&.eligible_sysadmin?
4✔
21
  end
22

23
  def breadcrumbs
1✔
24
    @breadcrumbs ||= []
557✔
25
  end
26

27
  def add_breadcrumb(name, path = nil)
1✔
28
    breadcrumbs << Breadcrumb.new(name, path)
230✔
29
  end
30

31
  private
1✔
32

33
    def mediaflux_session
1✔
34
      # this requires a connection to mediaflux... for ease of development we do not want to require this
35
      # current_user&.mediaflux_from_session(session)
36
      yield
227✔
37
    rescue Mediaflux::SessionExpired
38
      @retry_count ||= 0
4✔
39
      @retry_count += 1
4✔
40
      current_user.clear_mediaflux_session(session)
4✔
41
      current_user.mediaflux_from_session(session)
4✔
42
      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✔
43
        retry
3✔
44
      else
45
        raise
1✔
46
      end
47
    end
48

49
    def emulate_user
1✔
50
      return if Rails.env.production?
227✔
51
      return if current_user.blank? || !current_user.trainer
227✔
52

53
      if session[:emulation_role]
20✔
54
        if session[:emulation_role] == "Eligible Data Sponsor"
9✔
55
          emulate_sponsor
3✔
56
        elsif session[:emulation_role] == "Eligible Data Manager"
6✔
57
          emulate_manager
3✔
58
        elsif session[:emulation_role] == "System Administrator"
3✔
59
          emulate_sysadmin
2✔
60
        elsif session[:emulation_role] == "Eligible Data User"
1✔
61
          emulate_data_user
1✔
62
        elsif session[:emulation_role] == "Return to Self"
×
63
          return_to_self
×
64
        end
65
      end
66
    end
67

68
    def emulate_sponsor
1✔
69
      current_user.eligible_sponsor = true
3✔
70
      current_user.eligible_manager = false
3✔
71
      current_user.sysadmin = false
3✔
72
    end
73

74
    def emulate_manager
1✔
75
      current_user.eligible_manager = true
3✔
76
      current_user.eligible_sponsor = false
3✔
77
      current_user.sysadmin = false
3✔
78
    end
79

80
    def emulate_sysadmin
1✔
81
      current_user.sysadmin = true
2✔
82
      current_user.eligible_manager = false
2✔
83
      current_user.eligible_sponsor = false
2✔
84
    end
85

86
    def emulate_data_user
1✔
87
      current_user.eligible_sponsor = false
1✔
88
      current_user.eligible_manager = false
1✔
89
      current_user.trainer = false
1✔
90
      current_user.sysadmin = false
1✔
91
    end
92

93
    def return_to_self
1✔
UNCOV
94
      current_user.trainer = true
×
UNCOV
95
      current_user.eligible_sponsor = false
×
UNCOV
96
      current_user.eligible_manager = false
×
UNCOV
97
      current_user.sysadmin = false
×
98
    end
99
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