Skip to content

Commit cbd0ee1

Browse files
Update Mastodon to Rails 6.1 (#15910)
* Update devise-two-factor to unreleased fork for Rails 6 support Update tests to match new `rotp` version. * Update nsa gem to unreleased fork for Rails 6 support * Update rails to 6.1.3 and rails-i18n to 6.0 * Update to unreleased fork of pluck_each for Ruby 6 support * Run "rails app:update" * Add missing ActiveStorage config file * Use config.ssl_options instead of removed ApplicationController#force_ssl Disabled force_ssl-related tests as they do not seem to be easily testable anymore. * Fix nonce directives by removing Rails 5 specific monkey-patching * Fix fixture_file_upload deprecation warning * Fix yield-based test failing with Rails 6 * Use Rails 6's index_with when possible * Use ActiveRecord::Cache::Store#delete_multi from Rails 6 This will yield better performances when deleting an account * Disable Rails 6.1's automatic preload link headers Since Rails 6.1, ActionView adds preload links for javascript files in the Links header per default. In our case, that will bloat headers too much and potentially cause issues with reverse proxies. Furhermore, we don't need those links, as we already output them as HTML link tags. * Switch to Rails 6.0 default config * Switch to Rails 6.1 default config * Do not include autoload paths in the load path
1 parent 8255683 commit cbd0ee1

29 files changed

+204
-159
lines changed

Gemfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ruby '>= 2.5.0', '< 3.0.0'
66
gem 'pkg-config', '~> 1.4'
77

88
gem 'puma', '~> 5.2'
9-
gem 'rails', '~> 5.2.4.5'
9+
gem 'rails', '~> 6.1.3'
1010
gem 'sprockets', '~> 3.7.2'
1111
gem 'thor', '~> 1.1'
1212
gem 'rack', '~> 2.2.3'
@@ -34,7 +34,7 @@ gem 'iso-639'
3434
gem 'chewy', '~> 5.2'
3535
gem 'cld3', '~> 3.4.1'
3636
gem 'devise', '~> 4.7'
37-
gem 'devise-two-factor', '~> 3.1'
37+
gem 'devise-two-factor', git: 'https://github.com/ClearlyClaire/devise-two-factor', ref: '594bb8a32e6f94df7e5ba7c9399eaf9ff25bac0d'
3838

3939
group :pam_authentication, optional: true do
4040
gem 'devise_pam_authenticatable2', '~> 9.2'
@@ -65,7 +65,7 @@ gem 'link_header', '~> 0.0'
6565
gem 'mime-types', '~> 3.3.1', require: 'mime/types/columnar'
6666
gem 'nilsimsa', git: 'https://github.com/witgo/nilsimsa', ref: 'fd184883048b922b176939f851338d0a4971a532'
6767
gem 'nokogiri', '~> 1.11'
68-
gem 'nsa', '~> 0.2'
68+
gem 'nsa', git: 'https://github.com/Gargron/nsa', ref: 'd1079e0cdafdfed7f9f35478d13b9bdaa65965c0'
6969
gem 'oj', '~> 3.11'
7070
gem 'ox', '~> 2.14'
7171
gem 'parslet'
@@ -75,7 +75,7 @@ gem 'pundit', '~> 2.1'
7575
gem 'premailer-rails'
7676
gem 'rack-attack', '~> 6.5'
7777
gem 'rack-cors', '~> 1.1', require: 'rack/cors'
78-
gem 'rails-i18n', '~> 5.1'
78+
gem 'rails-i18n', '~> 6.0'
7979
gem 'rails-settings-cached', '~> 0.6'
8080
gem 'redis', '~> 4.2', require: ['redis', 'redis/connection/hiredis']
8181
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
@@ -159,4 +159,4 @@ gem 'concurrent-ruby', require: false
159159
gem 'connection_pool', require: false
160160

161161
gem 'xorcist', '~> 1.1'
162-
gem 'pluck_each', '~> 0.1.3'
162+
gem 'pluck_each', git: 'https://github.com/nsommer/pluck_each', ref: '73be0947c52fc54bf6d7085378db008358aac5eb'

Gemfile.lock

+109-72
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
GIT
2+
remote: https://github.com/ClearlyClaire/devise-two-factor
3+
revision: 594bb8a32e6f94df7e5ba7c9399eaf9ff25bac0d
4+
ref: 594bb8a32e6f94df7e5ba7c9399eaf9ff25bac0d
5+
specs:
6+
devise-two-factor (3.1.0)
7+
activesupport (< 7.0)
8+
attr_encrypted (>= 1.3, < 4, != 2)
9+
devise
10+
railties (< 7.0)
11+
rotp (~> 6)
12+
13+
GIT
14+
remote: https://github.com/Gargron/nsa
15+
revision: d1079e0cdafdfed7f9f35478d13b9bdaa65965c0
16+
ref: d1079e0cdafdfed7f9f35478d13b9bdaa65965c0
17+
specs:
18+
nsa (0.2.8)
19+
activesupport (>= 4.2, < 7)
20+
concurrent-ruby (~> 1.0, >= 1.0.2)
21+
sidekiq (>= 3.5)
22+
statsd-ruby (~> 1.4, >= 1.4.0)
23+
124
GIT
225
remote: https://github.com/ianheggie/health_check
326
revision: 0b799ead604f900ed50685e9b2d469cd2befba5b
@@ -6,6 +29,15 @@ GIT
629
health_check (4.0.0.pre)
730
rails (>= 4.0)
831

32+
GIT
33+
remote: https://github.com/nsommer/pluck_each
34+
revision: 73be0947c52fc54bf6d7085378db008358aac5eb
35+
ref: 73be0947c52fc54bf6d7085378db008358aac5eb
36+
specs:
37+
pluck_each (0.1.3)
38+
activerecord (>= 6.1.0)
39+
activesupport (>= 6.1.0)
40+
941
GIT
1042
remote: https://github.com/witgo/nilsimsa
1143
revision: fd184883048b922b176939f851338d0a4971a532
@@ -16,53 +48,71 @@ GIT
1648
GEM
1749
remote: https://rubygems.org/
1850
specs:
19-
actioncable (5.2.4.5)
20-
actionpack (= 5.2.4.5)
51+
actioncable (6.1.3)
52+
actionpack (= 6.1.3)
53+
activesupport (= 6.1.3)
2154
nio4r (~> 2.0)
2255
websocket-driver (>= 0.6.1)
23-
actionmailer (5.2.4.5)
24-
actionpack (= 5.2.4.5)
25-
actionview (= 5.2.4.5)
26-
activejob (= 5.2.4.5)
56+
actionmailbox (6.1.3)
57+
actionpack (= 6.1.3)
58+
activejob (= 6.1.3)
59+
activerecord (= 6.1.3)
60+
activestorage (= 6.1.3)
61+
activesupport (= 6.1.3)
62+
mail (>= 2.7.1)
63+
actionmailer (6.1.3)
64+
actionpack (= 6.1.3)
65+
actionview (= 6.1.3)
66+
activejob (= 6.1.3)
67+
activesupport (= 6.1.3)
2768
mail (~> 2.5, >= 2.5.4)
2869
rails-dom-testing (~> 2.0)
29-
actionpack (5.2.4.5)
30-
actionview (= 5.2.4.5)
31-
activesupport (= 5.2.4.5)
32-
rack (~> 2.0, >= 2.0.8)
70+
actionpack (6.1.3)
71+
actionview (= 6.1.3)
72+
activesupport (= 6.1.3)
73+
rack (~> 2.0, >= 2.0.9)
3374
rack-test (>= 0.6.3)
3475
rails-dom-testing (~> 2.0)
35-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
36-
actionview (5.2.4.5)
37-
activesupport (= 5.2.4.5)
76+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
77+
actiontext (6.1.3)
78+
actionpack (= 6.1.3)
79+
activerecord (= 6.1.3)
80+
activestorage (= 6.1.3)
81+
activesupport (= 6.1.3)
82+
nokogiri (>= 1.8.5)
83+
actionview (6.1.3)
84+
activesupport (= 6.1.3)
3885
builder (~> 3.1)
3986
erubi (~> 1.4)
4087
rails-dom-testing (~> 2.0)
41-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
88+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
4289
active_model_serializers (0.10.12)
4390
actionpack (>= 4.1, < 6.2)
4491
activemodel (>= 4.1, < 6.2)
4592
case_transform (>= 0.2)
4693
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
4794
active_record_query_trace (1.8)
48-
activejob (5.2.4.5)
49-
activesupport (= 5.2.4.5)
95+
activejob (6.1.3)
96+
activesupport (= 6.1.3)
5097
globalid (>= 0.3.6)
51-
activemodel (5.2.4.5)
52-
activesupport (= 5.2.4.5)
53-
activerecord (5.2.4.5)
54-
activemodel (= 5.2.4.5)
55-
activesupport (= 5.2.4.5)
56-
arel (>= 9.0)
57-
activestorage (5.2.4.5)
58-
actionpack (= 5.2.4.5)
59-
activerecord (= 5.2.4.5)
98+
activemodel (6.1.3)
99+
activesupport (= 6.1.3)
100+
activerecord (6.1.3)
101+
activemodel (= 6.1.3)
102+
activesupport (= 6.1.3)
103+
activestorage (6.1.3)
104+
actionpack (= 6.1.3)
105+
activejob (= 6.1.3)
106+
activerecord (= 6.1.3)
107+
activesupport (= 6.1.3)
60108
marcel (~> 0.3.1)
61-
activesupport (5.2.4.5)
109+
mimemagic (~> 0.3.2)
110+
activesupport (6.1.3)
62111
concurrent-ruby (~> 1.0, >= 1.0.2)
63-
i18n (>= 0.7, < 2)
64-
minitest (~> 5.1)
65-
tzinfo (~> 1.1)
112+
i18n (>= 1.6, < 2)
113+
minitest (>= 5.1)
114+
tzinfo (~> 2.0)
115+
zeitwerk (~> 2.3)
66116
addressable (2.7.0)
67117
public_suffix (>= 2.0.2, < 5.0)
68118
airbrussh (1.4.0)
@@ -71,7 +121,6 @@ GEM
71121
annotate (3.1.1)
72122
activerecord (>= 3.2, < 7.0)
73123
rake (>= 10.4, < 14.0)
74-
arel (9.0.0)
75124
ast (2.4.2)
76125
attr_encrypted (3.1.0)
77126
encryptor (~> 3.0.0)
@@ -175,12 +224,6 @@ GEM
175224
railties (>= 4.1.0)
176225
responders
177226
warden (~> 1.2.3)
178-
devise-two-factor (3.1.0)
179-
activesupport (< 6.1)
180-
attr_encrypted (>= 1.3, < 4, != 2)
181-
devise (~> 4.0)
182-
railties (< 6.1)
183-
rotp (~> 2.0)
184227
devise_pam_authenticatable2 (9.2.0)
185228
devise (>= 4.0.0)
186229
rpam2 (~> 4.0)
@@ -370,11 +413,6 @@ GEM
370413
racc (~> 1.4)
371414
nokogumbo (2.0.4)
372415
nokogiri (~> 1.8, >= 1.8.4)
373-
nsa (0.2.7)
374-
activesupport (>= 4.2, < 6)
375-
concurrent-ruby (~> 1.0, >= 1.0.2)
376-
sidekiq (>= 3.5)
377-
statsd-ruby (~> 1.4, >= 1.4.0)
378416
oj (3.11.3)
379417
omniauth (1.9.1)
380418
hashie (>= 3.4.6)
@@ -414,9 +452,6 @@ GEM
414452
pghero (2.8.0)
415453
activerecord (>= 5)
416454
pkg-config (1.4.5)
417-
pluck_each (0.1.3)
418-
activerecord (> 3.2.0)
419-
activesupport (> 3.0.0)
420455
posix-spawn (0.3.15)
421456
premailer (1.14.2)
422457
addressable
@@ -450,18 +485,20 @@ GEM
450485
rack
451486
rack-test (1.1.0)
452487
rack (>= 1.0, < 3)
453-
rails (5.2.4.5)
454-
actioncable (= 5.2.4.5)
455-
actionmailer (= 5.2.4.5)
456-
actionpack (= 5.2.4.5)
457-
actionview (= 5.2.4.5)
458-
activejob (= 5.2.4.5)
459-
activemodel (= 5.2.4.5)
460-
activerecord (= 5.2.4.5)
461-
activestorage (= 5.2.4.5)
462-
activesupport (= 5.2.4.5)
463-
bundler (>= 1.3.0)
464-
railties (= 5.2.4.5)
488+
rails (6.1.3)
489+
actioncable (= 6.1.3)
490+
actionmailbox (= 6.1.3)
491+
actionmailer (= 6.1.3)
492+
actionpack (= 6.1.3)
493+
actiontext (= 6.1.3)
494+
actionview (= 6.1.3)
495+
activejob (= 6.1.3)
496+
activemodel (= 6.1.3)
497+
activerecord (= 6.1.3)
498+
activestorage (= 6.1.3)
499+
activesupport (= 6.1.3)
500+
bundler (>= 1.15.0)
501+
railties (= 6.1.3)
465502
sprockets-rails (>= 2.0.0)
466503
rails-controller-testing (1.0.5)
467504
actionpack (>= 5.0.1.rc1)
@@ -472,17 +509,17 @@ GEM
472509
nokogiri (>= 1.6)
473510
rails-html-sanitizer (1.3.0)
474511
loofah (~> 2.3)
475-
rails-i18n (5.1.3)
512+
rails-i18n (6.0.0)
476513
i18n (>= 0.7, < 2)
477-
railties (>= 5.0, < 6)
514+
railties (>= 6.0.0, < 7)
478515
rails-settings-cached (0.6.6)
479516
rails (>= 4.2.0)
480-
railties (5.2.4.5)
481-
actionpack (= 5.2.4.5)
482-
activesupport (= 5.2.4.5)
517+
railties (6.1.3)
518+
actionpack (= 6.1.3)
519+
activesupport (= 6.1.3)
483520
method_source
484521
rake (>= 0.8.7)
485-
thor (>= 0.19.0, < 2.0)
522+
thor (~> 1.0)
486523
rainbow (3.0.0)
487524
rake (13.0.3)
488525
rdf (3.1.13)
@@ -500,7 +537,7 @@ GEM
500537
actionpack (>= 5.0)
501538
railties (>= 5.0)
502539
rexml (3.2.4)
503-
rotp (2.1.2)
540+
rotp (6.2.0)
504541
rpam2 (4.0.2)
505542
rqrcode (1.2.0)
506543
chunky_png (~> 1.0)
@@ -600,7 +637,7 @@ GEM
600637
net-scp (>= 1.1.2)
601638
net-ssh (>= 2.8.0)
602639
stackprof (0.2.16)
603-
statsd-ruby (1.4.0)
640+
statsd-ruby (1.5.0)
604641
stoplight (2.2.1)
605642
streamio-ffmpeg (3.0.2)
606643
multi_json (~> 1.8)
@@ -612,7 +649,6 @@ GEM
612649
terrapin (0.6.0)
613650
climate_control (>= 0.0.3, < 1.0)
614651
thor (1.1.0)
615-
thread_safe (0.3.6)
616652
thwait (0.2.0)
617653
e2mmap
618654
tilt (2.0.10)
@@ -632,8 +668,8 @@ GEM
632668
twitter-text (3.1.0)
633669
idn-ruby
634670
unf (~> 0.1.0)
635-
tzinfo (1.2.9)
636-
thread_safe (~> 0.1)
671+
tzinfo (2.0.4)
672+
concurrent-ruby (~> 1.0)
637673
tzinfo-data (1.2021.1)
638674
tzinfo (>= 1.0.0)
639675
unf (0.1.4)
@@ -672,6 +708,7 @@ GEM
672708
xorcist (1.1.2)
673709
xpath (3.2.0)
674710
nokogiri (~> 1.8)
711+
zeitwerk (2.4.2)
675712

676713
PLATFORMS
677714
ruby
@@ -703,7 +740,7 @@ DEPENDENCIES
703740
concurrent-ruby
704741
connection_pool
705742
devise (~> 4.7)
706-
devise-two-factor (~> 3.1)
743+
devise-two-factor!
707744
devise_pam_authenticatable2 (~> 9.2)
708745
discard (~> 1.2)
709746
doorkeeper (~> 5.5)
@@ -741,7 +778,7 @@ DEPENDENCIES
741778
net-ldap (~> 0.17)
742779
nilsimsa!
743780
nokogiri (~> 1.11)
744-
nsa (~> 0.2)
781+
nsa!
745782
oj (~> 3.11)
746783
omniauth (~> 1.9)
747784
omniauth-cas (~> 2.0)
@@ -756,7 +793,7 @@ DEPENDENCIES
756793
pg (~> 1.2)
757794
pghero (~> 2.8)
758795
pkg-config (~> 1.4)
759-
pluck_each (~> 0.1.3)
796+
pluck_each!
760797
posix-spawn
761798
premailer-rails
762799
private_address_check (~> 0.5)
@@ -767,9 +804,9 @@ DEPENDENCIES
767804
rack (~> 2.2.3)
768805
rack-attack (~> 6.5)
769806
rack-cors (~> 1.1)
770-
rails (~> 5.2.4.5)
807+
rails (~> 6.1.3)
771808
rails-controller-testing (~> 1.0)
772-
rails-i18n (~> 5.1)
809+
rails-i18n (~> 6.0)
773810
rails-settings-cached (~> 0.6)
774811
rdf-normalize (~> 0.4)
775812
redis (~> 4.2)

app/controllers/application_controller.rb

-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ class ApplicationController < ActionController::Base
55
# For APIs, you may want to use :null_session instead.
66
protect_from_forgery with: :exception
77

8-
force_ssl if: :https_enabled?
9-
108
include Localized
119
include UserTrackingConcern
1210
include SessionTrackingConcern
@@ -42,10 +40,6 @@ def raise_not_found
4240

4341
private
4442

45-
def https_enabled?
46-
Rails.env.production? && !request.path.start_with?('/health') && !request.headers["Host"].end_with?(".onion")
47-
end
48-
4943
def authorized_fetch_mode?
5044
ENV['AUTHORIZED_FETCH'] == 'true' || Rails.configuration.x.whitelist_mode
5145
end

app/lib/delivery_failure_tracker.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def available?
2929

3030
class << self
3131
def without_unavailable(urls)
32-
unavailable_domains_map = Rails.cache.fetch('unavailable_domains') { UnavailableDomain.pluck(:domain).each_with_object({}) { |domain, hash| hash[domain] = true } }
32+
unavailable_domains_map = Rails.cache.fetch('unavailable_domains') { UnavailableDomain.pluck(:domain).index_with(true) }
3333

3434
urls.reject do |url|
3535
host = Addressable::URI.parse(url).normalized_host

0 commit comments

Comments
 (0)