Skip to content

Commit 605f99d

Browse files
Merge branch 'rubyforgood:main' into 4473-expand-reminder-date-possibilities
2 parents 7e9dd92 + 6790e8b commit 605f99d

87 files changed

Lines changed: 1762 additions & 618 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cloud66/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rails:
22
configuration:
3-
ruby_version: 3.2.2
3+
ruby_version: 3.4.3

.rubocop.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ inherit_gem:
1010
inherit_from:
1111
.rubocop_todo.yml
1212

13-
require:
14-
- rubocop-rails
13+
plugins:
1514
- rubocop-performance
16-
- standard
1715
- standard-rails
1816
- standard-performance
1917

18+
require:
19+
- rubocop-rails
20+
- standard
21+
2022
AllCops:
2123
Exclude:
2224
- "vendor/**/*"

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.2
1+
3.4.3

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ gem 'bootsnap', require: false
108108
# Technically they don't need to be in this Gemfile at all, but we are pinning them to
109109
# specific versions for compatibility reasons.
110110
gem "nokogiri", ">= 1.10.4"
111-
gem "sprockets", "~> 4.2.1"
111+
gem "sprockets", "~> 4.2.2"
112112

113113
group :production, :staging do
114114
# Reduce the noise of logs and include custom fields to it for easier access

