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

pulibrary / tigerdata-app / 8f14883f-0ae2-4a66-9ab3-48069d0f2a95

11 Aug 2025 10:06PM UTC coverage: 76.229% (-0.3%) from 76.482%
8f14883f-0ae2-4a66-9ab3-48069d0f2a95

Pull #1669

circleci

tpendragon
Try this.
Pull Request #1669: Testing pulibrary resource class

2264 of 2970 relevant lines covered (76.23%)

176.36 hits per line

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

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

5
  # GET /requests
6
  def index
1✔
7
    return head :forbidden unless Flipflop.new_project_request_wizard?
5✔
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.superuser || current_user.sysadmin || current_user.trainer
7✔
24
      @request_model = Request.find(params[:id])
4✔
25
      add_breadcrumb("Requests", requests_path)
4✔
26
      add_breadcrumb(@request_model.project_title, request_path(@request_model))
4✔
27
      render :show
4✔
28
    else
29
      error_message = "You do not have access to this page."
3✔
30
      flash[:notice] = error_message
3✔
31
      redirect_to dashboard_path
3✔
32
    end
33
  end
34

35
  # rubocop:disable Metrics/MethodLength
36
  def approve
1✔
37
    if current_user.superuser || current_user.sysadmin || current_user.trainer
1✔
38
      @request_model = Request.find(params[:id])
1✔
39
      if @request_model.valid_to_submit?
1✔
40
        project = @request_model.approve(current_user)
×
41
        @request_model.destroy
×
42
        stub_message = "The request has been approved and this project was created in the TigerData web portal.  The request has been processed and deleted."
×
43
        redirect_to project_path(project.id), notice: stub_message
×
44
      else
45
        redirect_to new_project_review_and_submit_path(@request_model)
1✔
46
      end
47
    else
48
      error_message = "You do not have access to this page."
×
49
      flash[:notice] = error_message
×
50
      redirect_to dashboard_path
×
51
    end
52
  rescue StandardError
53
    flash[:notice] = "Error approving request #{@request_model.id}"
×
54
    redirect_to request_path(@request_model)
×
55
  end
56
  # rubocop:enable Metrics/MethodLength
57

58
  private
1✔
59

60
    # rubocop:disable Metrics/MethodLength
61
    def parse_request_metadata(request)
1✔
62
      project_directory = "/tigerdata/#{request[:parent_folder]}/#{request[:project_folder]}"
×
63
      departments = request[:departments].map { |d| d["name"] }
×
64
      data_users = request[:user_roles].map { |u| u["uid"] }
×
65
      {
66
        title: request[:project_title],
×
67
        description: request[:description],
68
        status: Project::APPROVED_STATUS,
69
        data_sponsor: request[:data_sponsor],
70
        data_manager: request[:data_manager],
71
        departments: departments,
72
        data_user_read_only: data_users,
73
        project_directory: project_directory,
74
        storage_capacity: {
75
          size: {
76
            approved: request[:quota].split(" ").first,
77
            requested: request[:quota].split(" ").first
78
          },
79
          unit: {
80
            approved: request[:storage_unit],
81
            requested: request[:storage_unit]
82
          }
83
        },
84
        storage_performance_expectations: { requested: "Standard", approved: "Standard" },
85
        created_by: nil,
86
        created_on: request[:created_at]
87
      }
88
    end
89
    # rubocop:enable Metrics/MethodLength
90

91
    def set_breadcrumbs
1✔
92
      add_breadcrumb("Dashboard", dashboard_path)
13✔
93
    end
94
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