Skip to content

Commit 814479a

Browse files
committed
Test with Rails 8.0
Need to reload routes in controller tests, because of an unresolved issue with Devise
1 parent 178f7fb commit 814479a

23 files changed

Lines changed: 769 additions & 342 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- "3.4"
2121
rails:
2222
- "7.2"
23+
- "8.0"
2324
database:
2425
- mysql
2526
- postgresql

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
alchemy_branch = ENV.fetch("ALCHEMY_BRANCH", "main")
44
gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: alchemy_branch
55

6-
rails_version = ENV.fetch("RAILS_VERSION", "7.2")
6+
rails_version = ENV.fetch("RAILS_VERSION", "8.0")
77
gem "rails", "~> #{rails_version}.0"
88
gem "listen", "~> 3.8"
99
gem "puma", "~> 7.0"

spec/dummy/bin/dev

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
#!/usr/bin/env sh
2-
3-
if ! gem list foreman -i --silent; then
4-
echo "Installing foreman..."
5-
gem install foreman
6-
fi
7-
8-
exec foreman start -f Procfile.dev "$@"
1+
#!/usr/bin/env ruby
2+
exec "./bin/rails", "server", *ARGV

spec/dummy/bin/rubocop

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
# explicit rubocop config increases performance slightly while avoiding config confusion.
6+
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
7+
8+
load Gem.bin_path("rubocop", "rubocop")

spec/dummy/bin/setup

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
33

4-
# path to your application root.
54
APP_ROOT = File.expand_path("..", __dir__)
65

76
def system!(*args)
8-
system(*args) || abort("\n== Command #{args} failed ==")
7+
system(*args, exception: true)
98
end
109

1110
FileUtils.chdir APP_ROOT do
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
1413
# Add necessary setup steps to this file.
1514

1615
puts "== Installing dependencies =="
17-
system! "gem install bundler --conservative"
1816
system("bundle check") || system!("bundle install")
1917

2018
# puts "\n== Copying sample files =="
@@ -28,6 +26,9 @@ FileUtils.chdir APP_ROOT do
2826
puts "\n== Removing old logs and tempfiles =="
2927
system! "bin/rails log:clear tmp:clear"
3028

31-
puts "\n== Restarting application server =="
32-
system! "bin/rails restart"
29+
unless ARGV.include?("--skip-server")
30+
puts "\n== Starting development server =="
31+
STDOUT.flush # flush the output before exec(2) so that it displays
32+
exec "bin/dev"
33+
end
3334
end

spec/dummy/config/application.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
require "rails"
44
# Pick the frameworks you want:
55
require "active_model/railtie"
6-
# require "active_job/railtie"
6+
require "active_job/railtie"
77
require "active_record/railtie"
8-
# require "active_storage/engine"
8+
require "active_storage/engine"
99
require "action_controller/railtie"
1010
require "action_mailer/railtie"
1111
# require "action_mailbox/engine"
@@ -17,12 +17,16 @@
1717
# Require the gems listed in Gemfile, including any gems
1818
# you've limited to :test, :development, or :production.
1919
Bundler.require(*Rails.groups)
20-
require "alchemy/devise"
2120

2221
module Dummy
2322
class Application < Rails::Application
2423
# Initialize configuration defaults for originally generated Rails version.
25-
config.load_defaults ENV.fetch("RAILS_VERSION", "7.1").to_f
24+
config.load_defaults ENV.fetch("RAILS_VERSION", "8.0").to_f
25+
26+
# Please, add to the `ignore` list any other `lib` subdirectories that do
27+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
28+
# Common ones are `templates`, `generators`, or `middleware`, for example.
29+
config.autoload_lib(ignore: %w[assets tasks])
2630

2731
# Configuration for the application, engines, and railties goes here.
2832
#

spec/dummy/config/environments/development.rb

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,67 @@
33
Rails.application.configure do
44
# Settings specified here will take precedence over those in config/application.rb.
55

