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

pulibrary / tigerdata-app / 27ab8946-b5ca-4972-b630-0965c50234b8

17 Sep 2025 05:38PM UTC coverage: 88.687%. First build
27ab8946-b5ca-4972-b630-0965c50234b8

Pull #1863

circleci

JaymeeH
Convert read/only and read/write roles into a project
Pull Request #1863: Convert read/only and read/write roles into a project

4 of 6 new or added lines in 2 files covered. (66.67%)

2532 of 2855 relevant lines covered (88.69%)

306.13 hits per line

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

70.83
/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.developer || current_user.sysadmin || current_user.trainer
16✔
24
      @request_model = Request.find(params[:id])
12✔
25
      add_breadcrumb("Requests", requests_path)
12✔
26
      add_breadcrumb(@request_model.project_title, request_path(@request_model))
12✔
27
      render :show
12✔
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
    # rubocop:disable Metrics/MethodLength
66
    def parse_request_metadata(request)
1✔
67
      project_directory = "/tigerdata/#{request[:parent_folder]}/#{request[:project_folder]}"
×
68
      departments = request[:departments].map { |d| d["name"] }
×
NEW
69
      read_only_users = request[:user_roles].map { |u| u["uid"] if u["read_only"] || u["read_only"].nil? }
×
NEW
70
      read_write_users = request[:user_roles].map { |u| u["uid"] if u["read_only"] == false }
×
71
      {
72
        title: request[:project_title],
×
73
        description: request[:description],
74
        status: Project::APPROVED_STATUS,
75
        data_sponsor: request[:data_sponsor],
76
        data_manager: request[:data_manager],
77
        departments: departments,
78
        data_user_read_only: read_only_users,
79
        data_user_read_write: read_write_users.compact,
80
        project_directory: project_directory,
81
        storage_capacity: {
82
          size: {
83
            approved: request[:quota].split(" ").first,
84
            requested: request[:quota].split(" ").first
85
          },
86
          unit: {
87
            approved: request[:storage_unit],
88
            requested: request[:storage_unit]
89
          }
90
        },
91
        storage_performance_expectations: { requested: "Standard", approved: "Standard" },
92
        created_by: nil,
93
        created_on: request[:created_at]
94
      }
95
    end
96
    # rubocop:enable Metrics/MethodLength
97

98
    def set_breadcrumbs
1✔
99
      add_breadcrumb("Dashboard", dashboard_path)
26✔
100
    end
101
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