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

pulibrary / tigerdata-app / a93f1bba-a389-4e05-8a0a-71cf37e8f475

23 Sep 2025 08:09PM UTC coverage: 88.877%. First build
a93f1bba-a389-4e05-8a0a-71cf37e8f475

Pull #1892

circleci

JaymeeH
Handle mediaflux session errors in request controller
Pull Request #1892: Handle mediaflux session errors in request controller

4 of 15 new or added lines in 1 file covered. (26.67%)

2573 of 2895 relevant lines covered (88.88%)

319.12 hits per line

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

69.23
/app/controllers/requests_controller.rb
1
# frozen_string_literal: true
2
class RequestsController < ApplicationController
1✔
3
  before_action :set_breadcrumbs
1✔
4
  around_action :mediaflux_session_errors
1✔
5

6
  # GET /requests
7
  def index
1✔
8
    if current_user.eligible_sysadmin?
5✔
9
      add_breadcrumb("Project Requests - All")
2✔
10
      @draft_requests = Request.where(state: Request::DRAFT).map do |request|
2✔
11
        request.project_title = "no title set" if request.project_title.blank?
×
12
        request
×
13
      end
14
      @submitted_requests = Request.where(state: Request::SUBMITTED)
2✔
15
    else
16
      error_message = "You do not have access to this page."
3✔
17
      flash[:notice] = error_message
3✔
18
      redirect_to dashboard_path
3✔
19
    end
20
  end
21

22
  def show
1✔
23
    if current_user.developer || current_user.sysadmin || current_user.trainer
15✔
24
      @request_model = Request.find(params[:id])
11✔
25
      add_breadcrumb("Requests", requests_path)
11✔
26
      add_breadcrumb(@request_model.project_title, request_path(@request_model))
11✔
27
      render :show
11✔
28
    else
29
      error_message = "You do not have access to this page."
4✔
30
      flash[:notice] = error_message
4✔
31
      redirect_to dashboard_path
4✔
32
    end
33
  end
34

35
  # rubocop:disable Metrics/MethodLength
36
  # rubocop:disable Metrics/AbcSize
37
  def approve
1✔
38
    if current_user.developer || current_user.sysadmin || current_user.trainer
5✔
39
      @request_model = Request.find(params[:id])
5✔
40
      if @request_model.valid_to_submit?
5✔
41
        project = @request_model.approve(current_user)
4✔
42
        @request_model.destroy
4✔
43
        stub_message = "The request has been approved and this project was created in the TigerData web portal.  The request has been processed and deleted."
4✔
44
        TigerdataMailer.with(project_id: project.id, approver: current_user).project_creation.deliver_later
4✔
45
        redirect_to project_path(project.id), notice: stub_message
4✔
46
      else
47
        redirect_to new_project_review_and_submit_path(@request_model)
1✔
48
      end
49
    else
50
      error_message = "You do not have access to this page."
×
51
      flash[:notice] = error_message
×
52
      redirect_to dashboard_path
×
53
    end
54
    # rescue StandardError => ex
55
    #   Rails.logger.error "Error approving request #{params[:id]}. Details: #{ex.message}"
56
    #   Honeybadger.notify "Error approving request #{params[:id]}. Details: #{ex.message}"
57
    #   flash[:notice] = "Error approving request #{params[:id]}"
58
    #   redirect_to request_path(@request_model)
59
  end
60
  # rubocop:enable Metrics/AbcSize
61
  # rubocop:enable Metrics/MethodLength
62

63
  private
1✔
64

65
    def set_breadcrumbs
1✔
66
      add_breadcrumb("Dashboard", dashboard_path)
25✔
67
    end
68

69
    def mediaflux_session_errors
1✔
70
      yield
25✔
71
    rescue ActionView::Template::Error, Mediaflux::SessionExpired => e
NEW
72
      raise unless e.is_a?(Mediaflux::SessionExpired) || e.cause.is_a?(Mediaflux::SessionExpired)
×
NEW
73
      if session[:active_web_user]
×
NEW
74
        redirect_to mediaflux_passthru_path(path: request.path)
×
NEW
75
      elsif session_error_handler
×
NEW
76
        retry
×
77
      else
NEW
78
        raise
×
79
      end
80
    end
81

82
    def session_error_handler
1✔
NEW
83
      @retry_count ||= 0
×
NEW
84
      @retry_count += 1
×
85

NEW
86
      current_user.clear_mediaflux_session(session)
×
NEW
87
      current_user.mediaflux_from_session(session)
×
NEW
88
      @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
×
89
    end
90
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