Skip to content

Commit 2f4d74b

Browse files
Matthijsygithub-actions[bot]
authored andcommitted
Feature/rails 6 (#90)
* Update gemfile and run rails app:upgrade * Fix optional belongs to in mail alias * Temp disable bullet * Fix scope deprecation warnings (rails/rails#35186) * Fix mail delivery job deprecation (rails/rails#34591) * Switch to load 6.0 - Fix deprecation warnings about initalizers - Fix model_name eager loading - Fix autoimport - Fix carrierwave * Cleanup * Rubocop * Re-enable bullet * Fix bullet * Update lockfile * Update activity spec and rubocop-performance version * rubocop * Typo * Remove secret token since it is not used since rails 6 * Remove carrierwave uploader * Sentry.rb * Add additional test case for accept mail
1 parent 10957af commit 2f4d74b

28 files changed

+231
-173
lines changed

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ gem 'puma', '~> 3.7'
3434
gem 'pundit', '~> 2.0'
3535
gem 'rack-attack', '~> 6.0'
3636
gem 'rack-cors', '~> 1.0', require: 'rack/cors'
37-
gem 'rails', '~> 5.2.2'
38-
gem 'rails-i18n', '~> 5.1'
37+
gem 'rails', '~> 6.0'
38+
gem 'rails-i18n', '~> 6.0'
3939
gem 'redis-rails', '~> 5.0.1'
4040
gem 'rqrcode', '~> 0.10'
4141
gem 'ruby-filemagic', '~> 0.7'
4242
gem 'rubyzip', '~> 2.0'
43-
gem 'sentry-raven', '~> 2.3'
43+
gem 'sentry-raven', '~> 2.12'
4444
gem 'sepa_king', '~> 0.11'
4545
gem 'sidekiq', '~> 5.0'
4646
gem 'sidekiq-scheduler', '~> 3.0'
@@ -52,7 +52,7 @@ gem 'vpim', '~> 13.11.11'
5252
group :development, :test do
5353
gem 'awesome_print'
5454
gem 'brakeman', require: false
55-
gem 'bullet', '=5.7.5'
55+
gem 'bullet'
5656
gem 'colorize'
5757
gem 'consistency_fail'
5858
gem 'dotenv-rails'

Gemfile.lock

Lines changed: 66 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,68 @@ GIT
1010
GEM
1111
remote: https://rubygems.org/
1212
specs:
13-
actioncable (5.2.4)
14-
actionpack (= 5.2.4)
13+
actioncable (6.0.1)
14+
actionpack (= 6.0.1)
1515
nio4r (~> 2.0)
1616
websocket-driver (>= 0.6.1)
17-
actionmailer (5.2.4)
18-
actionpack (= 5.2.4)
19-
actionview (= 5.2.4)
20-
activejob (= 5.2.4)
17+
actionmailbox (6.0.1)
18+
actionpack (= 6.0.1)
19+
activejob (= 6.0.1)
20+
activerecord (= 6.0.1)
21+
activestorage (= 6.0.1)
22+
activesupport (= 6.0.1)
23+
mail (>= 2.7.1)
24+
actionmailer (6.0.1)
25+
actionpack (= 6.0.1)
26+
actionview (= 6.0.1)
27+
activejob (= 6.0.1)
2128
mail (~> 2.5, >= 2.5.4)
2229
rails-dom-testing (~> 2.0)
23-
actionpack (5.2.4)
24-
actionview (= 5.2.4)
25-
activesupport (= 5.2.4)
30+
actionpack (6.0.1)
31+
actionview (= 6.0.1)
32+
activesupport (= 6.0.1)
2633
rack (~> 2.0)
2734
rack-test (>= 0.6.3)
2835
rails-dom-testing (~> 2.0)
29-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
30-
actionview (5.2.4)
31-
activesupport (= 5.2.4)
36+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
37+
actiontext (6.0.1)
38+
actionpack (= 6.0.1)
39+
activerecord (= 6.0.1)
40+
activestorage (= 6.0.1)
41+
activesupport (= 6.0.1)
42+
nokogiri (>= 1.8.5)
43+
actionview (6.0.1)
44+
activesupport (= 6.0.1)
3245
builder (~> 3.1)
3346
erubi (~> 1.4)
3447
rails-dom-testing (~> 2.0)
35-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
36-
activejob (5.2.4)
37-
activesupport (= 5.2.4)
48+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
49+
activejob (6.0.1)
50+
activesupport (= 6.0.1)
3851
globalid (>= 0.3.6)
39-
activemodel (5.2.4)
40-
activesupport (= 5.2.4)
41-
activerecord (5.2.4)
42-
activemodel (= 5.2.4)
43-
activesupport (= 5.2.4)
44-
arel (>= 9.0)
45-
activestorage (5.2.4)
46-
actionpack (= 5.2.4)
47-
activerecord (= 5.2.4)
52+
activemodel (6.0.1)
53+
activesupport (= 6.0.1)
54+
activerecord (6.0.1)
55+
activemodel (= 6.0.1)
56+
activesupport (= 6.0.1)
57+
activestorage (6.0.1)
58+
actionpack (= 6.0.1)
59+
activejob (= 6.0.1)
60+
activerecord (= 6.0.1)
4861
marcel (~> 0.3.1)
49-
activesupport (5.2.4)
62+
activesupport (6.0.1)
5063
concurrent-ruby (~> 1.0, >= 1.0.2)
5164
i18n (>= 0.7, < 2)
5265
minitest (~> 5.1)
5366
tzinfo (~> 1.1)
67+
zeitwerk (~> 2.2)
5468
addressable (2.7.0)
5569
public_suffix (>= 2.0.2, < 5.0)
5670
after_commit_action (1.1.0)
5771
activerecord (>= 3.0.0)
5872
activesupport (>= 3.0.0)
5973
airbrussh (1.4.0)
6074
sshkit (>= 1.6.1, != 1.7.0)
61-
arel (9.0.0)
6275
ast (2.4.0)
6376
awesome_print (1.8.0)
6477
bcrypt (3.1.13)
@@ -75,9 +88,9 @@ GEM
7588
msgpack (~> 1.0)
7689
brakeman (4.7.2)
7790
builder (3.2.3)
78-
bullet (5.7.5)
91+
bullet (6.0.2)
7992
activesupport (>= 3.0.0)
80-
uniform_notifier (~> 1.11.0)
93+
uniform_notifier (~> 1.11)
8194
byebug (11.0.1)
8295
capistrano (3.11.2)
8396
airbrussh (>= 1.0.0)
@@ -306,33 +319,35 @@ GEM
306319
rack
307320
rack-test (1.1.0)
308321
rack (>= 1.0, < 3)
309-
rails (5.2.4)
310-
actioncable (= 5.2.4)
311-
actionmailer (= 5.2.4)
312-
actionpack (= 5.2.4)
313-
actionview (= 5.2.4)
314-
activejob (= 5.2.4)
315-
activemodel (= 5.2.4)
316-
activerecord (= 5.2.4)
317-
activestorage (= 5.2.4)
318-
activesupport (= 5.2.4)
322+
rails (6.0.1)
323+
actioncable (= 6.0.1)
324+
actionmailbox (= 6.0.1)
325+
actionmailer (= 6.0.1)
326+
actionpack (= 6.0.1)
327+
actiontext (= 6.0.1)
328+
actionview (= 6.0.1)
329+
activejob (= 6.0.1)
330+
activemodel (= 6.0.1)
331+
activerecord (= 6.0.1)
332+
activestorage (= 6.0.1)
333+
activesupport (= 6.0.1)
319334
bundler (>= 1.3.0)
320-
railties (= 5.2.4)
335+
railties (= 6.0.1)
321336
sprockets-rails (>= 2.0.0)
322337
rails-dom-testing (2.0.3)
323338
activesupport (>= 4.2.0)
324339
nokogiri (>= 1.6)
325340
rails-html-sanitizer (1.3.0)
326341
loofah (~> 2.3)
327-
rails-i18n (5.1.3)
342+
rails-i18n (6.0.0)
328343
i18n (>= 0.7, < 2)
329-
railties (>= 5.0, < 6)
330-
railties (5.2.4)
331-
actionpack (= 5.2.4)
332-
activesupport (= 5.2.4)
344+
railties (>= 6.0.0, < 7)
345+
railties (6.0.1)
346+
actionpack (= 6.0.1)
347+
activesupport (= 6.0.1)
333348
method_source
334349
rake (>= 0.8.7)
335-
thor (>= 0.19.0, < 2.0)
350+
thor (>= 0.20.3, < 2.0)
336351
rainbow (3.0.0)
337352
rake (13.0.1)
338353
rb-fsevent (0.10.3)
@@ -481,7 +496,7 @@ GEM
481496
unf (0.1.4-java)
482497
unf_ext (0.0.7.6)
483498
unicode-display_width (1.6.0)
484-
uniform_notifier (1.11.0)
499+
uniform_notifier (1.13.0)
485500
url_mount (0.2.1)
486501
rack
487502
uuidtools (2.1.5)
@@ -504,6 +519,7 @@ GEM
504519
websocket-extensions (>= 0.1.0)
505520
websocket-extensions (0.1.4)
506521
yard (0.9.20)
522+
zeitwerk (2.2.2)
507523

508524
PLATFORMS
509525
java
@@ -520,7 +536,7 @@ DEPENDENCIES
520536
binding_of_caller
521537
bootsnap (~> 1.4)
522538
brakeman
523-
bullet (= 5.7.5)
539+
bullet
524540
capistrano-sidekiq
525541
carrierwave (= 1.2.2)
526542
carrierwave-base64 (~> 2.5)
@@ -562,8 +578,8 @@ DEPENDENCIES
562578
rack-attack (~> 6.0)
563579
rack-cors (~> 1.0)
564580
rack-mini-profiler
565-
rails (~> 5.2.2)
566-
rails-i18n (~> 5.1)
581+
rails (~> 6.0)
582+
rails-i18n (~> 6.0)
567583
rb-readline
568584
redis-rails (~> 5.0.1)
569585
rqrcode (~> 0.10)
@@ -574,7 +590,7 @@ DEPENDENCIES
574590
rubocop-rspec
575591
ruby-filemagic (~> 0.7)
576592
rubyzip (~> 2.0)
577-
sentry-raven (~> 2.3)
593+
sentry-raven (~> 2.12)
578594
sepa_king (~> 0.11)
579595
sidekiq (~> 5.0)
580596
sidekiq-scheduler (~> 3.0)

app/jobs/smtp_job.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class SMTPJob < ApplicationJob
1+
class SmtpJob < ApplicationJob
22
queue_as :default
33

44
def perform(mail_alias, enable)
@@ -15,12 +15,12 @@ def enable_smtp(mail_alias)
1515
password = SecureRandom.hex(16)
1616
mailgun_client.post("/domains/#{mail_alias.domain}/credentials",
1717
'login': mail_alias.email, 'password': password)
18-
MailSMTPMailer.enabled_email(mail_alias, password).deliver_later
18+
MailSmtpMailer.enabled_email(mail_alias, password).deliver_later
1919
end
2020

2121
def disable_smtp(mail_alias)
2222
mailgun_client.delete("/domains/#{mail_alias.domain}/credentials/#{mail_alias.email}")
23-
MailSMTPMailer.disabled_email(mail_alias).deliver_later
23+
MailSmtpMailer.disabled_email(mail_alias).deliver_later
2424
end
2525

2626
# :nocov:

app/mailers/mail_smtp_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class MailSMTPMailer < ApplicationMailer
1+
class MailSmtpMailer < ApplicationMailer
22
def enabled_email(mail_alias, password)
33
@mail_alias = mail_alias
44
@password = password

app/models/activity.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Activity < ApplicationRecord
2828
scope :closing, (lambda { |days_ahead = 7|
2929
now = DateTime.current
3030
ahead = days_ahead.days.from_now.to_datetime
31-
Activity.joins(:form).where(form_forms: { respond_until: now..ahead })
31+
joins(:form).where(form_forms: { respond_until: now..ahead })
3232
})
3333

3434
after_save :copy_author_and_group_to_form!

app/models/application_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ApplicationRecord < ActiveRecord::Base
66

77
def self.model_names
88
@model_names ||= begin
9-
Rails.application.eager_load!
9+
Zeitwerk::Loader.eager_load_all
1010
ActiveRecord::Base.descendants.map { |m| m.name.underscore }
1111
end
1212
end

app/models/mail_alias.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class MailAlias < ApplicationRecord
2-
belongs_to :group
3-
belongs_to :user
4-
belongs_to :moderator_group, class_name: 'Group'
2+
belongs_to :group, optional: true
3+
belongs_to :user, optional: true
4+
belongs_to :moderator_group, class_name: 'Group', optional: true
55

66
validates :email, presence: true, uniqueness: true
77
validates :moderation_type, inclusion: %w[open semi_moderated moderated]
@@ -73,7 +73,7 @@ def known_mail_domains
7373
def set_smtp
7474
return unless smtp_enabled_changed?
7575

76-
SMTPJob.perform_later(self, smtp_enabled)
76+
SmtpJob.perform_later(self, smtp_enabled)
7777
end
7878
# :nocov:
7979
end

app/models/user.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
7878
})
7979
scope :upcoming_birthdays, (lambda { |days_ahead = 7|
8080
range = (0.days.from_now.to_date..days_ahead.days.from_now.to_date)
81-
scope = range.inject(User.birthday) do |birthdays, day|
82-
birthdays.or(User.birthday(day.month, day.day))
81+
scope = range.inject(birthday) do |birthdays, day|
82+
birthdays.or(birthday(day.month, day.day))
8383
end
8484
february28 = Date.new(Time.zone.now.year, 2, 28)
85-
scope = scope.or(User.birthday(2, 29)) if range.include?(february28) &&
85+
scope = scope.or(birthday(2, 29)) if range.include?(february28) &&
8686
!Date.leap?(Time.zone.now.year)
8787
scope
8888
})
8989
scope :active_users_for_group, (lambda { |group|
90-
User.joins(:memberships).merge(Membership.active.where(group: group))
90+
joins(:memberships).merge(Membership.active.where(group: group))
9191
})
9292
scope :archived, (lambda { |bool = true|
9393
return where.not(archived_at: nil) if bool

bin/setup

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
22
require 'fileutils'
3-
include FileUtils # rubocop:disable Style/MixinUsage
43

54
# path to your application root.
65
APP_ROOT = File.expand_path('..', __dir__)
@@ -9,8 +8,9 @@ def system!(*args)
98
system(*args) || abort("\n== Command #{args} failed ==")
109
end
1110

12-
chdir APP_ROOT do
13-
# This script is a starting point to setup your application.
11+
FileUtils.chdir APP_ROOT do
12+
# This script is a way to setup or update your development environment automatically.
13+
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
1414
# Add necessary setup steps to this file.
1515

1616
puts '== Installing dependencies =='
@@ -19,11 +19,11 @@ chdir APP_ROOT do
1919

2020
# puts "\n== Copying sample files =="
2121
# unless File.exist?('config/database.yml')
22-
# cp 'config/database.yml.sample', 'config/database.yml'
22+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
2323
# end
2424

2525
puts "\n== Preparing database =="
26-
system! 'bin/rails db:setup'
26+
system! 'bin/rails db:prepare'
2727

2828
puts "\n== Removing old logs and tempfiles =="
2929
system! 'bin/rails log:clear tmp:clear'

config/application.rb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,34 @@
44
require 'active_model/railtie'
55
require 'active_job/railtie'
66
require 'active_record/railtie'
7+
require 'active_storage/engine'
78
require 'action_controller/railtie'
89
require 'action_mailer/railtie'
9-
require 'active_storage/engine'
10+
# require "action_mailbox/engine"
11+
# require "action_text/engine"
12+
# require "action_view/railtie"
13+
# require "action_cable/engine"
14+
# require "sprockets/railtie"
15+
# require "rails/test_unit/railtie"
1016

1117
# Require the gems listed in Gemfile, including any gems
1218
# you've limited to :test, :development, or :production.
1319
Bundler.require(*Rails.groups)
1420

1521
module Amber
1622
class Application < Rails::Application
23+
# Initialize configuration defaults for originally generated Rails version.
24+
config.load_defaults 6.0
25+
1726
# Settings in config/environments/* take precedence over those specified here.
18-
# Application configuration should go into files in config/initializers
19-
# -- all .rb files in that directory are automatically loaded.
27+
# Application configuration can go into files in config/initializers
28+
# -- all .rb files in that directory are automatically loaded after loading
29+
# the framework and any gems in your application.
2030

2131
# Only loads a smaller set of middleware suitable for API only apps.
2232
# Middleware like session, flash, cookies can be added back manually.
2333
# Skip views, helpers and assets when generating a new resource.
2434
config.api_only = true
25-
26-
config.autoload_paths << Rails.root.join('app', 'helpers')
27-
config.autoload_paths << Rails.root.join('app', 'paginators')
28-
2935
config.i18n.default_locale = :nl
3036

3137
# Required by message_bus as long as https://github.com/SamSaffron/message_bus/issues/124

0 commit comments

Comments
 (0)