6-
# In the development environment your application's code is reloaded any time
7-
# it changes. This slows down response time but is perfect for development
8-
# since you don't have to restart the web server when you make code changes.
9-
config.cache_classes = false
6+
# Make code changes take effect immediately without server restart.
7+
config.enable_reloading = true
108

119
# Do not eager load code on boot.
1210
config.eager_load = false
1311

1412
# Show full error reports.
1513
config.consider_all_requests_local = true
1614

17-
# Enable server timing
15+
# Enable server timing.
1816
config.server_timing = true
1917

20-
# Enable/disable caching. By default caching is disabled.
21-
# Run rails dev:cache to toggle caching.
18+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19+
# Run rails dev:cache to toggle Action Controller caching.
2220
if Rails.root.join("tmp/caching-dev.txt").exist?
2321
config.action_controller.perform_caching = true
2422
config.action_controller.enable_fragment_cache_logging = true
25-
26-
config.cache_store = :memory_store
27-
config.public_file_server.headers = {
28-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
29-
}
23+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
3024
else
3125
config.action_controller.perform_caching = false
32-
33-
config.cache_store = :null_store
3426
end
3527

28+
# Change to :null_store to avoid any caching.
29+
config.cache_store = :memory_store
30+
31+
# Store uploaded files on the local file system (see config/storage.yml for options).
32+
config.active_storage.service = :local
33+
3634
# Don't care if the mailer can't send.
3735
config.action_mailer.raise_delivery_errors = false
3836

37+
# Make template changes take effect immediately.
3938
config.action_mailer.perform_caching = false
4039

40+
# Set localhost to be used by links generated in mailer templates.
41+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
42+
4143
# Print deprecation notices to the Rails logger.
4244
config.active_support.deprecation = :log
4345

44-
# Raise exceptions for disallowed deprecations.
45-
config.active_support.disallowed_deprecation = :raise
46-
47-
# Tell Active Support which deprecation messages to disallow.
48-
config.active_support.disallowed_deprecation_warnings = []
49-
5046
# Raise an error on page load if there are pending migrations.
5147
config.active_record.migration_error = :page_load
5248

5349
# Highlight code that triggered database queries in logs.
5450
config.active_record.verbose_query_logs = true
5551

56-
# Debug mode disables concatenation and preprocessing of assets.
57-
# This option may cause significant delays in view rendering with a large
58-
# number of complex assets.
59-
config.assets.debug = true
52+
# Append comments with runtime information tags to SQL queries in logs.
53+
config.active_record.query_log_tags_enabled = true
6054

61-
# Suppress logger output for asset requests.
62-
config.assets.quiet = true
55+
# Highlight code that enqueued background job in logs.
56+
config.active_job.verbose_enqueue_logs = true
6357

6458
# Raises error for missing translations.
6559
# config.i18n.raise_on_missing_translations = true
6660

6761
# Annotate rendered view with file names.
68-
# config.action_view.annotate_rendered_view_with_filenames = true
62+
config.action_view.annotate_rendered_view_with_filenames = true
63+
64+
# Raise error when a before_action's only/except options reference missing actions.
65+
config.action_controller.raise_on_missing_callback_actions = true
6966

70-
# Uncomment if you wish to allow Action Cable access from any origin.
71-
# config.action_cable.disable_request_forgery_protection = true
67+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
68+
# config.generators.apply_rubocop_autocorrect_after_generate!
7269
end

spec/dummy/config/environments/production.rb

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,86 @@
44
# Settings specified here will take precedence over those in config/application.rb.
55

66
# Code is not reloaded between requests.
7-
config.cache_classes = true
7+
config.enable_reloading = false
88

9-
# Eager load code on boot. This eager loads most of Rails and
10-
# your application in memory, allowing both threaded web servers
11-
# and those relying on copy on write to perform better.
12-
# Rake tasks automatically ignore this option for performance.
9+
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
1310
config.eager_load = true
1411

15-
# Full error reports are disabled and caching is turned on.
16-
config.consider_all_requests_local = false
17-
config.action_controller.perform_caching = true
18-
19-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21-
# config.require_master_key = true
22-
23-
# Disable serving static files from the `/public` folder by default since
24-
# Apache or NGINX already handles this.
25-
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
12+
# Full error reports are disabled.
13+
config.consider_all_requests_local = false
2614

