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

pulibrary / tigerdata-app / bd039a2a-6f1b-4f1e-b08e-58dd6b70d54e

25 Nov 2025 08:28PM UTC coverage: 91.374% (+11.8%) from 79.623%
bd039a2a-6f1b-4f1e-b08e-58dd6b70d54e

Pull #2247

circleci

hectorcorrea
Added tests to the dashboard for the new data
Pull Request #2247: Display the data sponsor and data manager in the dashboard listing

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

724 existing lines in 41 files now uncovered.

2913 of 3188 relevant lines covered (91.37%)

563.89 hits per line

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

92.31
/app/controllers/request_wizards_controller.rb
1
# frozen_string_literal: true
2
class RequestWizardsController < ApplicationController
5✔
3
  layout "wizard"
5✔
4
  before_action :set_breadcrumbs
5✔
5

6
  before_action :set_request_model, only: %i[save]
5✔
7
  before_action :exit_without_saving, only: %i[save]
5✔
8
  before_action :set_or_init_request_model, only: %i[show]
5✔
9
  before_action :check_access
5✔
10

11
  attr_reader :request_model
5✔
12

13
  # GET /request_wizards/1
14
  def show
5✔
15
    # show the current wizard step form
16
    render_current
78✔
17
  end
18

19
  # PUT /request_wizards/1/save
20
  def save
5✔
21
    # save and render dashboard
22
    save_request
88✔
23
    case params[:commit]
88✔
24
    when "Back"
25
      render_back
19✔
26
    when "Next", "Submit"
27
      render_next
32✔
28
    else
29
      if params[:commit].start_with?("http")
37✔
30
        # Go directly to the step the user clicked on
31
        redirect_to params[:commit]
6✔
32
      elsif params[:go_to_dashboard] == "yes"
31✔
33
        # The user clicked on the "Dashboard" breadcrumb
34
        redirect_to dashboard_path
×
35
      else
36
        redirect_to request_path(@request_model)
31✔
37
      end
38
    end
39
  end
40

41
  private
5✔
42

43
    def check_access
5✔
44
      return if user_eligible_to_modify_request?
199✔
45

46
      # request can not be modified by this user, redirect to dashboard
UNCOV
47
      error_message = "You do not have access to this page."
33✔
UNCOV
48
      flash[:notice] = error_message
33✔
UNCOV
49
      redirect_to dashboard_path
33✔
50
    end
51

52
    def exit_without_saving
5✔
53
      if params[:commit] == "Exit without Saving"
103✔
54
        if @request_model.nil?
1✔
55
          redirect_to dashboard_path
1✔
56
        else
57
          redirect_to request_path(@request_model)
×
58
        end
59
      end
60
    end
61

62
    def render_current
5✔
63
      raise "Must be implemented"
×
64
    end
65

66
    def render_next
5✔
67
      raise "Must be implemented"
×
68
    end
69

70
    def render_back
5✔
71
      raise "Must be implemented"
×
72
    end
73

74
    # Use callbacks to share common setup or constraints between actions.
75
    def set_request_model
5✔
76
      # do nothing if we are bailing out without creating a request2
77
      return if params[:request_id] == "0" && params[:commit] == "Exit without Saving"
103✔
78

79
      @request_model = if params[:request_id] == "0"
102✔
80
                         # on the first page with a brand new request that has not been created
81
                         req = Request.create(requested_by: current_user.uid)
11✔
82
                         update_sidebar_url(req)
11✔
83
                         req
11✔
84
                       else
85
                         # on a page when the request has already been created
86
                         Request.find(params[:request_id])
91✔
87
                       end
88
    end
89

90
    def update_sidebar_url(request_model)
5✔
91
      return unless params[:commit].start_with?("http")
11✔
92

93
      # take of the zero in the url and replace it with the real request id
94
      params[:commit] = "#{params[:commit][0..-2]}#{request_model.id}"
4✔
95
    end
96

97
    # set if id is present or initialize a blank request if not
98
    def set_or_init_request_model
5✔
99
      @princeton_departments = Affiliation.all
97✔
100
      @request_model = if params[:request_id].blank?
97✔
UNCOV
101
                         Request.new(id: 0, requested_by: current_user.uid)
17✔
102
                       else
103
                         Request.find(params[:request_id])
80✔
104
                       end
105
    end
106

107
    def save_request
5✔
108
      request_model.update(request_params)
88✔
109
    end
110

111
    # Only allow a list of trusted parameters through.
112
    def request_params
5✔
113
      request_params = params.fetch(:request, {}).permit(:request_title, :project_title, :state, :data_sponsor, :data_manager,
88✔
114
                                        :project_purpose, :description, :parent_folder, :project_folder, :project_id, :quota,
115
                                        :requested_by, :storage_size, :storage_unit, :number_of_files, :hpc, :smb, :globus, user_roles: [], departments: [])
116
      request_params[:storage_unit] ||= "TB"
88✔
117
      if request_params[:departments].present?
88✔
UNCOV
118
        request_params[:departments] = clean_departments(request_params[:departments])
25✔
119
      end
120
      if request_params[:user_roles].present?
88✔
121
        request_params[:user_roles] = request_params[:user_roles].compact_blank.map do |role_str|
3✔
122
          json = JSON.parse(role_str)
4✔
123
          json["read_only"] = params[:request]["read_only_#{json['uid']}"] == "true"
4✔
124
          json
4✔
125
        end
126
      end
127
      request_params
88✔
128
    end
129

130
    def clean_departments(departments)
5✔
UNCOV
131
      uniq_departments = departments.uniq
25✔
UNCOV
132
      uniq_departments.compact_blank.map { |dep_str| JSON.parse(dep_str) }
45✔
133
    end
134

135
    def set_breadcrumbs
5✔
136
      add_breadcrumb("Dashboard", dashboard_path)
200✔
137
    end
138

139
    def user_eligible_to_modify_request?
5✔
140
      # elevated privs for the current user
141
      if current_user.sysadmin || (current_user.developer && !Rails.env.production?)
199✔
142
        true
140✔
143
      # current user is the requestor
UNCOV
144
      elsif (@request_model.requested_by == current_user.uid) && !@request_model.submitted?
59✔
UNCOV
145
        true
26✔
146
      # a brand new request
UNCOV
147
      elsif params[:request_id].blank?
33✔
148
        true
×
149
      # no access for any other reason
150
      else
UNCOV
151
        false
33✔
152
      end
153
    end
154
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