Add rails 7 support

This commit is contained in:
Benjamin Neff 2022-07-03 03:39:44 +02:00
parent fbc0653153
commit a0e1cac95f
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
14 changed files with 69 additions and 89 deletions

View file

@ -9,7 +9,7 @@ PATH
valid (~> 1.0) valid (~> 1.0)
diaspora_federation-json_schema (0.3.0) diaspora_federation-json_schema (0.3.0)
diaspora_federation-rails (0.3.0) diaspora_federation-rails (0.3.0)
actionpack (>= 5.2, < 7) actionpack (>= 5.2, < 8)
diaspora_federation (= 0.3.0) diaspora_federation (= 0.3.0)
diaspora_federation-test (0.3.0) diaspora_federation-test (0.3.0)
diaspora_federation (= 0.3.0) diaspora_federation (= 0.3.0)
@ -19,32 +19,31 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionpack (6.1.4.1) actionpack (7.0.3.1)
actionview (= 6.1.4.1) actionview (= 7.0.3.1)
activesupport (= 6.1.4.1) activesupport (= 7.0.3.1)
rack (~> 2.0, >= 2.0.9) rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.1.4.1) actionview (7.0.3.1)
activesupport (= 6.1.4.1) activesupport (= 7.0.3.1)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (6.1.4.1) activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
minitest (>= 5.1) minitest (>= 5.1)
tzinfo (~> 2.0) tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0) addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2) ast (2.4.2)
builder (3.2.4) builder (3.2.4)
byebug (11.1.3) byebug (11.1.3)
coderay (1.1.3) coderay (1.1.3)
concurrent-ruby (1.1.9) concurrent-ruby (1.1.10)
crack (0.4.5) crack (0.4.5)
rexml rexml
crass (1.0.6) crass (1.0.6)
@ -86,7 +85,7 @@ GEM
httparty (0.20.0) httparty (0.20.0)
mime-types (~> 3.0) mime-types (~> 3.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (1.8.11) i18n (1.12.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
json-schema (2.8.1) json-schema (2.8.1)
addressable (>= 2.4) addressable (>= 2.4)
@ -96,7 +95,7 @@ GEM
listen (3.7.0) listen (3.7.0)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.12.0) loofah (2.18.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
macaddr (1.7.2) macaddr (1.7.2)
@ -106,10 +105,10 @@ GEM
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115) mime-types-data (3.2021.1115)
mini_portile2 (2.8.0) mini_portile2 (2.8.0)
minitest (5.14.4) minitest (5.16.2)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.1.1) multipart-post (2.1.1)
nokogiri (1.13.3) nokogiri (1.13.7)
mini_portile2 (~> 2.8.0) mini_portile2 (~> 2.8.0)
racc (~> 1.4) racc (~> 1.4)
nyan-cat-formatter (0.12.0) nyan-cat-formatter (0.12.0)
@ -139,20 +138,21 @@ GEM
pry (~> 0.10) pry (~> 0.10)
public_suffix (4.0.6) public_suffix (4.0.6)
racc (1.6.0) racc (1.6.0)
rack (2.2.3) rack (2.2.4)
rack-test (1.1.0) rack-test (2.0.2)
rack (>= 1.0, < 3) rack (>= 1.3)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2) rails-html-sanitizer (1.4.3)
loofah (~> 2.3) loofah (~> 2.3)
railties (6.1.4.1) railties (7.0.3.1)
actionpack (= 6.1.4.1) actionpack (= 7.0.3.1)
activesupport (= 6.1.4.1) activesupport (= 7.0.3.1)
method_source method_source
rake (>= 0.13) rake (>= 12.2)
thor (~> 1.0) thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.0.0) rainbow (3.0.0)
rake (13.0.6) rake (13.0.6)
rb-fsevent (0.11.0) rb-fsevent (0.11.0)
@ -217,7 +217,7 @@ GEM
simplecov_json_formatter (0.1.3) simplecov_json_formatter (0.1.3)
systemu (2.6.5) systemu (2.6.5)
terminal-table (1.6.0) terminal-table (1.6.0)
thor (1.1.0) thor (1.2.1)
typhoeus (1.4.0) typhoeus (1.4.0)
ethon (>= 0.9.0) ethon (>= 0.9.0)
tzinfo (2.0.4) tzinfo (2.0.4)
@ -231,7 +231,7 @@ GEM
crack (>= 0.3.2) crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0) hashdiff (>= 0.4.0, < 2.0.0)
yard (0.9.26) yard (0.9.26)
zeitwerk (2.5.1) zeitwerk (2.6.0)
PLATFORMS PLATFORMS
ruby ruby

View file

