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

pulibrary / tigerdata-app / 20221123-c4fc-472d-9eea-6c8332d605d3

11 Nov 2025 02:31PM UTC coverage: 87.611% (-3.8%) from 91.371%
20221123-c4fc-472d-9eea-6c8332d605d3

Pull #2175

circleci

web-flow
Merge branch 'main' into i2166-string-reverse
Pull Request #2175: Show the status of our java plugin

5 of 7 new or added lines in 1 file covered. (71.43%)

392 existing lines in 20 files now uncovered.

2758 of 3148 relevant lines covered (87.61%)

349.48 hits per line

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

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

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

11
  attr_reader :request_model
4✔
12

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

19
  # PUT /request_wizards/1/save
20
  def save
4✔
21
    # save and render dashboard
22
    save_request
52✔
23
    case params[:commit]
52✔
24
    when "Back"
25
      render_back
11✔
26
    when "Next", "Submit"
27
      render_next
13✔
28
    else
29
      if params[:commit].start_with?("http")
28✔
30
        # Go directly to the step the user clicked on
31
        redirect_to params[:commit]
×
32
      else
33
        redirect_to request_path(@request_model)
28✔
34
      end
35
    end
36
  end
37

38
  private
4✔
39

40
    def check_access
4✔
41
      return if user_eligible_to_modify_request?
116✔
42

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

49
    def exit_without_saving
4✔
50
      if params[:commit] == "Exit without Saving"
66✔
51
        if @request_model.nil?
×
52
          redirect_to dashboard_path
×
53
        else
54
          redirect_to request_path(@request_model)
×
55
        end
56
      end
57
    end
58

59
    def render_current
4✔
60
      raise "Must be implemented"
×
61
    end
62

63
    def render_next
4✔
64
      raise "Must be implemented"
×
65
    end
66

67
    def render_back
4✔
68
      raise "Must be implemented"
×
69
    end
70

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

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

87
    def update_sidebar_url(request_model)
4✔
88
      return unless params[:commit].start_with?("http")
×
89

90
      # take of the zero in the url and replace it with the real request id
91
      params[:commit] = "#{params[:commit][0..-2]}#{request_model.id}"
×
92
    end
93

94
    # set if id is present or initialize a blank request if not
95
    def set_or_init_request_model
4✔
96
      @princeton_departments = Affiliation.all
50✔
97
      @project_purposes = [["Research", "research"], ["Administrative", "administrative"], ["Teaching", "teaching"]]
50✔
98
      @request_model = if params[:request_id].blank?
50✔
UNCOV
99
                         Request.new(id: 0, requested_by: current_user.uid)
2✔
100
                       else
101
                         Request.find(params[:request_id])
48✔
102
                       end
103
    end
104

105
    def save_request
4✔
106
      request_model.update(request_params)
52✔
107
    end
108

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

128
    def set_breadcrumbs
4✔
129
      add_breadcrumb("Dashboard", dashboard_path)
116✔
130
    end
131

132
    def user_eligible_to_modify_request?
4✔
133
      # elevated privs for the current user
134
      if current_user.sysadmin || (current_user.developer && !Rails.env.production?)
116✔
135
        true
79✔
136
      # current user is the requestor
UNCOV
137
      elsif (@request_model.requested_by == current_user.uid) && !@request_model.submitted?
37✔
UNCOV
138
        true
4✔
139
      # a brand new request
UNCOV
140
      elsif params[:request_id].blank?
33✔
141
        true
×
142
      # no access for any other reason
143
      else
UNCOV
144
        false
33✔
145
      end
146
    end
147
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