Skip to content

Commit

Permalink
Rails 7 Upgrade (#1178)
Browse files Browse the repository at this point in the history
# What it does

Upgrades the application to Rails 7.

# Why it is important

Getting on the latest version of Rails unlocks a few underlying features
we can use to implement improvements to the application.

# Implementation notes

* This builds on and supersedes #1138  
* This holds off on switching to `vips` for image processing. We will
probably do that as part of follow on work on ActiveStorage variants.
* The [upgrade
guide](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-6-1-to-rails-7-0)
suggests there are changes to `button_to`. No system tests are failing
but we should audit the behavior to make sure everything still works.

---------

Co-authored-by: Joshua Flark <[email protected]>
  • Loading branch information
phinze and archonic authored Nov 10, 2023
1 parent c6d6c28 commit 07c1187
Show file tree
Hide file tree
Showing 32 changed files with 133 additions and 320 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

services:
postgres:
image: postgres:11
image: postgres:13.12
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
Expand Down Expand Up @@ -167,4 +167,4 @@ jobs:
bundler-cache: true

- name: ERB Lint
run: bundle exec erblint --lint-all
run: bundle exec erblint --lint-all
9 changes: 6 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.4"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem "rails", "~> 6.1.4"
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
gem "rails", "~> 7.0.0"

# Since Rails 7 sprockets is optional; we still use it so we need to depend on
# the gem explicitly
gem "sprockets-rails"

# Use postgresql as the database for Active Record
gem "pg", ">= 0.18", "< 2.0"
Expand Down Expand Up @@ -76,7 +80,6 @@ group :development do
gem "listen"
gem "solargraph"
gem "solargraph-standardrb"
gem "active_storage_log_suppressor", path: "gems/active_storage_log_suppressor"
gem "lefthook"
gem "erb_lint", "~> 0.1.1"
end
Expand Down
148 changes: 74 additions & 74 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,77 @@ GIT
audited (5.0.2)
activerecord (>= 5.0, < 7.1)

PATH
remote: gems/active_storage_log_suppressor
specs:
active_storage_log_suppressor (0.1.1)
rails (>= 6.0.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.4.3)
actionpack (= 6.1.4.3)
activesupport (= 6.1.4.3)
actioncable (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.4.3)
actionpack (= 6.1.4.3)
activejob (= 6.1.4.3)
activerecord (= 6.1.4.3)
activestorage (= 6.1.4.3)
activesupport (= 6.1.4.3)
actionmailbox (7.0.8)
actionpack (= 7.0.8)
activejob (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
mail (>= 2.7.1)
actionmailer (6.1.4.3)
actionpack (= 6.1.4.3)
actionview (= 6.1.4.3)
activejob (= 6.1.4.3)
activesupport (= 6.1.4.3)
net-imap
net-pop
net-smtp
actionmailer (7.0.8)
actionpack (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activesupport (= 7.0.8)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (6.1.4.3)
actionview (= 6.1.4.3)
activesupport (= 6.1.4.3)
rack (~> 2.0, >= 2.0.9)
actionpack (7.0.8)
actionview (= 7.0.8)
activesupport (= 7.0.8)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.4.3)
actionpack (= 6.1.4.3)
activerecord (= 6.1.4.3)
activestorage (= 6.1.4.3)
activesupport (= 6.1.4.3)
actiontext (7.0.8)
actionpack (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (6.1.4.3)
activesupport (= 6.1.4.3)
actionview (7.0.8)
activesupport (= 7.0.8)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.4.3)
activesupport (= 6.1.4.3)
activejob (7.0.8)
activesupport (= 7.0.8)
globalid (>= 0.3.6)
activemodel (6.1.4.3)
activesupport (= 6.1.4.3)
activerecord (6.1.4.3)
activemodel (= 6.1.4.3)
activesupport (= 6.1.4.3)
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activerecord-postgres_enum (2.0.1)
activerecord (>= 5.2)
pg
activestorage (6.1.4.3)
actionpack (= 6.1.4.3)
activejob (= 6.1.4.3)
activerecord (= 6.1.4.3)
activesupport (= 6.1.4.3)
marcel (~> 1.0.0)
activestorage (7.0.8)
actionpack (= 7.0.8)
activejob (= 7.0.8)
activerecord (= 7.0.8)
activesupport (= 7.0.8)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.4.3)
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
acts_as_list (1.1.0)
activerecord (>= 4.2)
acts_as_tenant (0.5.1)
Expand Down Expand Up @@ -136,7 +136,7 @@ GEM
crass (1.0.6)
cssbundling-rails (1.3.2)
railties (>= 6.0.0)
date (3.3.3)
date (3.3.4)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -201,8 +201,8 @@ GEM
locale (>= 2.0.5)
prime
text (>= 1.3.0)
globalid (1.0.0)
activesupport (>= 5.0)
globalid (1.2.1)
activesupport (>= 6.1)
hashie (5.0.0)
html_tokenizer (0.0.7)
http (5.0.4)
Expand Down Expand Up @@ -282,14 +282,14 @@ GEM
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
net-imap (0.3.6)
net-imap (0.4.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
net-protocol (0.2.2)
timeout
net-smtp (0.3.3)
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.4)
Expand Down Expand Up @@ -340,21 +340,20 @@ GEM
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.4.3)
actioncable (= 6.1.4.3)
actionmailbox (= 6.1.4.3)
actionmailer (= 6.1.4.3)
actionpack (= 6.1.4.3)
actiontext (= 6.1.4.3)
actionview (= 6.1.4.3)
activejob (= 6.1.4.3)
activemodel (= 6.1.4.3)
activerecord (= 6.1.4.3)
activestorage (= 6.1.4.3)
activesupport (= 6.1.4.3)
rails (7.0.8)
actioncable (= 7.0.8)
actionmailbox (= 7.0.8)
actionmailer (= 7.0.8)
actionpack (= 7.0.8)
actiontext (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activemodel (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
bundler (>= 1.15.0)
railties (= 6.1.4.3)
sprockets-rails (>= 2.0.0)
railties (= 7.0.8)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -366,12 +365,13 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (6.1.4.3)
actionpack (= 6.1.4.3)
activesupport (= 6.1.4.3)
railties (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
method_source
rake (>= 0.13)
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.0)
Expand Down Expand Up @@ -459,7 +459,7 @@ GEM
text (1.3.1)
thor (1.2.2)
tilt (2.0.10)
timeout (0.4.0)
timeout (0.4.1)
translation (1.29)
gettext (~> 3.2, >= 3.2.5, <= 3.4.2)
turbolinks (5.2.1)
Expand All @@ -485,7 +485,7 @@ GEM
railties (>= 6.0.0)
webrick (1.7.0)
websocket (1.2.10)
websocket-driver (0.7.5)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
Expand All @@ -498,7 +498,6 @@ PLATFORMS
ruby

DEPENDENCIES
active_storage_log_suppressor!
activerecord-postgres_enum
acts_as_list
acts_as_tenant
Expand Down Expand Up @@ -535,14 +534,15 @@ DEPENDENCIES
pg_search
puma
pundit
rails (~> 6.1.4)
rails (~> 7.0.0)
rails-controller-testing
reverse_markdown
scenic
selenium-webdriver
sentry-raven
solargraph
solargraph-standardrb
sprockets-rails
spy
square.rb
standard
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/signup/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create

result = checkout.checkout_url(amount: @form.amount, email: @member.email, return_to: callback_signup_payments_url, member_id: @member.id, date: Date.current)
if result.success?
redirect_to result.value
redirect_to result.value, allow_other_host: true
else
errors = result.error
Rails.logger.error(errors)
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/date_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module DateHelper
def date_with_time_title(time)
tag.span(time.to_s(:short_date), title: time.to_s(:short_datetime))
tag.span(time.to_fs(:short_date), title: time.to_fs(:short_datetime))
end

def time_ago_with_time_title(time)
tag.span(time_ago_in_words(time) + " ago", title: time.to_s(:short_datetime))
tag.span(time_ago_in_words(time) + " ago", title: time.to_fs(:short_datetime))
end

def checked_out_date(datetime, day_of_week: false)
Expand All @@ -21,6 +21,6 @@ def appointment_date_and_time(appointment, include_time: true)

def display_date(datetime, format)
return unless datetime
tag.time(datetime.to_s(format), datetime: datetime.utc)
tag.time(datetime.to_fs(format), datetime: datetime.utc)
end
end
2 changes: 1 addition & 1 deletion app/lib/member_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def year_values(member)
started_at = member["#{year}_started_at"]
amount = member["#{year}_amount"].to_i
if started_at
[amount / 100, started_at.to_s(:short_date)]
[amount / 100, started_at.to_fs(:short_date)]
elsif amount > 0
[amount / 100, nil]
else
Expand Down
4 changes: 2 additions & 2 deletions app/models/membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def status_text
if pending?
"pending"
elsif ended?
"ended on #{ended_at.to_s(:month_day_year)}"
"ended on #{ended_at.to_fs(:month_day_year)}"
else
"ends on #{ended_at.to_s(:month_day_year)}"
"ends on #{ended_at.to_fs(:month_day_year)}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/items/histories/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="timeline-content">
<div class="tile-content">
<p class="tile-title"><%= audit.created_at.to_s(:short) %> by
<p class="tile-title"><%= audit.created_at.to_fs(:short) %> by
<% if audit.user.present? %>
<%= audit.user.email %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/reports/memberships/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</td>
<td><%= member.status %></td>
<td><%= member.loans_count %></td>
<td><%= member.expires_on.to_date.to_s(:long) if member.expires_on %></td>
<td><%= member.expires_on&.to_date&.to_fs(:long) %></td>
<td><%= member.amounts.map { |a| Money.new(a&.abs).format }.join(", ") %></td>
<td><%= member.memberships_count %></td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<%= tag.div format_phone_number(member.phone_number), class: "responsive-table-cell" %>
</td>
<td>
<%= member.created_at.to_s(:short_date) %>
<%= member.created_at.to_fs(:short_date) %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/member_mailer/membership_reminder.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ We'd love to see you!
<%= HTMLToMarkdown.new.convert(render(partial: "member_mailer/reminder")) %>
---------------------

<%= HTMLToMarkdown.new.convert(render(partial: "signup/confirmations/instructions", formats: ["html"])) %>
<%= HTMLToMarkdown.new.convert(render(partial: "signup/confirmations/instructions", formats: [:html])) %>

---

Expand Down
Loading

0 comments on commit 07c1187

Please sign in to comment.