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

pulibrary / tigerdata-app / 62d2653f-d28c-4b7b-bbf1-1e4879e08c0c

05 Nov 2025 06:00PM UTC coverage: 91.5% (+0.03%) from 91.467%
62d2653f-d28c-4b7b-bbf1-1e4879e08c0c

push

circleci

web-flow
upgrade mflux_dev to v0.18.0 (#2144)

2831 of 3094 relevant lines covered (91.5%)

988.81 hits per line

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

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

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

21
  def show
3✔
22
    if current_user.developer || current_user.sysadmin || current_user.trainer
36✔
23
      @request_model = Request.find(params[:id])
28✔
24
      @request_presenter = RequestPresenter.new(@request_model)
28✔
25
      add_breadcrumb("New Project Request", new_project_project_info_path)
28✔
26
      render :show
28✔
27
    else
28
      error_message = "You do not have access to this page."
8✔
29
      flash[:notice] = error_message
8✔
30
      redirect_to dashboard_path
8✔
31
    end
32
  end
33

34
  # rubocop:disable Metrics/AbcSize
35
  # rubocop:disable Metrics/MethodLength
36
  # rubocop:disable Metrics/PerceivedComplexity
37
  # rubocop:disable Metrics/CyclomaticComplexity
38
  def approve
3✔
39
    if eligible_to_approve
36✔
40
      @request_model = Request.find(params[:id])
26✔
41
      if @request_model.valid_to_submit?
26✔
42
        project = @request_model.approve(current_user)
20✔
43
        @request_model.destroy!
16✔
44
        stub_message = "The request has been approved and this project was created in the TigerData web portal.  The request has been processed and deleted."
16✔
45
        TigerdataMailer.with(project_id: project.id, approver: current_user).project_creation.deliver_later
16✔
46
        redirect_to project_path(project.id), notice: stub_message
16✔
47
      else
48
        redirect_to new_project_review_and_submit_path(@request_model)
6✔
49
      end
50
    else
51
      error_message = "You do not have access to this page."
10✔
52
      flash[:notice] = error_message
10✔
53
      redirect_to dashboard_path
10✔
54
    end
55
  rescue StandardError => ex
56
    if ex.is_a?(Mediaflux::SessionExpired) || ex.cause.is_a?(Mediaflux::SessionExpired)
4✔
57
      raise
2✔
58
    elsif ex.is_a?(ProjectCreate::ProjectCreateError) && ex.message.include?("Session expired for token")
2✔
59
      raise Mediaflux::SessionExpired
2✔
60
    else
61
      Rails.logger.error "Error approving request #{params[:id]}. Details: #{ex.message}"
×
62
      Honeybadger.notify "Error approving request #{params[:id]}. Details: #{ex.message}"
×
63
      flash[:notice] = "Error approving request #{params[:id]}"
×
64
      redirect_to request_path(@request_model)
×
65
    end
66
  end
67
  # rubocop:enable Metrics/MethodLength
68
  # rubocop:enable Metrics/AbcSize
69
  # rubocop:enable Metrics/PerceivedComplexity
70
  # rubocop:enable Metrics/CyclomaticComplexity
71

72
  private
3✔
73

74
    def set_breadcrumbs
3✔
75
      add_breadcrumb("Dashboard", dashboard_path)
82✔
76
    end
77

78
    def eligible_to_approve
3✔
79
      current_user.sysadmin || (current_user.developer && !Rails.env.production?)
36✔
80
    end
81
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