@ -15,8 +15,9 @@ module DiasporaFederation
if magic_env if magic_env
render xml: magic_env, content_type: "application/magic-envelope+xml" render xml: magic_env, content_type: "application/magic-envelope+xml"
else else
redirect_to DiasporaFederation.callbacks.trigger(:fetch_person_url_to, redirect_url = DiasporaFederation.callbacks.trigger(:fetch_person_url_to,
entity.author, "/fetch/#{params[:type]}/#{params[:guid]}") entity.author, "/fetch/#{params[:type]}/#{params[:guid]}")
redirect_to redirect_url, allow_other_host: true
end end
else else
head :not_found head :not_found

View file

@ -2,12 +2,12 @@
# This command will automatically be run when you run "rails" with Rails gems # This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application. # installed from the root of your application.
ENGINE_ROOT = File.expand_path('..', __dir__) ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path('../lib/diaspora_federation/engine', __dir__) ENGINE_PATH = File.expand_path("../lib/diaspora_federation/engine", __dir__)
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
require "rails/all" require "rails/all"

View file

@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.7" s.required_ruby_version = ">= 2.7"
s.add_dependency "actionpack", ">= 5.2", "< 7" s.add_dependency "actionpack", ">= 5.2", "< 8"
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
end end

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__) APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot" require_relative "../config/boot"
require "rails/commands" require "rails/commands"

View file

@ -2,7 +2,7 @@
require "fileutils" require "fileutils"
# path to your application root. # path to your application root.
APP_ROOT = File.expand_path('..', __dir__) APP_ROOT = File.expand_path("..", __dir__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
@ -13,13 +13,13 @@ FileUtils.chdir APP_ROOT do
# This script is idempotent, so that you can run it at any time and get an expectable outcome. # This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file. # Add necessary setup steps to this file.
puts '== Installing dependencies ==' puts "== Installing dependencies =="
system! 'gem install bundler --conservative' system! "gem install bundler --conservative"
system('bundle check') || system!('bundle install') system("bundle check") || system!("bundle install")
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear' system! "bin/rails log:clear tmp:clear"
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system! 'bin/rails restart' system! "bin/rails restart"
end end

View file

@ -14,7 +14,6 @@ require "action_controller/railtie"
# require "action_text/engine" # require "action_text/engine"
require "action_view/railtie" require "action_view/railtie"
# require "action_cable/engine" # require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie" require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
@ -25,7 +24,7 @@ require "diaspora_federation/rails"
module Dummy module Dummy
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.0 config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here. # Configuration for the application, engines, and railties goes here.
# #

View file

@ -1,6 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile. require "bundler/setup" # Set up gems listed in the Gemfile.

View file

@ -16,6 +16,9 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable server timing
config.server_timing = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist? if Rails.root.join("tmp/caching-dev.txt").exist?
@ -47,16 +50,6 @@ Rails.application.configure do
# Annotate rendered view with file names. # Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true # config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Set the logging destination(s)
config.log_to = %w[stdout file]
# Show the logging configuration on STDOUT
config.show_log_configuration = true
# Uncomment if you wish to allow Action Cable access from any origin. # Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true # config.action_cable.disable_request_forgery_protection = true
end end

View file

@ -27,11 +27,11 @@ Rails.application.configure do
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = 'http://assets.example.com' # config.asset_host = "http://assets.example.com"
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true # config.force_ssl = true
@ -54,46 +54,19 @@ Rails.application.configure do
# the I18n.default_locale when a translation cannot be found). # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true config.i18n.fallbacks = true
# Send deprecation notices to registered listeners. # Don't log any deprecations.
config.active_support.deprecation = :notify config.active_support.report_deprecations = false
# Log disallowed deprecations.
config.active_support.disallowed_deprecation = :log
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Use default logging formatter so that PID and timestamp are not suppressed. # Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups. # Use a different logger for distributed setups.
# require "syslog/logger" # require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present? if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new($stdout) logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger) config.logger = ActiveSupport::TaggedLogging.new(logger)
end end
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end end

View file

@ -10,12 +10,13 @@ require "active_support/core_ext/integer/time"
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application # Eager loading loads your whole application. When running a single test locally,
# just for the purpose of running a single test. If you are using a tool that # this probably isn't necessary. It's a good idea to do in a continuous integration
# preloads Rails for running tests, you may have to set it to true. # system, or in some way before deploying your code.
config.eager_load = false config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]

View file

@ -2,7 +2,9 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file. # Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application.config.filter_parameters += %i[ Rails.application.config.filter_parameters += %i[
passw secret token _key crypt salt certificate otp ssn passw secret token _key crypt salt certificate otp ssn
] ]

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.routes.draw do Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
mount DiasporaFederation::Engine => "/" mount DiasporaFederation::Engine => "/"
get "discovery" => "discovery#discovery" get "discovery" => "discovery#discovery"