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

pulibrary / tigerdata-app / 83b0522b-f91f-4e94-90b7-25006b51e19a

01 Dec 2025 05:39PM UTC coverage: 91.374% (+3.8%) from 87.594%
83b0522b-f91f-4e94-90b7-25006b51e19a

push

circleci

web-flow
Updating the department select to utilize LuxInputMultiSelect (#2251)

The component only allows an item to be selected once (only for non
async results which departments are).

fixes #2134

2913 of 3188 relevant lines covered (91.37%)

569.59 hits per line

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

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

6
  before_action :set_request_model, only: %i[edit update]
3✔
7
  before_action :check_access
3✔
8

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

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

28
  private
3✔
29

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

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

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

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

65
    def set_breadcrumbs
3✔
66
      add_breadcrumb("Dashboard", dashboard_path)
5✔
67
      add_breadcrumb("Requests", requests_path)
5✔
68
    end
69

70
    def check_access
3✔
71
      return if user_eligible_to_modify_request?
5✔
72

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

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

© 2025 Coveralls, Inc