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

pulibrary / tigerdata-app / a75ab644-69de-42d4-af3b-04f2c06f5129

28 Oct 2025 03:36PM UTC coverage: 91.333% (+0.2%) from 91.162%
a75ab644-69de-42d4-af3b-04f2c06f5129

push

circleci

web-flow
Dashboard displays projects straights from Mediaflux (#2057)

The list of projects displayed in the **Dashboard** now comes straight
from Mediaflux.

The code in this PR is a bit messy because the
`ProjectDashboardPresenter` inherits from the `ProjectShowPresenter` and
this PR only updates the project information in the Dashboard (not on
the project Show page). Therefore there a few extra `if/else` statements
to account for the two kind of data that the presenter might receive. I
am hoping these `if/else` statements will be removed once we update the
Project Show page
(https://github.com/pulibrary/tigerdata-app/issues/2039) to also fetch
its data directly from Mediaflux.

Closes #2037 (and #2038)

Example in QA of the Dashboard showing **only my Projects** in the
Projects tab and **all the projects** in the Admin tab (I am an
Administrator in QA):

<img width="1211" height="848" alt="mine"
src="https://github.com/user-attachments/assets/c5fa4ace-fa1d-4529-8f89-1f23a0ab8b3d"
/>

<img width="1187" height="708" alt="not-mine"
src="https://github.com/user-attachments/assets/218323ec-4c78-4b15-8103-c50d26c9a690"
/>

32 of 87 new or added lines in 4 files covered. (36.78%)

699 existing lines in 26 files now uncovered.

2803 of 3069 relevant lines covered (91.33%)

486.99 hits per line

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

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

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

UNCOV
21
  def show
2✔
22
    if current_user.developer || current_user.sysadmin || current_user.trainer
16✔
23
      @request_model = Request.find(params[:id])
12✔
24
      @request_presenter = RequestPresenter.new(@request_model)
12✔
25
      add_breadcrumb("Requests", requests_path)
12✔
26
      add_breadcrumb(@request_model.project_title, request_path(@request_model))
12✔
27
      render :show
12✔
UNCOV
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✔
UNCOV
32
    end
UNCOV
33
  end
34

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

UNCOV
73
  private
2✔
74

UNCOV
75
    def set_breadcrumbs
2✔
UNCOV
76
      add_breadcrumb("Dashboard", dashboard_path)
39✔
UNCOV
77
    end
78

UNCOV
79
    def eligible_to_approve
2✔
UNCOV
80
      current_user.sysadmin || (current_user.developer && !Rails.env.production?)
18✔
UNCOV
81
    end
UNCOV
82
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