27-
# Compress CSS using a preprocessor.
28-
# config.assets.css_compressor = :sass
15+
# Turn on fragment caching in view templates.
16+
config.action_controller.perform_caching = true
2917

30-
# Do not fallback to assets pipeline if a precompiled asset is missed.
31-
config.assets.compile = false
18+
# Cache assets for far-future expiry since they are all digest stamped.
19+
config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
3220

3321
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3422
# config.asset_host = "http://assets.example.com"
3523

36-
# Specifies the header that your server uses for sending files.
37-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
38-
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
24+
# Store uploaded files on the local file system (see config/storage.yml for options).
25+
config.active_storage.service = :local
26+
27+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
28+
config.assume_ssl = true
3929

4030
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
41-
# config.force_ssl = true
31+
config.force_ssl = true
4232

43-
# Include generic and useful information about system operation, but avoid logging too much
44-
# information to avoid inadvertent exposure of personally identifiable information (PII).
45-
config.log_level = :info
33+
# Skip http-to-https redirect for the default health check endpoint.
34+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
4635

47-
# Prepend all log lines with the following tags.
36+
# Log to STDOUT with the current request id as a default log tag.
4837
config.log_tags = [ :request_id ]
38+
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
4939

50-
# Use a different cache store in production.
51-
# config.cache_store = :mem_cache_store
40+
# Change to "debug" to log everything (including potentially personally-identifiable information!)
41+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
42+
43+
# Prevent health checks from clogging up the logs.
44+
config.silence_healthcheck_path = "/up"
45+
46+
# Don't log any deprecations.
47+
config.active_support.report_deprecations = false
5248

53-
# Use a real queuing backend for Active Job (and separate queues per environment).
54-
# config.active_job.queue_adapter = :resque
55-
# config.active_job.queue_name_prefix = "dummy_production"
49+
# Replace the default in-process memory cache store with a durable alternative.
50+
# config.cache_store = :mem_cache_store
5651

57-
config.action_mailer.perform_caching = false
52+
# Replace the default in-process and non-durable queuing backend for Active Job.
53+
# config.active_job.queue_adapter = :resque
5854

5955
# Ignore bad email addresses and do not raise email delivery errors.
6056
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
6157
# config.action_mailer.raise_delivery_errors = false
6258

59+
# Set host to be used by links generated in mailer templates.
60+
config.action_mailer.default_url_options = { host: "example.com" }
61+
62+
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
63+
# config.action_mailer.smtp_settings = {
64+
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
65+
# password: Rails.application.credentials.dig(:smtp, :password),
66+
# address: "smtp.example.com",
67+
# port: 587,
68+
# authentication: :plain
69+
# }
70+
6371
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
6472
# the I18n.default_locale when a translation cannot be found).
6573
config.i18n.fallbacks = true
6674

67-
# Don't log any deprecations.
68-
config.active_support.report_deprecations = false
69-
70-
# Use default logging formatter so that PID and timestamp are not suppressed.
71-
config.log_formatter = ::Logger::Formatter.new
72-
73-
# Use a different logger for distributed setups.
74-
# require "syslog/logger"
75-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
76-
77-
if ENV["RAILS_LOG_TO_STDOUT"].present?
78-
logger = ActiveSupport::Logger.new(STDOUT)
79-
logger.formatter = config.log_formatter
80-
config.logger = ActiveSupport::TaggedLogging.new(logger)
81-
end
82-
8375
# Do not dump schema after migrations.
8476
config.active_record.dump_schema_after_migration = false
77+
78+
# Only use :id for inspections in production.
79+
config.active_record.attributes_for_inspect = [ :id ]
80+
81+
# Enable DNS rebinding protection and other `Host` header attacks.
82+
# config.hosts = [
83+
# "example.com", # Allow requests from example.com
84+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
85+
# ]
86+
#
87+
# Skip DNS rebinding protection for the default health check endpoint.
88+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
8589
end

0 commit comments

Comments
 (0)