Gemfile.lock

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ GEM
130130
autoprefixer-rails (>= 9.1.0)
131131
popper_js (>= 2.11.6, < 3)
132132
sassc-rails (>= 2.0.0)
133-
brakeman (7.0.0)
133+
brakeman (7.0.2)
134134
racc
135135
bugsnag (6.27.1)
136136
concurrent-ruby (~> 1.0)
137137
builder (3.3.0)
138-
bullet (8.0.0)
138+
bullet (8.0.5)
139139
activesupport (>= 3.0.0)
140140
uniform_notifier (~> 1.11)
141141
capybara (3.40.0)
@@ -157,7 +157,7 @@ GEM
157157
tzinfo
158158
coderay (1.1.3)
159159
concurrent-ruby (1.3.5)
160-
connection_pool (2.5.0)
160+
connection_pool (2.5.3)
161161
crack (1.0.0)
162162
bigdecimal
163163
rexml
@@ -268,10 +268,10 @@ GEM
268268
concurrent-ruby (~> 1.1)
269269
webrick (~> 1.7)
270270
websocket-driver (~> 0.7)
271-
ffi (1.17.0)
272-
ffi (1.17.0-arm64-darwin)
273-
ffi (1.17.0-x86_64-darwin)
274-
ffi (1.17.0-x86_64-linux-gnu)
271+
ffi (1.17.2)
272+
ffi (1.17.2-arm64-darwin)
273+
ffi (1.17.2-x86_64-darwin)
274+
ffi (1.17.2-x86_64-linux-gnu)
275275
filterrific (5.2.7)
276276
flipper (1.3.4)
277277
concurrent-ruby (< 2)
@@ -329,8 +329,8 @@ GEM
329329
actionview (>= 5.0.0)
330330
activesupport (>= 5.0.0)
331331
jmespath (1.6.2)
332-
json (2.10.2)
333-
jwt (2.9.1)
332+
json (2.11.3)
333+
jwt (2.10.1)
334334
base64
335335
kaminari (1.2.2)
336336
activesupport (>= 4.1.0)
@@ -344,7 +344,7 @@ GEM
344344
activerecord
345345
kaminari-core (= 1.2.2)
346346
kaminari-core (1.2.2)
347-
knapsack_pro (8.1.0)
347+
knapsack_pro (8.1.2)
348348
rake
349349
language_server-protocol (3.17.0.4)
350350
launchy (3.0.0)
@@ -412,14 +412,14 @@ GEM
412412
net-protocol
413413
newrelic_rpm (9.16.0)
414414
nio4r (2.7.4)
415-
nokogiri (1.18.7)
415+
nokogiri (1.18.8)
416416
mini_portile2 (~> 2.8.2)
417417
racc (~> 1.4)
418-
nokogiri (1.18.7-arm64-darwin)
418+
nokogiri (1.18.8-arm64-darwin)
419419
racc (~> 1.4)
420-
nokogiri (1.18.7-x86_64-darwin)
420+
nokogiri (1.18.8-x86_64-darwin)
421421
racc (~> 1.4)
422-
nokogiri (1.18.7-x86_64-linux-gnu)
422+
nokogiri (1.18.8-x86_64-linux-gnu)
423423
racc (~> 1.4)
424424
notiffany (0.1.3)
425425
nenv (~> 0.1)
@@ -431,7 +431,7 @@ GEM
431431
rack (>= 1.2, < 4)
432432
snaky_hash (~> 2.0)
433433
version_gem (~> 1.1)
434-
omniauth (2.1.2)
434+
omniauth (2.1.3)
435435
hashie (>= 3.4.6)
436436
rack (>= 2.2.3)
437437
rack-protection
@@ -454,8 +454,8 @@ GEM
454454
paper_trail (16.0.0)
455455
activerecord (>= 6.1)
456456
request_store (~> 1.4)
457-
parallel (1.26.3)
458-
parser (3.3.7.4)
457+
parallel (1.27.0)
458+
parser (3.3.8.0)
459459
ast (~> 2.4.1)
460460
racc
461461
pdf-core (0.10.0)
@@ -505,7 +505,7 @@ GEM
505505
puma (6.6.0)
506506
nio4r (~> 2.0)
507507
racc (1.8.1)
508-
rack (3.1.12)
508+
rack (3.1.13)
509509
rack-mini-profiler (3.3.1)
510510
rack (>= 1.2.0)
511511
rack-protection (4.0.0)
@@ -602,22 +602,24 @@ GEM
602602
rspec-mocks (~> 3.13)
603603
rspec-support (~> 3.13)
604604
rspec-support (3.13.2)
605-
rubocop (1.70.0)
605+
rubocop (1.75.4)
606606
json (~> 2.3)
607-
language_server-protocol (>= 3.17.0)
607+
language_server-protocol (~> 3.17.0.2)
608+
lint_roller (~> 1.1.0)
608609
parallel (~> 1.10)
609610
parser (>= 3.3.0.2)
610611
rainbow (>= 2.2.2, < 4.0)
611612
regexp_parser (>= 2.9.3, < 3.0)
612-
rubocop-ast (>= 1.36.2, < 2.0)
613+
rubocop-ast (>= 1.44.0, < 2.0)
613614
ruby-progressbar (~> 1.7)
614615
unicode-display_width (>= 2.4.0, < 4.0)
615-
rubocop-ast (1.43.0)
616+
rubocop-ast (1.44.1)
616617
parser (>= 3.3.7.2)
617618
prism (~> 1.4)
618-
rubocop-performance (1.23.1)
619-
rubocop (>= 1.48.1, < 2.0)
620-
rubocop-ast (>= 1.31.1, < 2.0)
619+
rubocop-performance (1.25.0)
620+
lint_roller (~> 1.1)
621+
rubocop (>= 1.75.0, < 2.0)
622+
rubocop-ast (>= 1.38.0, < 2.0)
621623
rubocop-rails (2.25.1)
622624
activesupport (>= 4.2.0)
623625
rack (>= 1.1)
@@ -669,33 +671,34 @@ GEM
669671
activejob (>= 7.2)
670672
activerecord (>= 7.2)
671673
railties (>= 7.2)
672-
sprockets (4.2.1)
674+
sprockets (4.2.2)
673675
concurrent-ruby (~> 1.0)
676+
logger
674677
rack (>= 2.2.4, < 4)
675678
sprockets-rails (3.4.2)
676679
actionpack (>= 5.2)
677680
activesupport (>= 5.2)
678681
sprockets (>= 3.0.0)
679682
stackprof (0.2.27)
680-
standard (1.44.0)
683+
standard (1.49.0)
681684
language_server-protocol (~> 3.17.0.2)
682685
lint_roller (~> 1.0)
683-
rubocop (~> 1.70.0)
686+
rubocop (~> 1.75.2)
684687
standard-custom (~> 1.0.0)
685-
standard-performance (~> 1.6)
688+
standard-performance (~> 1.8)
686689
standard-custom (1.0.2)
687690
lint_roller (~> 1.0)
688691
rubocop (~> 1.50)
689-
standard-performance (1.6.0)
692+
standard-performance (1.8.0)
690693
lint_roller (~> 1.1)
691-
rubocop-performance (~> 1.23.0)
694+
rubocop-performance (~> 1.25.0)
692695
standard-rails (1.1.0)
693696
lint_roller (~> 1.0)
694697
rubocop-rails (~> 2.25.0)
695698
stimulus-rails (1.3.4)
696699
railties (>= 6.0.0)
697700
stringio (3.1.6)
698-
strong_migrations (2.2.1)
701+
strong_migrations (2.3.0)
699702
activerecord (>= 7)
700703
terser (1.2.5)
701704
execjs (>= 0.3.0, < 3)
@@ -738,16 +741,11 @@ GEM
738741
zeitwerk (2.7.2)
739742

