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

pulibrary / tigerdata-app / 751a8b7a-3dcf-4fbf-b16e-522d27f88642

03 Nov 2025 02:30PM UTC coverage: 91.4% (+0.006%) from 91.394%
751a8b7a-3dcf-4fbf-b16e-522d27f88642

push

circleci

web-flow
Make sure all projects are fetched (not only the first 100) (#2131)

This fixes an issue we noted while testing in Staging since
Administrators should be able to fetch all projects that they have
access to, not only the first 100 (which is the default when not
indicating a `size` parameter to Mediaflux.)

3 of 3 new or added lines in 1 file covered. (100.0%)

191 existing lines in 11 files now uncovered.

2827 of 3093 relevant lines covered (91.4%)

486.73 hits per line

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

93.48
/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✔
UNCOV
11
    add_breadcrumb(@request_model.project_title, request_path(@request_model))
1✔
UNCOV
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✔
UNCOV
17
    respond_to do |format|
2✔
UNCOV
18
      if @request_model.update(request_params) && @request_model.valid_to_submit?
2✔
UNCOV
19
        format.html { redirect_to request_url(@request_model), notice: I18n.t(:successful_update) }
2✔
UNCOV
20
        format.json { render :show, status: :ok, location: @request_model }
1✔
21
      else
UNCOV
22
        format.html { render :edit, status: :unprocessable_entity }
2✔
UNCOV
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✔
UNCOV
32
      @princeton_departments = Affiliation.all
5✔
UNCOV
33
      @project_purposes = [["Research", "research"], ["Administrative", "administrative"], ["Teaching", "teaching"]]
5✔
UNCOV
34
      @request_model = Request.find(params[:id])
5✔
35
    end
36

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

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

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

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

71
    def check_access
3✔
UNCOV
72
      return if user_eligible_to_modify_request?
5✔
73

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

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