Skip to content

Commit

Permalink
Update rails to 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Nov 18, 2024
1 parent fbded08 commit e761530
Show file tree
Hide file tree
Showing 36 changed files with 360 additions and 481 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0", "3.1"]
ruby-version: ["3.2", "3.3"]

services:
db:
Expand All @@ -41,7 +41,7 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -63,11 +63,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
ruby-version: "3.2"
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run rubocop
run: bundle exec rubocop
Expand All @@ -91,11 +91,11 @@ jobs:
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
ruby-version: "3.2"
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Prepare
env:
Expand Down
9 changes: 1 addition & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem 'actionpack'
gem 'activerecord'
gem 'railties'

gem 'pg', '< 1.3.0' # newer requires posgresql >= 9.3
gem 'pg'

gem 'active_model_serializers'
gem 'jwt'
Expand All @@ -28,9 +28,6 @@ gem 'bootsnap', require: false
# which is currently not available in production.
gem 'rdoc', '< 6.4.0'

# Ruby 3.0 uses this version of the base64 default gem
gem 'base64', '0.1.0'

group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
Expand All @@ -48,10 +45,6 @@ group :development do
gem 'rubocop-rails'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'

# Loading the listen gem enables an evented file system monitor. Check
# https://github.com/guard/listen#listen-adapters if on Windows or *BSD.
# gem 'listen', '~> 3.0.4'
end

group :test do
Expand Down
143 changes: 74 additions & 69 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
GEM
remote: https://rubygems.org/
specs:
actionpack (7.1.4.1)
actionview (= 7.1.4.1)
activesupport (= 7.1.4.1)
actionpack (8.0.0)
actionview (= 8.0.0)
activesupport (= 8.0.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actionview (7.1.4.1)
activesupport (= 7.1.4.1)
useragent (~> 0.16)
actionview (8.0.0)
activesupport (= 8.0.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
Expand All @@ -22,37 +22,41 @@ GEM
activemodel (>= 4.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activemodel (7.1.4.1)
activesupport (= 7.1.4.1)
activerecord (7.1.4.1)
activemodel (= 7.1.4.1)
activesupport (= 7.1.4.1)
activemodel (8.0.0)
activesupport (= 8.0.0)
activerecord (8.0.0)
activemodel (= 8.0.0)
activesupport (= 8.0.0)
timeout (>= 0.4.0)
activesupport (7.1.4.1)
activesupport (8.0.0)
base64
benchmark (>= 0.3)
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)
airbrussh (1.5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
airbrussh (1.5.3)
sshkit (>= 1.6.1, != 1.7.0)
ast (2.4.2)
base64 (0.1.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
bootsnap (1.18.3)
bootsnap (1.18.4)
msgpack (~> 1.2)
builder (3.3.0)
byebug (11.1.3)
capistrano (3.18.0)
capistrano (3.19.2)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (2.1.0)
capistrano-bundler (2.1.1)
capistrano (~> 3.1)
capistrano-passenger (0.2.1)
capistrano (~> 3.0)
Expand All @@ -65,18 +69,18 @@ GEM
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
docile (1.4.0)
docile (1.4.1)
drb (2.2.1)
erubi (1.13.0)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.11.2)
rdoc
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.1)
json (2.8.2)
jsonapi-renderer (0.2.2)
jwt (2.8.0)
jwt (2.9.3)
base64
kaminari (1.2.2)
activesupport (>= 4.1.0)
Expand All @@ -91,32 +95,33 @@ GEM
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
logger (1.6.1)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mini_portile2 (2.8.7)
mini_portile2 (2.8.8)
minitest (5.25.1)
mocha (2.1.0)
mocha (2.5.0)
ruby2_keywords (>= 0.0.5)
msgpack (1.7.2)
msgpack (1.7.5)
multi_json (1.15.0)
mutex_m (0.2.0)
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-ssh (7.2.1)
nio4r (2.7.3)
net-ssh (7.3.0)
nio4r (2.7.4)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
ostruct (0.6.1)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pg (1.2.3)
pg (1.5.9)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
Expand All @@ -127,9 +132,8 @@ GEM
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rackup (2.2.1)
rack (>= 3)
webrick (~> 1.8)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -142,75 +146,77 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-i18n (7.0.8)
rails-i18n (8.0.1)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
railties (7.1.4.1)
actionpack (= 7.1.4.1)
activesupport (= 7.1.4.1)
irb
railties (>= 8.0.0, < 9)
railties (8.0.0)
actionpack (= 8.0.0)
activesupport (= 8.0.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.1.0)
rake (13.2.1)
rdoc (6.3.4.1)
regexp_parser (2.9.0)
reline (0.4.2)
regexp_parser (2.9.2)
reline (0.5.11)
io-console (~> 0.5)
rexml (3.3.9)
rubocop (1.60.2)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.20.2)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
rubocop-performance (1.23.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rails (2.23.1)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.27.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
securerandom (0.3.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
spring (4.1.3)
sqlite3 (1.7.2)
spring (4.2.1)
sqlite3 (2.2.0)
mini_portile2 (~> 2.8.0)
sqlite3 (1.7.2-x86_64-linux)
sshkit (1.22.0)
mutex_m
sqlite3 (2.2.0-x86_64-linux-gnu)
sshkit (1.23.2)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
ostruct
streamio-ffmpeg (3.0.2)
multi_json (~> 1.8)
swagger-blocks (3.0.0)
thor (1.3.0)
timeout (0.4.1)
thor (1.3.2)
timeout (0.4.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
webrick (1.8.2)
zeitwerk (2.6.13)
unicode-display_width (2.6.0)
uri (1.0.2)
useragent (0.16.10)
zeitwerk (2.7.1)

PLATFORMS
ruby
Expand All @@ -220,15 +226,14 @@ DEPENDENCIES
actionpack
active_model_serializers
activerecord
base64 (= 0.1.0)
bootsnap
byebug
capistrano-passenger
capistrano-rails
jwt
kaminari
mocha
pg (< 1.3.0)
pg
puma
rack-cors
rails-erd
Expand Down
12 changes: 10 additions & 2 deletions app/models/access_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@

class AccessCode < ApplicationRecord

include UserStampable
CODE_LENGTH = 6

attr_readonly :code

belongs_to :creator, optional: true, class_name: 'User'

validates :expires_at, presence: true

before_validation :generate_code, on: :create
before_save :set_user_stamps

scope :list, -> { order(expires_at: :desc) }
scope :expired, -> { where('expires_at < ?', Time.zone.today) }
scope :expired, -> { where(expires_at: ...Time.zone.today) }

private

Expand All @@ -32,4 +34,10 @@ def generate_code
generate_code if AccessCode.exists?(code: code)
end

def set_user_stamps
return unless User.current

self.creator = User.current if new_record?
end

end
Loading

0 comments on commit e761530

Please sign in to comment.