Skip to content

Commit

Permalink
feat: upgrade to Rails 7.2
Browse files Browse the repository at this point in the history
fix: deperecations
- swap enums to use symbol style calls instead of keyword calls
- ensure form_with(model:) is not called with nil

fix: remove old defaults

feat: fix json issues

prepend ActiveSupport to classes that use to_json to ensure we use
ActiveSupport implementation of to_json instead of Object to_json (which
is an alias for to_s)

fix: accessible concern

Some change in rails 7.2 made drawing of routes in an RSpec test not
play well with config.eager_load = true. Thus, in CI these tests would
fail.

Changed the way routes were dynamically added to fix.

fix: add dummy secret key for parallel CI
  • Loading branch information
elasticspoon committed Sep 25, 2024
1 parent 7e2c9c2 commit 1f42efa
Show file tree
Hide file tree
Showing 23 changed files with 287 additions and 460 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source "https://rubygems.org"

ruby "3.2.2"
gem "rails", "7.1.3.4"
gem "rails", "7.2.1"

gem "after_party" # post-deployment tasks
gem "amazing_print" # easier console reading
Expand Down
145 changes: 71 additions & 74 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,84 +1,80 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
actioncable (7.2.1)
actionpack (= 7.2.1)
activesupport (= 7.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.3.4)
actionpack (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
actionmailbox (7.2.1)
actionpack (= 7.2.1)
activejob (= 7.2.1)
activerecord (= 7.2.1)
activestorage (= 7.2.1)
activesupport (= 7.2.1)
mail (>= 2.8.0)
actionmailer (7.2.1)
actionpack (= 7.2.1)
actionview (= 7.2.1)
activejob (= 7.2.1)
activesupport (= 7.2.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.1.3.4)
actionview (= 7.1.3.4)
activesupport (= 7.1.3.4)
actionpack (7.2.1)
actionview (= 7.2.1)
activesupport (= 7.2.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.3.4)
actionpack (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
useragent (~> 0.16)
actiontext (7.2.1)
actionpack (= 7.2.1)
activerecord (= 7.2.1)
activestorage (= 7.2.1)
activesupport (= 7.2.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.3.4)
activesupport (= 7.1.3.4)
actionview (7.2.1)
activesupport (= 7.2.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.3.4)
activesupport (= 7.1.3.4)
activejob (7.2.1)
activesupport (= 7.2.1)
globalid (>= 0.3.6)
activemodel (7.1.3.4)
activesupport (= 7.1.3.4)
activemodel (7.2.1)
activesupport (= 7.2.1)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (7.1.3.4)
activemodel (= 7.1.3.4)
activesupport (= 7.1.3.4)
activerecord (7.2.1)
activemodel (= 7.2.1)
activesupport (= 7.2.1)
timeout (>= 0.4.0)
activestorage (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activesupport (= 7.1.3.4)
activestorage (7.2.1)
actionpack (= 7.2.1)
activejob (= 7.2.1)
activerecord (= 7.2.1)
activesupport (= 7.2.1)
marcel (~> 1.0)
activesupport (7.1.3.4)
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
after_party (1.11.2)
Expand Down Expand Up @@ -313,7 +309,6 @@ GEM
multi_xml (0.7.1)
bigdecimal (~> 3.1)
multipart-post (2.4.1)
mutex_m (0.2.0)
net-http-persistent (4.0.1)
connection_pool (~> 2.2)
net-imap (0.4.16)
Expand Down Expand Up @@ -386,20 +381,20 @@ GEM
rackup (1.0.0)
rack (< 3)
webrick
rails (7.1.3.4)
actioncable (= 7.1.3.4)
actionmailbox (= 7.1.3.4)
actionmailer (= 7.1.3.4)
actionpack (= 7.1.3.4)
actiontext (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activemodel (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
rails (7.2.1)
actioncable (= 7.2.1)
actionmailbox (= 7.2.1)
actionmailer (= 7.2.1)
actionpack (= 7.2.1)
actiontext (= 7.2.1)
actionview (= 7.2.1)
activejob (= 7.2.1)
activemodel (= 7.2.1)
activerecord (= 7.2.1)
activestorage (= 7.2.1)
activesupport (= 7.2.1)
bundler (>= 1.15.0)
railties (= 7.1.3.4)
railties (= 7.2.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -411,10 +406,10 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
irb
railties (7.2.1)
actionpack (= 7.2.1)
activesupport (= 7.2.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
Expand Down Expand Up @@ -452,17 +447,17 @@ GEM
rspec-support (3.13.1)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rswag-api (2.13.0)
activesupport (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
rswag-api (2.14.0)
activesupport (>= 5.2, < 8.0)
railties (>= 5.2, < 8.0)
rswag-specs (2.14.0)
activesupport (>= 5.2, < 8.0)
json-schema (>= 2.2, < 5.0)
railties (>= 5.2, < 8.0)
rspec-core (>= 2.14)
rswag-ui (2.13.0)
actionpack (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
rswag-ui (2.14.0)
actionpack (>= 5.2, < 8.0)
railties (>= 5.2, < 8.0)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down Expand Up @@ -495,6 +490,7 @@ GEM
scout_apm (5.3.8)
parser
selenium-webdriver (4.25.0)
securerandom (0.3.1)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
Expand Down Expand Up @@ -553,6 +549,7 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uniform_notifier (1.16.0)
useragent (0.16.10)
view_component (3.13.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -643,7 +640,7 @@ DEPENDENCIES
pundit
rack-attack
rack-cors
rails (= 7.1.3.4)
rails (= 7.2.1)
rails-controller-testing
rake
request_store
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/fund_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def verify_casa_case
end

def parsed_params
params.permit(
params.require(:fund_request).permit(
:submitter_email,
:youth_name,
:payment_amount,
Expand Down
2 changes: 2 additions & 0 deletions app/datatables/application_datatable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ApplicationDatatable
prepend ActiveSupport::ToJsonWithActiveSupportEncoder

attr_reader :base_relation, :params

DEFAULT_PER_PAGE = 10
Expand Down
1 change: 1 addition & 0 deletions app/models/all_casa_admin.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class AllCasaAdmin < ApplicationRecord
prepend ActiveSupport::ToJsonWithActiveSupportEncoder
include Roles

# Include default devise modules. Others available are:
Expand Down
2 changes: 2 additions & 0 deletions app/models/casa_admin.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class CasaAdmin < User
prepend ActiveSupport::ToJsonWithActiveSupportEncoder

devise :invitable, invite_for: 2.weeks

default_scope { order(email: :asc) }
Expand Down
3 changes: 2 additions & 1 deletion app/models/casa_case.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class CasaCase < ApplicationRecord
prepend ActiveSupport::ToJsonWithActiveSupportEncoder
include ByOrganizationScope
include DateHelper
include CasaCase::Validations
Expand Down Expand Up @@ -53,7 +54,7 @@ class CasaCase < ApplicationRecord
has_many :case_court_orders, -> { order "id asc" }, dependent: :destroy
accepts_nested_attributes_for :case_court_orders, reject_if: :all_blank, allow_destroy: true

enum court_report_status: {not_submitted: 0, submitted: 1, in_review: 2, completed: 3}, _prefix: :court_report
enum :court_report_status, {not_submitted: 0, submitted: 1, in_review: 2, completed: 3}, prefix: :court_report

scope :ordered, -> { order(updated_at: :desc) }
scope :actively_assigned_to, ->(volunteer) {
Expand Down
1 change: 1 addition & 0 deletions app/models/casa_org.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class CasaOrg < ApplicationRecord
prepend ActiveSupport::ToJsonWithActiveSupportEncoder
# NOTE: location of the default report template
CASA_DEFAULT_COURT_REPORT = File.new(Rails.root.join("app", "documents", "templates", "default_report_template.docx"), "r")
CASA_DEFAULT_LOGO = Rails.root.join("public", "logo.jpeg")
Expand Down
2 changes: 1 addition & 1 deletion app/models/case_court_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CaseCourtOrder < ApplicationRecord

validates :text, presence: true

enum implementation_status: IMPLEMENTATION_STATUSES
enum :implementation_status, IMPLEMENTATION_STATUSES

def self.court_order_options
STANDARD_COURT_ORDERS.map { |o| [o, o] }
Expand Down
2 changes: 1 addition & 1 deletion app/models/followup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Followup < ApplicationRecord
belongs_to :case_contact
has_one :casa_org, through: :case_contact
belongs_to :creator, class_name: "User"
enum status: {requested: 0, resolved: 1}
enum :status, {requested: 0, resolved: 1}

validate :uniqueness_of_requested

Expand Down
29 changes: 15 additions & 14 deletions app/views/fund_requests/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,62 @@

<!-- ========== card start ========== -->
<div class="card-style mb-50">
<%= form_with(model: @form_request, local: true, url: casa_case_fund_request_path(@casa_case), method: :post) do |form| %>
<%= form_with(model: @fund_request, local: true, url: casa_case_fund_request_path(@casa_case), method: :post) do |form| %>
<div class="input-style-1">
<%= form.label "Your email", for: :submitter_email %>
<%= form.label :submitter_email, "Your email" %>
<%= form.text_field :submitter_email, class: "form-control", required: true, value: current_user.email %>
</div>

<div class="input-style-1">
<%= form.label "Name or case number of youth", for: :youth_name %>
<%= form.label :youth_name, "Name or case number of youth" %>
<%= form.text_field :youth_name, class: "form-control", required: false, value: @casa_case&.case_number %>
</div>

<div class="input-style-1">
<%= form.label "Amount of payment*", for: :payment_amount %>
<%= form.label :payment_amount, "Amount of payment*" %>
<%= form.text_field :payment_amount, class: "form-control", required: false %>
</div>

<div class="input-style-1">
<%= form.label "Deadline / date needed", for: :deadline %>
<%= form.label :deadline, "Deadline / date needed" %>
<%= form.text_field :deadline, class: "form-control", required: false %>
</div>

<div class="input-style-1">
<%= form.label "Request is for...", for: :request_purpose %>
<%= form.label :request_purpose, "Request is for..." %>
<%= form.text_area :request_purpose, class: "form-control", required: false %>
</div>

<div class="input-style-1">
<%= form.label "Name of payee**", for: :payee_name %>
<%= form.label :payee_name, "Name of payee**" %>
<%= form.text_field :payee_name, class: "form-control", required: false %>
</div>

<div class="input-style-1">
<%= form.label "Requested by & relationship to youth", for: :requested_by_and_relationship %>
<%= form.label :requested_by_and_relationship, "Requested by & relationship to youth" %>
<%= form.text_field :requested_by_and_relationship, class: "form-control", required: false,
value: "#{current_user.display_name} CASA Volunteer" %>
</div>

<div class="input-style-1">
<%= form.label "Other source of funding available/sought please include status of these
requests, if applicable.", for: :other_funding_source_sought %>
<%= form.label :other_funding_source_sought,
"Other source of funding available/sought please include status of these requests, if applicable." %>
<%= form.text_area :other_funding_source_sought, class: "form-control", required: false %>
</div>

<div class="input-style-1">
<%= form.label "How will this funding positively impact the personal goals or aspirations of
<%= form.label :impact, "How will this funding positively impact the personal goals or aspirations of
the youth? If this is for emergency funding, please share any support that is
or can be in place to maintain stability or alleviate the emergency moving
forward. If funding is for a program or a service, please describe how this will
support the youth in the short or long-term.", for: :impact %>
support the youth in the short or long-term." %>
<%= form.text_area :impact, class: "form-control", required: false %>
</div>

<div class="input-style-1">
<%= form.label "Please use this space if it is necessary/helpful to provide additional information
that will assist us in understanding the need and making a decision.", for: :extra_information %>
<%= form.label :extra_information,
"Please use this space if it is necessary/helpful to provide additional
information that will assist us in understanding the need and making a decision." %>
<%= form.text_area :extra_information, class: "form-control", required: false %>
</div>

Expand Down
7 changes: 7 additions & 0 deletions bin/brakeman
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"

ARGV.unshift("--ensure-latest")

load Gem.bin_path("brakeman", "brakeman")
Loading

0 comments on commit 1f42efa

Please sign in to comment.