740743
PLATFORMS
741-
arm64-darwin-20
742-
arm64-darwin-21
743-
arm64-darwin-22
744-
arm64-darwin-23
744+
arm64-darwin
745745
ruby
746-
x86_64-darwin-20
747-
x86_64-darwin-21
748-
x86_64-darwin-22
749-
x86_64-darwin-23
746+
x86_64-darwin
750747
x86_64-linux
748+
x86_64-linux-gnu
751749

752750
DEPENDENCIES
753751
annotaterb
@@ -828,7 +826,7 @@ DEPENDENCIES
828826
simple_form
829827
simplecov
830828
solid_cache (~> 1.0)
831-
sprockets (~> 4.2.1)
829+
sprockets (~> 4.2.2)
832830
stackprof
833831
standard (~> 1.40)
834832
standard-performance

app/assets/stylesheets/simple_form-bootstrap/_form_multi_select.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@
1616
margin-left: 0 !important;
1717
margin-right: 0 !important;
1818
}
19-
}
19+
}
20+
21+
.input-group, .form-group {
22+
select {
23+
@extend .form-select;
24+
}
25+
}

app/controllers/admin/users_controller.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [Super Admin] This is for administrating users at a global level. We can create, view, modify, etc.
22
class Admin::UsersController < AdminController
3-
before_action :load_organizations, only: %i[new create edit update]
3+
before_action :load_organizations, only: %i[create edit update]
44
before_action :user_params, only: %i[create update]
55

66
def index
@@ -34,15 +34,19 @@ def new
3434

3535
def edit
3636
@user = User.find_by(id: params[:id])
37-
@resources = Role.resources_for_select
3837
end
3938

4039
def create
4140
@user = User.new(user_params)
42-
UserInviteService.invite(name: user_params[:name],
41+
validate_role_resource_params
42+
klass = Role::TITLE_TO_RESOURCE[params[:resource_type].to_sym]
43+
resource = klass&.find(params[:resource_id])
44+
UserInviteService.invite(
45+
name: user_params[:name],
4346
email: user_params[:email],
44-
roles: [Role::ORG_USER],
45-
resource: Organization.find(organization_id_param))
47+
roles: [params[:resource_type].to_sym],
48+
resource: resource
49+
)
4650
flash[:notice] = "Created a new user!"
4751
redirect_to admin_users_path
4852
rescue => e
@@ -95,12 +99,9 @@ def user_params
9599
params.require(:user).permit(:name, :email)
96100
end
97101

98-
def organization_id_param
99-
organization_id = params[:user][:organization_id]
100-
101-
raise "Please select an organization for the user." if organization_id.blank?
102-
103-
organization_id
102+
def validate_role_resource_params
103+
raise "Please select a role for the user." if params[:resource_type].blank?
104+
raise "Please select an associated resource for the role." if !Role::ROLES_WITHOUT_RESOURCE.map(&:to_s).include?(params[:resource_type]) && params[:resource_id].blank?
104105
end
105106

106107
def load_organizations

app/controllers/application_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class ApplicationController < ActionController::Base
1515

1616
rescue_from ActiveRecord::RecordNotFound, with: :not_found!
1717

18-
rescue_from ActionController::InvalidAuthenticityToken do
18+
rescue_from ActionController::InvalidAuthenticityToken, with: :session_expired
19+
20+
def session_expired
1921
flash[:error] = "Your session expired. This could be due to leaving a page open for a long time, or having multiple tabs open. Try resubmitting."
2022
redirect_back fallback_location: root_path
2123
end

app/controllers/concerns/importable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Importable
2525
def import_csv
2626
if params[:file].present?
2727
data = File.read(params[:file].path, encoding: "BOM|UTF-8")
28-
csv = CSV.parse(data, headers: true).reject { |row| row.to_hash.values.any?(&:nil?) }
28+
csv = CSV.parse(data, headers: true)
2929
if csv.count.positive? && csv.first.headers.all? { |header| !header.nil? }
3030
errors = resource_model.import_csv(csv, current_organization.id)
3131
if errors.empty?
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Validatable
2+
extend ActiveSupport::Concern
3+
4+
included do
5+
rescue_from ActionController::InvalidAuthenticityToken do
6+
if action_name == "validate"
7+
render json: {valid: false}
8+
else
9+
session_expired
10+
end
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)