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

pulibrary / tigerdata-app / 611084c9-342d-4394-a4ed-99af3ac79af4

03 Dec 2025 07:02PM UTC coverage: 71.819% (+0.5%) from 71.313%
611084c9-342d-4394-a4ed-99af3ac79af4

push

circleci

web-flow
Allow requested by or approved by information to be empty (#2267)

There are no tests yet, but the detail page may not load for you (like
it did not load for me)

0 of 49 new or added lines in 3 files covered. (0.0%)

997 existing lines in 42 files now uncovered.

2444 of 3403 relevant lines covered (71.82%)

336.49 hits per line

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

0.0
/app/controllers/edit_requests_controller.rb
1
# frozen_string_literal: true
UNCOV
2
class EditRequestsController < ApplicationController
×
UNCOV
3
  layout "edit_request"
×
UNCOV
4
  before_action :set_breadcrumbs
×
5

UNCOV
6
  before_action :set_request_model, only: %i[edit update]
×
UNCOV
7
  before_action :check_access
×
8

9
  # GET /edit_requests/1/edit
UNCOV
10
  def edit
×
UNCOV
11
    add_breadcrumb(@request_model.project_title, request_path(@request_model))
×
UNCOV
12
    add_breadcrumb("Edit Submitted Request")
×
UNCOV
13
  end
×
14

15
  # PATCH/PUT /edit_requests/1 or /edit_requests/1.json
UNCOV
16
  def update
×
UNCOV
17
    respond_to do |format|
×
UNCOV
18
      if @request_model.update(request_params) && @request_model.valid_to_submit?
×
UNCOV
19
        format.html { redirect_to request_url(@request_model), notice: I18n.t(:successful_update) }
×
UNCOV
20
        format.json { render :show, status: :ok, location: @request_model }
×
UNCOV
21
      else
×
UNCOV
22
        format.html { render :edit, status: :unprocessable_entity }
×
UNCOV
23
        format.json { render json: @request_model.errors, status: :unprocessable_entity }
×
UNCOV
24
      end
×
UNCOV
25
    end
×
UNCOV
26
  end
×
27

UNCOV
28
  private
×
29

30
    # Use callbacks to share common setup or constraints between actions.
UNCOV
31
    def set_request_model
×
UNCOV
32
      @princeton_departments = Affiliation.all
×
UNCOV
33
      @request_model = Request.find(params[:id])
×
UNCOV
34
    end
×
35

36
    # Only allow a list of trusted parameters through.
UNCOV
37
    def request_params
×
UNCOV
38
      request_params = params.fetch(:request, {}).permit(:request_title, :project_title, :state, :data_sponsor, :data_manager,
×
UNCOV
39
                                        :description, :project_purpose, :parent_folder, :project_folder, :project_id, :quota,
×
UNCOV
40
                                        :requested_by, :storage_size, :storage_unit, :number_of_files, :hpc, :smb, :globus,
×
UNCOV
41
                                        user_roles: [], departments: [])
×
42

UNCOV
43
      if request_params[:departments].present?
×
UNCOV
44
        request_params[:departments] = request_params[:departments].compact_blank.map { |dep_str| JSON.parse(dep_str) }
×
UNCOV
45
      end
×
UNCOV
46
      if request_params[:user_roles].present?
×
47
        request_params[:user_roles] = request_params[:user_roles].compact_blank.map { |role_str| JSON.parse(role_str) }
×
UNCOV
48
      end
×
UNCOV
49
      move_approved_values(request_params)
×
UNCOV
50
    end
×
51

UNCOV
52
    def move_approved_values(request_params)
×
UNCOV
53
      if request_params[:quota].present?
×
UNCOV
54
        request_params[:approved_quota] = request_params.delete(:quota)
×
UNCOV
55
      end
×
UNCOV
56
      if request_params[:storage_size].present?
×
57
        request_params[:approved_storage_size] = request_params.delete(:storage_size)
×
UNCOV
58
      end
×
UNCOV
59
      if request_params[:storage_unit].present?
×
60
        request_params[:approved_storage_unit] = request_params.delete(:storage_unit)
×
UNCOV
61
      end
×
UNCOV
62
      request_params
×
UNCOV
63
    end
×
64

UNCOV
65
    def set_breadcrumbs
×
UNCOV
66
      add_breadcrumb("Dashboard", dashboard_path)
×
UNCOV
67
      add_breadcrumb("Requests", requests_path)
×
UNCOV
68
    end
×
69

UNCOV
70
    def check_access
×
UNCOV
71
      return if user_eligible_to_modify_request?
×
72

73
      # request can not be modified by this user, redirect to the request
UNCOV
74
      flash[:notice] = I18n.t(:no_modify_submitted)
×
UNCOV
75
      redirect_to request_path(@request_model)
×
UNCOV
76
    end
×
77

UNCOV
78
    def user_eligible_to_modify_request?
×
79
      # elevated privs for the current user
UNCOV
80
      if current_user.sysadmin || (current_user.developer && !Rails.env.production?)
×
UNCOV
81
        true
×
UNCOV
82
      else
×
UNCOV
83
        false
×
UNCOV
84
      end
×
UNCOV
85
    end
×
UNCOV
86
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