diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 3ea674f37..11040bfe3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -59,9 +59,6 @@ jobs: strategy: matrix: appraisal: [ - 'rails50_rack22', - 'rails52_rack22', - 'rails60_rack22', 'rails61_rack22', 'rails70_rack22', 'rails71_rack22', diff --git a/Appraisals b/Appraisals index d23863e35..dd04ccfa3 100644 --- a/Appraisals +++ b/Appraisals @@ -3,9 +3,6 @@ version_spec = ->(prefix, desc) { "~> #{desc.split(prefix).last.insert(1, ".")}. # Rails version -> rack versions in format # rails#{MAJOR}#{MINOR} => %w[ rack#{MAJOR}#{MINOR} ] { - "rails50" => %w[rack22], - "rails52" => %w[rack22], - "rails60" => %w[rack22], "rails61" => %w[rack22], "rails70" => %w[rack22], "rails71" => %w[rack22], diff --git a/History.md b/History.md index e438bcafa..077658365 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ - Support Javax Servlet API 4.0 (JEE 8) - Adds basic compatibility with JRuby 10.0 - Drop support for JRuby 9.3 +- Drop support for Rails < 6.1 - Drop unnecessary `jruby.compat.version` and `RackConfig.getCompatVersion()` API - Drop JMS support - Drop deprecated `RackLogger` string (level) constants diff --git a/README.md b/README.md index e1c181b92..0c973ada6 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ For more information on Rack, visit http://rack.github.io/. | JRuby-Rack Series | Status | Rack | JRuby | Java | Rails | Target Servlet API | Notes | |------------------------------------------------------------|------------|-----------|------------|------|-----------|---------------------|--------------------------------------------| -| 2.0 (_planned_) | Dev | 2.2 | 9.4 → 10.0 | 8+ | 5.0 → 8.0 | 5.0+ (Jakarta EE 9) | Pre 5.0 servlet APIs non functional. | -| 1.3 (master, _unreleased_) | Dev | 2.2 | 9.4 → 10.0 | 8+ | 5.0 → 8.0 | 4.0 (Java EE 8) | Servlet 2.5 → 3.1 likely to work fine. | +| 2.0 (_planned_) | Dev | 2.2 | 9.4 → 10.0 | 8+ | 6.1 → 8.0 | 5.0+ (Jakarta EE 9) | Pre 5.0 servlet APIs non functional. | +| 1.3 (master, _unreleased_) | Dev | 2.2 | 9.4 → 10.0 | 8+ | 6.1 → 8.0 | 4.0 (Java EE 8) | Servlet 2.5 → 3.1 likely to work fine. | | [1.2](https://github.com/jruby/jruby-rack/tree/1.2-stable) | Maintained | 2.2 | 9.3 → 9.4 | 8+ | 5.0 → 7.2 | 3.0 (Java EE 6) | Servlet 3.1 → 4.0 OK with some containers. | | [1.1](https://github.com/jruby/jruby-rack/tree/1.1-stable) | EOL | 1.x → 2.2 | 1.6 → 9.4 | 6+ | 2.1 → 5.2 | 2.5 (Java EE 5) | Servlet 3.0 → 4.0 OK with some containers. | | 1.0 | EOL | 0.9 → 1.x | 1.1 → 1.9 | 5+ | 2.1 → 3.x | 2.5 (Java EE 5) | | @@ -335,6 +335,20 @@ package and push the .jar every time a commit changes a source file). * `./mvnw release:perform` (possibly with `-DuseReleaseProfile=false` due to Javadoc doclint failures for now) * `rake clean gem SKIP_SPECS=true` and push the gem +## Adding testing for new Rails versions + +* Add the new version to `.github/workflows/maven.yml` under the `matrix` section +* Add a new configuration to the `Appraisals` file, then + ```bundle exec appraisal generate``` +* Generate a new stub Rails application for the new version + ```shell + VERSION=rails72 + cd src/spec/stub + rm -rf $VERSION && BUNDLE_GEMFILE=~/Projects/community/jruby-rack/gemfiles/${VERSION}_rack22.gemfile bundle exec rails new $VERSION --minimal --skip-git --skip-docker --skip-active-model --skip-active-record --skip-test --skip-system-test --skip-dev-gems --skip-bundle --skip-keeps --skip-asset-pipeline --skip-ci --skip-brakeman --skip-rubocop + ``` +* Manual changes to make to support testing + * In `config/production.rb` comment out the default `config.logger` value so jruby-rack applies its own `RailsLogger`. + ## Support Please use [github][3] to file bugs, patches and/or pull requests. diff --git a/gemfiles/rails50_rack22.gemfile b/gemfiles/rails50_rack22.gemfile deleted file mode 100644 index 38c611b35..000000000 --- a/gemfiles/rails50_rack22.gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rake", "~> 13.3", group: :test, require: nil -gem "rspec", group: :test - -group :default do - gem "rack", "~> 2.2.0" - gem "rails", "~> 5.0.0" -end - -group :development do - gem "appraisal", require: nil -end diff --git a/gemfiles/rails52_rack22.gemfile b/gemfiles/rails52_rack22.gemfile deleted file mode 100644 index 3936b45c3..000000000 --- a/gemfiles/rails52_rack22.gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rake", "~> 13.3", group: :test, require: nil -gem "rspec", group: :test - -group :default do - gem "rack", "~> 2.2.0" - gem "rails", "~> 5.2.0" -end - -group :development do - gem "appraisal", require: nil -end diff --git a/gemfiles/rails60_rack22.gemfile b/gemfiles/rails60_rack22.gemfile deleted file mode 100644 index bb01c8595..000000000 --- a/gemfiles/rails60_rack22.gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rake", "~> 13.3", group: :test, require: nil -gem "rspec", group: :test - -group :default do - gem "rack", "~> 2.2.0" - gem "rails", "~> 6.0.0" -end - -group :development do - gem "appraisal", require: nil -end diff --git a/src/spec/ruby/jruby/rack/integration_spec.rb b/src/spec/ruby/jruby/rack/integration_spec.rb index c885a3d89..1ba98724f 100644 --- a/src/spec/ruby/jruby/rack/integration_spec.rb +++ b/src/spec/ruby/jruby/rack/integration_spec.rb @@ -82,77 +82,73 @@ end + it "should have defined Rails stub tests" do + expect(File.foreach(__FILE__).select { |line| line.include?("describe") }).to include(/^ describe.*lib: :#{CURRENT_LIB}/), + "Expected rails stub tests to be defined for #{CURRENT_LIB} inside integration_spec.rb" + expect(File.exist?(File.join(STUB_DIR, CURRENT_LIB.to_s))).to be(true), + "Expected rails stub dir for #{CURRENT_LIB.to_s} to exist at #{File.join(STUB_DIR, CURRENT_LIB.to_s).inspect}" + end if CURRENT_LIB.to_s.include?('rails') + shared_examples_for 'a rails app', :shared => true do + base_path = "file://#{STUB_DIR}/#{CURRENT_LIB.to_s}" + let(:servlet_context) do - new_servlet_context(base_path).tap { |servlet_context| prepare_servlet_context(servlet_context) } + new_servlet_context(base_path).tap { |servlet_context| prepare_servlet_context(servlet_context, base_path) } end - it "initializes pooling when min/max set" do - servlet_context.addInitParameter('jruby.min.runtimes', '1') - servlet_context.addInitParameter('jruby.max.runtimes', '2') - - listener = org.jruby.rack.rails.RailsServletContextListener.new - listener.contextInitialized javax.servlet.ServletContextEvent.new(servlet_context) + context "runtime" do - rack_factory = servlet_context.getAttribute("rack.factory") - expect(rack_factory).to be_a(RackApplicationFactory) - expect(rack_factory).to be_a(PoolingRackApplicationFactory) - expect(rack_factory.delegate).to be_a(RailsRackApplicationFactory) + it "initializes pooling when min/max set" do + servlet_context.addInitParameter('jruby.min.runtimes', '1') + servlet_context.addInitParameter('jruby.max.runtimes', '2') - expect(servlet_context.getAttribute("rack.context")).to be_a(RackContext) - expect(servlet_context.getAttribute("rack.context")).to be_a(ServletRackContext) + listener = org.jruby.rack.rails.RailsServletContextListener.new + listener.contextInitialized javax.servlet.ServletContextEvent.new(servlet_context) - expect(rack_factory.getApplication).to be_a(DefaultRackApplication) - end + rack_factory = servlet_context.getAttribute("rack.factory") + expect(rack_factory).to be_a(RackApplicationFactory) + expect(rack_factory).to be_a(PoolingRackApplicationFactory) + expect(rack_factory.delegate).to be_a(RailsRackApplicationFactory) - it "initializes shared (thread-safe) by default" do - listener = org.jruby.rack.rails.RailsServletContextListener.new - listener.contextInitialized javax.servlet.ServletContextEvent.new(servlet_context) + expect(servlet_context.getAttribute("rack.context")).to be_a(RackContext) + expect(servlet_context.getAttribute("rack.context")).to be_a(ServletRackContext) - rack_factory = servlet_context.getAttribute("rack.factory") - expect(rack_factory).to be_a(RackApplicationFactory) - expect(rack_factory).to be_a(SharedRackApplicationFactory) - expect(rack_factory.delegate).to be_a(RailsRackApplicationFactory) - - expect(rack_factory.getApplication).to be_a(DefaultRackApplication) - end - - it "initializes shared (thread-safe) whem max runtimes is 1" do - servlet_context.addInitParameter('jruby.max.runtimes', '1') + expect(rack_factory.getApplication).to be_a(DefaultRackApplication) + end - listener = org.jruby.rack.rails.RailsServletContextListener.new - listener.contextInitialized javax.servlet.ServletContextEvent.new(servlet_context) + it "initializes shared (thread-safe) by default" do + listener = org.jruby.rack.rails.RailsServletContextListener.new + listener.contextInitialized javax.servlet.ServletContextEvent.new(servlet_context) - rack_factory = servlet_context.getAttribute("rack.factory") - expect(rack_factory).to be_a(RackApplicationFactory) - expect(rack_factory).to be_a(SharedRackApplicationFactory) - expect(rack_factory.delegate).to be_a(RailsRackApplicationFactory) - end + rack_factory = servlet_context.getAttribute("rack.factory") + expect(rack_factory).to be_a(RackApplicationFactory) + expect(rack_factory).to be_a(SharedRackApplicationFactory) + expect(rack_factory.delegate).to be_a(RailsRackApplicationFactory) - end + expect(rack_factory.getApplication).to be_a(DefaultRackApplication) + end - describe 'rails 7.2', lib: :rails72 do + it "initializes shared (thread-safe) whem max runtimes is 1" do + servlet_context.addInitParameter('jruby.max.runtimes', '1') - before(:all) do - name = :rails72 # copy_gemfile : - raise "Environment variable BUNDLE_GEMFILE seems to not contain #{name.to_s}" unless ENV['BUNDLE_GEMFILE']&.include?(name.to_s) - FileUtils.cp ENV['BUNDLE_GEMFILE'], File.join(STUB_DIR, "#{name}/Gemfile") - FileUtils.cp "#{ENV['BUNDLE_GEMFILE']}.lock", File.join(STUB_DIR, "#{name}/Gemfile.lock") - Dir.chdir File.join(STUB_DIR, name.to_s) - end + listener = org.jruby.rack.rails.RailsServletContextListener.new + listener.contextInitialized javax.servlet.ServletContextEvent.new(servlet_context) - def base_path - "#{STUB_DIR}/rails72" + rack_factory = servlet_context.getAttribute("rack.factory") + expect(rack_factory).to be_a(RackApplicationFactory) + expect(rack_factory).to be_a(SharedRackApplicationFactory) + expect(rack_factory.delegate).to be_a(RailsRackApplicationFactory) + end end - it_should_behave_like 'a rails app' - context "initialized" do + before(:all) { copy_gemfile } + before(:all) do initialize_rails('production', "file://#{base_path}") do |servlet_context, _| - prepare_servlet_context(servlet_context) + prepare_servlet_context(servlet_context, base_path) end end after(:all) { restore_rails } @@ -168,21 +164,30 @@ def base_path should_eval_as_not_nil "defined?(Rails)" should_eval_as_not_nil "Rails.logger" - # Rails 7.x wraps the default in a ActiveSupport::BroadcastLogger - should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::BroadcastLogger", true - should_eval_as_eql_to "Rails.logger.broadcasts.size", 1 - should_eval_as_eql_to "Rails.logger.broadcasts.first.is_a? JRuby::Rack::Logger", true - # NOTE: TaggedLogging is a module that extends the logger instance: - should_eval_as_eql_to "Rails.logger.broadcasts.first.is_a? ActiveSupport::TaggedLogging", true - # production.rb: config.log_level = 'info' should_eval_as_eql_to "Rails.logger.level", Logger::INFO - should_eval_as_eql_to "Rails.logger.broadcasts.first.level", Logger::INFO - unwrap_logger = "logger = Rails.logger.broadcasts.first;" + # Rails 7.1+ wraps the default in a ActiveSupport::BroadcastLogger + if Rails::VERSION::STRING < '7.1' + should_eval_as_eql_to "Rails.logger.is_a? JRuby::Rack::Logger", true + should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::TaggedLogging", true + unwrap_logger = "logger = Rails.logger;" + else + should_eval_as_not_nil "defined?(ActiveSupport::BroadcastLogger)" + should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::BroadcastLogger", true + should_eval_as_eql_to "Rails.logger.broadcasts.size", 1 + should_eval_as_eql_to "Rails.logger.broadcasts.first.is_a? JRuby::Rack::Logger", true + # NOTE: TaggedLogging is a module that extends the logger instance: + should_eval_as_eql_to "Rails.logger.broadcasts.first.is_a? ActiveSupport::TaggedLogging", true + + should_eval_as_eql_to "Rails.logger.broadcasts.first.level", Logger::INFO + + unwrap_logger = "logger = Rails.logger.broadcasts.first;" + end + # sanity check logger-silence works: + should_eval_as_not_nil "#{unwrap_logger} defined?(logger.silence)" should_eval_as_eql_to "#{unwrap_logger} logger.silence { logger.warn('from-integration-spec') }", true - should_eval_as_eql_to "#{unwrap_logger} logger.real_logger.is_a?(org.jruby.rack.logging.ServletContextLogger)", true end @@ -191,9 +196,33 @@ def base_path should_eval_as_eql_to "Rails.public_path.to_s", "#{base_path}/public" end + it "disables rack's chunked support (by default)" do + @runtime = @rack_factory.getApplication.getRuntime + expect_to_have_monkey_patched_chunked + end end end + describe 'rails 6.1', lib: :rails61 do + it_should_behave_like 'a rails app' + end + + describe 'rails 7.0', lib: :rails70 do + it_should_behave_like 'a rails app' + end + + describe 'rails 7.1', lib: :rails71 do + it_should_behave_like 'a rails app' + end + + describe 'rails 7.2', lib: :rails72 do + it_should_behave_like 'a rails app' + end + + describe 'rails 8.0', lib: :rails80 do + it_should_behave_like 'a rails app' + end + def expect_to_have_monkey_patched_chunked @runtime.evalScriptlet "require 'rack/chunked'" script = %{ @@ -232,17 +261,19 @@ def new_servlet_context(base_path = nil) servlet_context end - def prepare_servlet_context(servlet_context) + def prepare_servlet_context(servlet_context, base_path) servlet_context.addInitParameter('rails.root', base_path) servlet_context.addInitParameter('jruby.rack.layout_class', 'FileSystemLayout') end GEMFILES_DIR = File.expand_path('../../../gemfiles', STUB_DIR) - def copy_gemfile(name) - # e.g. 'rails30' - FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile"), File.join(STUB_DIR, "#{name}/WEB-INF/Gemfile") - FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile.lock"), File.join(STUB_DIR, "#{name}/WEB-INF/Gemfile.lock") + def copy_gemfile + name = CURRENT_LIB.to_s + raise "Environment variable BUNDLE_GEMFILE seems to not contain #{name}" unless ENV['BUNDLE_GEMFILE']&.include?(name) + FileUtils.cp ENV['BUNDLE_GEMFILE'], File.join(STUB_DIR, "#{name}/Gemfile") + FileUtils.cp "#{ENV['BUNDLE_GEMFILE']}.lock", File.join(STUB_DIR, "#{name}/Gemfile.lock") + Dir.chdir File.join(STUB_DIR, name) end ENV_COPY = ENV.to_h diff --git a/src/spec/stub/.gitignore b/src/spec/stub/.gitignore index ed438a4a2..7095ce900 100644 --- a/src/spec/stub/.gitignore +++ b/src/spec/stub/.gitignore @@ -1,2 +1,21 @@ */tmp */*.war + +# Rails stub files we don't want +rails*/Rakefile +rails*/Gemfile +rails*/Gemfile.lock +rails*/bin +rails*/README.md +rails*/config.ru +rails*/.ruby-version +rails*/package.json + +# Rails generates assets in samples that we don't really want +rails*/**/*.ico +rails*/**/*.png +rails*/**/*.svg +rails*/**/*.html +rails*/**/*.erb +rails*/**/*.js +rails*/**/*.css diff --git a/src/spec/stub/rails61/app/controllers/application_controller.rb b/src/spec/stub/rails61/app/controllers/application_controller.rb new file mode 100644 index 000000000..09705d12a --- /dev/null +++ b/src/spec/stub/rails61/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/src/spec/stub/rails61/app/helpers/application_helper.rb b/src/spec/stub/rails61/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/src/spec/stub/rails61/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/src/spec/stub/rails61/config/application.rb b/src/spec/stub/rails61/config/application.rb new file mode 100644 index 000000000..9f1353e94 --- /dev/null +++ b/src/spec/stub/rails61/config/application.rb @@ -0,0 +1,38 @@ +require_relative "boot" + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +# require "active_job/railtie" +# require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +# require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" +require "action_view/railtie" +# require "action_cable/engine" +# require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails61 + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 6.1 + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/src/spec/stub/rails61/config/boot.rb b/src/spec/stub/rails61/config/boot.rb new file mode 100644 index 000000000..9e68e5f0c --- /dev/null +++ b/src/spec/stub/rails61/config/boot.rb @@ -0,0 +1,6 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. + +# workaround for https://github.com/ruby-concurrency/concurrent-ruby/issues/1077 since https://github.com/rails/rails/pull/54264 wont be backported earlier than 7.1. +require "logger" diff --git a/src/spec/stub/rails61/config/credentials.yml.enc b/src/spec/stub/rails61/config/credentials.yml.enc new file mode 100644 index 000000000..617e129f3 --- /dev/null +++ b/src/spec/stub/rails61/config/credentials.yml.enc @@ -0,0 +1 @@ +h7j6TBtL1MQo4aye3KuFMJqXjsojY1IPfhda51j54oYS0xgUgqz+5wlsyq7mFhh549MUTEWxaYWm1bDOooOtMKrIuUzDkXfgyZLWyvhMtfGRbe74a/SGS+M8SDXN65XgeVcYpiZxIHmTeXj/FQ2t3nXjXkQV1g892+XFzgB1mYE59B6B1b21m0lVVSKMXHZhVguZEMnAB6sdVDIdQQA2xOFllnVcIdAvifHE0GYKgALCgdVeRDs1Ob3xZp0cXaZBqGl27lR1a+8MyR1ZDwZ08aysmtzY4koUE6JR5Auv3SBpVr0xXihTWZB55/H0b6t1SXiGRr06EnsM1libanIX1II36IBcsi4MOMLjj89KDUaLOTfbFMtcRMh+r7YHZEgIQksMVl6yxQVH3tjzlbgPXC5alj+sICKsh1ve--YuCA+1XrgTwmE0Oc--JvkiuzV70g4zSz7VF3/21w== \ No newline at end of file diff --git a/src/spec/stub/rails61/config/environment.rb b/src/spec/stub/rails61/config/environment.rb new file mode 100644 index 000000000..cac531577 --- /dev/null +++ b/src/spec/stub/rails61/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/src/spec/stub/rails61/config/environments/development.rb b/src/spec/stub/rails61/config/environments/development.rb new file mode 100644 index 000000000..1181937f3 --- /dev/null +++ b/src/spec/stub/rails61/config/environments/development.rb @@ -0,0 +1,55 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # 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 + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true +end diff --git a/src/spec/stub/rails61/config/environments/production.rb b/src/spec/stub/rails61/config/environments/production.rb new file mode 100644 index 000000000..0d5988d60 --- /dev/null +++ b/src/spec/stub/rails61/config/environments/production.rb @@ -0,0 +1,94 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = 'http://assets.example.com' + + # 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-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # 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. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + 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 diff --git a/src/spec/stub/rails61/config/environments/test.rb b/src/spec/stub/rails61/config/environments/test.rb new file mode 100644 index 000000000..9fa79ddf0 --- /dev/null +++ b/src/spec/stub/rails61/config/environments/test.rb @@ -0,0 +1,49 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true +end diff --git a/src/spec/stub/rails61/config/initializers/application_controller_renderer.rb b/src/spec/stub/rails61/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..89d2efab2 --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/src/spec/stub/rails61/config/initializers/backtrace_silencers.rb b/src/spec/stub/rails61/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..33699c309 --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/backtrace_silencers.rb @@ -0,0 +1,8 @@ +# 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"] diff --git a/src/spec/stub/rails61/config/initializers/content_security_policy.rb b/src/spec/stub/rails61/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..41c43016f --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/content_security_policy.rb @@ -0,0 +1,28 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Set the nonce only to specific directives +# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/src/spec/stub/rails61/config/initializers/cookies_serializer.rb b/src/spec/stub/rails61/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..5a6a32d37 --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/src/spec/stub/rails61/config/initializers/filter_parameter_logging.rb b/src/spec/stub/rails61/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4b34a0366 --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/src/spec/stub/rails61/config/initializers/inflections.rb b/src/spec/stub/rails61/config/initializers/inflections.rb new file mode 100644 index 000000000..ac033bf9d --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/src/spec/stub/rails61/config/initializers/mime_types.rb b/src/spec/stub/rails61/config/initializers/mime_types.rb new file mode 100644 index 000000000..dc1899682 --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/src/spec/stub/rails61/config/initializers/permissions_policy.rb b/src/spec/stub/rails61/config/initializers/permissions_policy.rb new file mode 100644 index 000000000..00f64d71b --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/src/spec/stub/rails61/config/initializers/wrap_parameters.rb b/src/spec/stub/rails61/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..633c1c889 --- /dev/null +++ b/src/spec/stub/rails61/config/initializers/wrap_parameters.rb @@ -0,0 +1,9 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end diff --git a/src/spec/stub/rails61/config/locales/en.yml b/src/spec/stub/rails61/config/locales/en.yml new file mode 100644 index 000000000..cf9b342d0 --- /dev/null +++ b/src/spec/stub/rails61/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/src/spec/stub/rails61/config/master.key b/src/spec/stub/rails61/config/master.key new file mode 100644 index 000000000..bd61b157b --- /dev/null +++ b/src/spec/stub/rails61/config/master.key @@ -0,0 +1 @@ +41965057759dc9068cf6c6ee8a971b61 \ No newline at end of file diff --git a/src/spec/stub/rails61/config/routes.rb b/src/spec/stub/rails61/config/routes.rb new file mode 100644 index 000000000..c06383a17 --- /dev/null +++ b/src/spec/stub/rails61/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html +end diff --git a/src/spec/stub/rails61/public/robots.txt b/src/spec/stub/rails61/public/robots.txt new file mode 100644 index 000000000..c19f78ab6 --- /dev/null +++ b/src/spec/stub/rails61/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/src/spec/stub/rails70/app/controllers/application_controller.rb b/src/spec/stub/rails70/app/controllers/application_controller.rb new file mode 100644 index 000000000..09705d12a --- /dev/null +++ b/src/spec/stub/rails70/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/src/spec/stub/rails70/app/helpers/application_helper.rb b/src/spec/stub/rails70/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/src/spec/stub/rails70/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/src/spec/stub/rails70/config/application.rb b/src/spec/stub/rails70/config/application.rb new file mode 100644 index 000000000..44477b8d5 --- /dev/null +++ b/src/spec/stub/rails70/config/application.rb @@ -0,0 +1,37 @@ +require_relative "boot" + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +# require "active_job/railtie" +# require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +# require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" +require "action_view/railtie" +# require "action_cable/engine" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails70 + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.0 + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/src/spec/stub/rails70/config/boot.rb b/src/spec/stub/rails70/config/boot.rb new file mode 100644 index 000000000..0980b3ef5 --- /dev/null +++ b/src/spec/stub/rails70/config/boot.rb @@ -0,0 +1,5 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. +# workaround for https://github.com/ruby-concurrency/concurrent-ruby/issues/1077 since https://github.com/rails/rails/pull/54264 wont be backported earlier than 7.1. +require "logger" diff --git a/src/spec/stub/rails70/config/credentials.yml.enc b/src/spec/stub/rails70/config/credentials.yml.enc new file mode 100644 index 000000000..11e04461a --- /dev/null +++ b/src/spec/stub/rails70/config/credentials.yml.enc @@ -0,0 +1 @@ +Ks8WMqYXI67JiLvqB2XFPU1q+c0phvGDsA4VkaSNJvsZKx3kog3FfnkmGOzK1J7elI+RbI39JzkJrfFyPuglERXgMK+/thpJYKWwhmU1AGsTjSJfumB5jIHIVJhMh1TYKZmas1lzV0SlzUpqJy9UcyucYwqXdCHGyTcHugiv0zwelMO3M/KCDEssNWSAi1fV7lKj/eIdkgE4lOX6XpfF58085OJ5BUZWWKSK1vBq0+xxv8czG7UxaLCv8xu5MEwnhztruuKPE4gV7eVbHcKHfJTibA2MNY1G4LJk9G+wLkg8GIf+oSyB81Y+mTfcaii2fN9FP2+d0aASFYRT6LX1HAnLybxhK5yCLBOK5Hb414TntUwTnun4a+LObZCOcBcFVvC/a3KdDIXfaTvQw72oMz6qcq5YeAkSaWv4--1vC+tsi2Y0YsIwOi--pMvCIu1i4YfRyVxVYg7MIg== \ No newline at end of file diff --git a/src/spec/stub/rails70/config/environment.rb b/src/spec/stub/rails70/config/environment.rb new file mode 100644 index 000000000..cac531577 --- /dev/null +++ b/src/spec/stub/rails70/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/src/spec/stub/rails70/config/environments/development.rb b/src/spec/stub/rails70/config/environments/development.rb new file mode 100644 index 000000000..6df11e560 --- /dev/null +++ b/src/spec/stub/rails70/config/environments/development.rb @@ -0,0 +1,54 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true +end diff --git a/src/spec/stub/rails70/config/environments/production.rb b/src/spec/stub/rails70/config/environments/production.rb new file mode 100644 index 000000000..061063854 --- /dev/null +++ b/src/spec/stub/rails70/config/environments/production.rb @@ -0,0 +1,66 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # 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-Accel-Redirect" # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end +end diff --git a/src/spec/stub/rails70/config/environments/test.rb b/src/spec/stub/rails70/config/environments/test.rb new file mode 100644 index 000000000..eb2f1716c --- /dev/null +++ b/src/spec/stub/rails70/config/environments/test.rb @@ -0,0 +1,50 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # 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 + + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true +end diff --git a/src/spec/stub/rails70/config/initializers/content_security_policy.rb b/src/spec/stub/rails70/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..54f47cf15 --- /dev/null +++ b/src/spec/stub/rails70/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/src/spec/stub/rails70/config/initializers/filter_parameter_logging.rb b/src/spec/stub/rails70/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..adc6568ce --- /dev/null +++ b/src/spec/stub/rails70/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this 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 += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/src/spec/stub/rails70/config/initializers/inflections.rb b/src/spec/stub/rails70/config/initializers/inflections.rb new file mode 100644 index 000000000..3860f659e --- /dev/null +++ b/src/spec/stub/rails70/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/src/spec/stub/rails70/config/initializers/permissions_policy.rb b/src/spec/stub/rails70/config/initializers/permissions_policy.rb new file mode 100644 index 000000000..00f64d71b --- /dev/null +++ b/src/spec/stub/rails70/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/src/spec/stub/rails70/config/locales/en.yml b/src/spec/stub/rails70/config/locales/en.yml new file mode 100644 index 000000000..8ca56fc74 --- /dev/null +++ b/src/spec/stub/rails70/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t "hello" +# +# In views, this is aliased to just `t`: +# +# <%= t("hello") %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# "true": "foo" +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/src/spec/stub/rails70/config/master.key b/src/spec/stub/rails70/config/master.key new file mode 100644 index 000000000..2d6deb451 --- /dev/null +++ b/src/spec/stub/rails70/config/master.key @@ -0,0 +1 @@ +61cbceab4f72f0eb29a43fad2807a128 \ No newline at end of file diff --git a/src/spec/stub/rails70/config/puma.rb b/src/spec/stub/rails70/config/puma.rb new file mode 100644 index 000000000..daaf03699 --- /dev/null +++ b/src/spec/stub/rails70/config/puma.rb @@ -0,0 +1,43 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart diff --git a/src/spec/stub/rails70/config/routes.rb b/src/spec/stub/rails70/config/routes.rb new file mode 100644 index 000000000..262ffd547 --- /dev/null +++ b/src/spec/stub/rails70/config/routes.rb @@ -0,0 +1,6 @@ +Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Defines the root path route ("/") + # root "articles#index" +end diff --git a/src/spec/stub/rails70/public/robots.txt b/src/spec/stub/rails70/public/robots.txt new file mode 100644 index 000000000..c19f78ab6 --- /dev/null +++ b/src/spec/stub/rails70/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/src/spec/stub/rails71/README.md b/src/spec/stub/rails71/README.md new file mode 100644 index 000000000..7db80e4ca --- /dev/null +++ b/src/spec/stub/rails71/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/src/spec/stub/rails71/Rakefile b/src/spec/stub/rails71/Rakefile new file mode 100644 index 000000000..9a5ea7383 --- /dev/null +++ b/src/spec/stub/rails71/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative "config/application" + +Rails.application.load_tasks diff --git a/src/spec/stub/rails71/app/controllers/application_controller.rb b/src/spec/stub/rails71/app/controllers/application_controller.rb new file mode 100644 index 000000000..09705d12a --- /dev/null +++ b/src/spec/stub/rails71/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/src/spec/stub/rails71/app/helpers/application_helper.rb b/src/spec/stub/rails71/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/src/spec/stub/rails71/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/src/spec/stub/rails71/config.ru b/src/spec/stub/rails71/config.ru new file mode 100644 index 000000000..4a3c09a68 --- /dev/null +++ b/src/spec/stub/rails71/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/src/spec/stub/rails71/config/application.rb b/src/spec/stub/rails71/config/application.rb new file mode 100644 index 000000000..f384d7e7b --- /dev/null +++ b/src/spec/stub/rails71/config/application.rb @@ -0,0 +1,42 @@ +require_relative "boot" + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +# require "active_job/railtie" +# require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +# require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" +require "action_view/railtie" +# require "action_cable/engine" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails71 + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.1 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w(assets tasks)) + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/src/spec/stub/rails71/config/boot.rb b/src/spec/stub/rails71/config/boot.rb new file mode 100644 index 000000000..282011619 --- /dev/null +++ b/src/spec/stub/rails71/config/boot.rb @@ -0,0 +1,3 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/src/spec/stub/rails71/config/credentials.yml.enc b/src/spec/stub/rails71/config/credentials.yml.enc new file mode 100644 index 000000000..8a29b57f4 --- /dev/null +++ b/src/spec/stub/rails71/config/credentials.yml.enc @@ -0,0 +1 @@ ++u1GpoOEX4wRcKPVlXaWaCNL2ovW0/lhPoCilF6FPYlM4/gI7IRq7VpswS3TiH39Aak80G/J1NPei+6DInfzHv57o2Id41exbYzXuUwBy1zNXT2Ht4TTCfpRJguGf1OuSeEom+aYps0XL56RGQemudFFV14qJo0odrIGw30qvBo6Pz6qb9qnua07qKlNtosDcCTmdJ77ulXje0p/UyLwzao1yIGWpQc4NvBdxBpg8WuUomp+191LAmkIDWvoXagS5JNGGx7fFnYl8UPkce+W+sUF8SJL0EaJ//+Dipjwvvp0ph9E1UN0G8LDI7ostXDLCZSlgdWE1q7tNGqFYQLBySz6j4mxBkB5wt+/s6J7nhlpLttmDdEFB3YxiI8YC7XxqNt9AfK8BsvpeninsmppeecvMV+R--cSN3EVUUdX/ELvXi--I6//3r/xvpzSXE1dGGfX/w== \ No newline at end of file diff --git a/src/spec/stub/rails71/config/environment.rb b/src/spec/stub/rails71/config/environment.rb new file mode 100644 index 000000000..cac531577 --- /dev/null +++ b/src/spec/stub/rails71/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/src/spec/stub/rails71/config/environments/development.rb b/src/spec/stub/rails71/config/environments/development.rb new file mode 100644 index 000000000..2c4802922 --- /dev/null +++ b/src/spec/stub/rails71/config/environments/development.rb @@ -0,0 +1,54 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.enable_reloading = true + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/src/spec/stub/rails71/config/environments/production.rb b/src/spec/stub/rails71/config/environments/production.rb new file mode 100644 index 000000000..4f569bf9e --- /dev/null +++ b/src/spec/stub/rails71/config/environments/production.rb @@ -0,0 +1,70 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.enable_reloading = false + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. + # config.public_file_server.enabled = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # 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-Accel-Redirect" # for NGINX + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + config.force_ssl = true + + # Log to STDOUT by default + # config.logger = ActiveSupport::Logger.new(STDOUT) + # .tap { |logger| logger.formatter = ::Logger::Formatter.new } + # .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } +end diff --git a/src/spec/stub/rails71/config/environments/test.rb b/src/spec/stub/rails71/config/environments/test.rb new file mode 100644 index 000000000..d349c3556 --- /dev/null +++ b/src/spec/stub/rails71/config/environments/test.rb @@ -0,0 +1,54 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false + + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/src/spec/stub/rails71/config/initializers/content_security_policy.rb b/src/spec/stub/rails71/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..b3076b38f --- /dev/null +++ b/src/spec/stub/rails71/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/src/spec/stub/rails71/config/initializers/filter_parameter_logging.rb b/src/spec/stub/rails71/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..c2d89e28a --- /dev/null +++ b/src/spec/stub/rails71/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be partially matched (e.g. passw matches password) and 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 += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/src/spec/stub/rails71/config/initializers/inflections.rb b/src/spec/stub/rails71/config/initializers/inflections.rb new file mode 100644 index 000000000..3860f659e --- /dev/null +++ b/src/spec/stub/rails71/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/src/spec/stub/rails71/config/initializers/permissions_policy.rb b/src/spec/stub/rails71/config/initializers/permissions_policy.rb new file mode 100644 index 000000000..7db3b9577 --- /dev/null +++ b/src/spec/stub/rails71/config/initializers/permissions_policy.rb @@ -0,0 +1,13 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide HTTP permissions policy. For further +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" +# end diff --git a/src/spec/stub/rails71/config/locales/en.yml b/src/spec/stub/rails71/config/locales/en.yml new file mode 100644 index 000000000..6c349ae5e --- /dev/null +++ b/src/spec/stub/rails71/config/locales/en.yml @@ -0,0 +1,31 @@ +# Files in the config/locales directory are used for internationalization and +# are automatically loaded by Rails. If you want to use locales other than +# English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t "hello" +# +# In views, this is aliased to just `t`: +# +# <%= t("hello") %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. +# +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: +# +# en: +# "yes": yup +# enabled: "ON" + +en: + hello: "Hello world" diff --git a/src/spec/stub/rails71/config/master.key b/src/spec/stub/rails71/config/master.key new file mode 100644 index 000000000..3f482db3b --- /dev/null +++ b/src/spec/stub/rails71/config/master.key @@ -0,0 +1 @@ +6f7c8dd123b7a40e1efe1402ad7fd55f \ No newline at end of file diff --git a/src/spec/stub/rails71/config/puma.rb b/src/spec/stub/rails71/config/puma.rb new file mode 100644 index 000000000..7a709d7b6 --- /dev/null +++ b/src/spec/stub/rails71/config/puma.rb @@ -0,0 +1,44 @@ +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. + +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +rails_env = ENV.fetch("RAILS_ENV") { "development" } + +if rails_env == "production" + # If you are running more than 1 thread per process, the workers count + # should be equal to the number of processors (CPU cores) in production. + # + # It defaults to 1 because it's impossible to reliably detect how many + # CPU cores are available. Make sure to set the `WEB_CONCURRENCY` environment + # variable to match the number of processors. + worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { 1 }) + if worker_count > 1 + workers worker_count + else + preload_app! + end +end +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +environment rails_env + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart diff --git a/src/spec/stub/rails71/config/routes.rb b/src/spec/stub/rails71/config/routes.rb new file mode 100644 index 000000000..a125ef085 --- /dev/null +++ b/src/spec/stub/rails71/config/routes.rb @@ -0,0 +1,10 @@ +Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + # Can be used by load balancers and uptime monitors to verify that the app is live. + get "up" => "rails/health#show", as: :rails_health_check + + # Defines the root path route ("/") + # root "posts#index" +end diff --git a/src/spec/stub/rails71/public/404.html b/src/spec/stub/rails71/public/404.html new file mode 100644 index 000000000..2be3af26f --- /dev/null +++ b/src/spec/stub/rails71/public/404.html @@ -0,0 +1,67 @@ + + +
+You may have mistyped the address or the page may have moved.
+If you are the application owner check the logs for more information.
+Maybe you tried to change something you didn't have access to.
+If you are the application owner check the logs for more information.
+If you are the application owner check the logs for more information.
+Find me in app/views/sample/index.html.erb
diff --git a/src/spec/stub/rails72/config/application.rb b/src/spec/stub/rails72/config/application.rb index 9d099687a..fdd8b2b61 100644 --- a/src/spec/stub/rails72/config/application.rb +++ b/src/spec/stub/rails72/config/application.rb @@ -2,17 +2,17 @@ require "rails" # Pick the frameworks you want: -#require "active_model/railtie" -#require "active_job/railtie" -#require "active_record/railtie" -#require "active_storage/engine" +require "active_model/railtie" +# require "active_job/railtie" +# require "active_record/railtie" +# require "active_storage/engine" require "action_controller/railtie" -#require "action_mailer/railtie" -#require "action_mailbox/engine" -#require "action_text/engine" +# require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" require "action_view/railtie" -#require "action_cable/engine" -#require "rails/test_unit/railtie" +# require "action_cable/engine" +# require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -36,9 +36,7 @@ class Application < Rails::Application # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") - # Only loads a smaller set of middleware suitable for API only apps. - # Middleware like session, flash, cookies can be added back manually. - # Skip views, helpers and assets when generating a new resource. - #config.api_only = true + # Don't generate system test files. + config.generators.system_tests = nil end end diff --git a/src/spec/stub/rails72/config/environments/development.rb b/src/spec/stub/rails72/config/environments/development.rb index 1409a9162..992f090dc 100644 --- a/src/spec/stub/rails72/config/environments/development.rb +++ b/src/spec/stub/rails72/config/environments/development.rb @@ -20,6 +20,9 @@ # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + config.cache_store = :memory_store config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } else @@ -28,9 +31,6 @@ config.cache_store = :null_store end - # Store uploaded files on the local file system (see config/storage.yml for options). - #config.active_storage.service = :local - # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -40,15 +40,6 @@ # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] - # Raise an error on page load if there are pending migrations. - #config.active_record.migration_error = :page_load - - # Highlight code that triggered database queries in logs. - #config.active_record.verbose_query_logs = true - - # Highlight code that enqueued background job in logs. - #config.active_job.verbose_enqueue_logs = true - # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true @@ -57,7 +48,4 @@ # Raise error when a before_action's only/except options reference missing actions. config.action_controller.raise_on_missing_callback_actions = true - - # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. - # config.generators.apply_rubocop_autocorrect_after_generate! end diff --git a/src/spec/stub/rails72/config/environments/production.rb b/src/spec/stub/rails72/config/environments/production.rb index 31d14ad7b..781b0d383 100644 --- a/src/spec/stub/rails72/config/environments/production.rb +++ b/src/spec/stub/rails72/config/environments/production.rb @@ -14,13 +14,14 @@ # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false + config.action_controller.perform_caching = true # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. - config.public_file_server.enabled = false + # config.public_file_server.enabled = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" @@ -29,15 +30,12 @@ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - # Store uploaded files on the local file system (see config/storage.yml for options). - #config.active_storage.service = :local - # Assume all access to the app is happening through a SSL-terminating reverse proxy. # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. # config.assume_ssl = true # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - #config.force_ssl = true + config.force_ssl = true # Skip http-to-https redirect for the default health check endpoint. # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } @@ -47,23 +45,17 @@ # .tap { |logger| logger.formatter = ::Logger::Formatter.new } # .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - config.log_level = 'info' # added manually for the sake of a jruby-rack spec - # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # "info" includes generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you # want to log everything, set the level to "debug". - #config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "rails72_production" - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true @@ -71,12 +63,6 @@ # Don't log any deprecations. config.active_support.report_deprecations = false - # Do not dump schema after migrations. - #config.active_record.dump_schema_after_migration = false - - # Only use :id for inspections in production. - #config.active_record.attributes_for_inspect = [ :id ] - # Enable DNS rebinding protection and other `Host` header attacks. # config.hosts = [ # "example.com", # Allow requests from example.com diff --git a/src/spec/stub/rails72/config/environments/test.rb b/src/spec/stub/rails72/config/environments/test.rb new file mode 100644 index 000000000..999db7091 --- /dev/null +++ b/src/spec/stub/rails72/config/environments/test.rb @@ -0,0 +1,51 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false + + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/src/spec/stub/rails72/config/initializers/content_security_policy.rb b/src/spec/stub/rails72/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..b3076b38f --- /dev/null +++ b/src/spec/stub/rails72/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/src/spec/stub/rails72/config/initializers/cors.rb b/src/spec/stub/rails72/config/initializers/cors.rb deleted file mode 100644 index 0c5dd99ac..000000000 --- a/src/spec/stub/rails72/config/initializers/cors.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Avoid CORS issues when API is called from the frontend app. -# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests. - -# Read more: https://github.com/cyu/rack-cors - -# Rails.application.config.middleware.insert_before 0, Rack::Cors do -# allow do -# origins "example.com" -# -# resource "*", -# headers: :any, -# methods: [:get, :post, :put, :patch, :delete, :options, :head] -# end -# end diff --git a/src/spec/stub/rails72/config/initializers/permissions_policy.rb b/src/spec/stub/rails72/config/initializers/permissions_policy.rb new file mode 100644 index 000000000..7db3b9577 --- /dev/null +++ b/src/spec/stub/rails72/config/initializers/permissions_policy.rb @@ -0,0 +1,13 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide HTTP permissions policy. For further +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" +# end diff --git a/src/spec/stub/rails72/config/routes.rb b/src/spec/stub/rails72/config/routes.rb index cc34fc10f..33c963903 100644 --- a/src/spec/stub/rails72/config/routes.rb +++ b/src/spec/stub/rails72/config/routes.rb @@ -1,11 +1,14 @@ Rails.application.routes.draw do - get "sample/index" # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check + # Render dynamic PWA files from app/views/pwa/* + get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker + get "manifest" => "rails/pwa#manifest", as: :pwa_manifest + # Defines the root path route ("/") # root "posts#index" end diff --git a/src/spec/stub/rails72/vendor/.keep b/src/spec/stub/rails72/vendor/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spec/stub/rails80/app/controllers/application_controller.rb b/src/spec/stub/rails80/app/controllers/application_controller.rb new file mode 100644 index 000000000..0d95db22b --- /dev/null +++ b/src/spec/stub/rails80/app/controllers/application_controller.rb @@ -0,0 +1,4 @@ +class ApplicationController < ActionController::Base + # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. + allow_browser versions: :modern +end diff --git a/src/spec/stub/rails80/app/helpers/application_helper.rb b/src/spec/stub/rails80/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/src/spec/stub/rails80/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/src/spec/stub/rails80/config/application.rb b/src/spec/stub/rails80/config/application.rb new file mode 100644 index 000000000..5c934c8ab --- /dev/null +++ b/src/spec/stub/rails80/config/application.rb @@ -0,0 +1,42 @@ +require_relative "boot" + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +# require "active_job/railtie" +# require "active_record/railtie" +# require "active_storage/engine" +require "action_controller/railtie" +# require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" +require "action_view/railtie" +# require "action_cable/engine" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails80 + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 8.0 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/src/spec/stub/rails80/config/boot.rb b/src/spec/stub/rails80/config/boot.rb new file mode 100644 index 000000000..282011619 --- /dev/null +++ b/src/spec/stub/rails80/config/boot.rb @@ -0,0 +1,3 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/src/spec/stub/rails80/config/credentials.yml.enc b/src/spec/stub/rails80/config/credentials.yml.enc new file mode 100644 index 000000000..52f451f19 --- /dev/null +++ b/src/spec/stub/rails80/config/credentials.yml.enc @@ -0,0 +1 @@ +NCPB0BoQmoDBGNi6wTV45XD6wglzlWKz9UaJ+0/a4ByWCTVIwQ0TU7sBgXAqugWW122abcrrVuicT4K3/f3N4rGXSK7ub5ThDpY0q/+9NQrc1uYTLN5W8lAVjrO1mtk1uskK47hc8gvBXKRhOrxV1IGJazzXBgY2GA3fh6FtdUKMlKrUcq9TmmbGffCUOfqf1dD5KwDVPuwuavzFDbK32P3/Dvvjgh8FnfLms2QZo+WKp7/TtRxChonWkq/+AA/tKZZMFnKc4hbNA5tJfFL2NV2613UBj+nIITwxVxfFbhArKbR65S+3x5fwOVBl19TYT8SC/ITR9zOXQh/tNOJGZfEuQhKLYyIr+bbwoo0fDqvwExRiRbhg0rPccTpP+ISfE4HwAdKKi8v3MQht5J4bK3DWIx8OxPQFLaweCKZ187RH9dMkqJeMjQiUGzpcTXzJ+rkbDdRXPdpjOgsEi0+6BOHn84Tv5QTTvKwXky0bLjF8ffrfBZmThryy--pOOE0qME1o1qDga2--P86TbVCxNjPYcMsuRouaEg== \ No newline at end of file diff --git a/src/spec/stub/rails80/config/environment.rb b/src/spec/stub/rails80/config/environment.rb new file mode 100644 index 000000000..cac531577 --- /dev/null +++ b/src/spec/stub/rails80/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/src/spec/stub/rails80/config/environments/development.rb b/src/spec/stub/rails80/config/environments/development.rb new file mode 100644 index 000000000..f68dd3575 --- /dev/null +++ b/src/spec/stub/rails80/config/environments/development.rb @@ -0,0 +1,42 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Make code changes take effect immediately without server restart. + config.enable_reloading = true + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing. + config.server_timing = true + + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } + else + config.action_controller.perform_caching = false + end + + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/src/spec/stub/rails80/config/environments/production.rb b/src/spec/stub/rails80/config/environments/production.rb new file mode 100644 index 000000000..4f2cfb8f8 --- /dev/null +++ b/src/spec/stub/rails80/config/environments/production.rb @@ -0,0 +1,61 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.enable_reloading = false + + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). + config.eager_load = true + + # Full error reports are disabled. + config.consider_all_requests_local = false + + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true + + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + config.force_ssl = true + + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + + # Log to STDOUT with the current request id as a default log tag. + config.log_tags = [ :request_id ] + # config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) + + # Change to "debug" to log everything (including potentially personally-identifiable information!) + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = "/up" + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Replace the default in-process memory cache store with a durable alternative. + # config.cache_store = :mem_cache_store + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } +end diff --git a/src/spec/stub/rails80/config/environments/test.rb b/src/spec/stub/rails80/config/environments/test.rb new file mode 100644 index 000000000..14bc29e06 --- /dev/null +++ b/src/spec/stub/rails80/config/environments/test.rb @@ -0,0 +1,42 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false + + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with cache-control for performance. + config.public_file_server.headers = { "cache-control" => "public, max-age=3600" } + + # Show full error reports. + config.consider_all_requests_local = true + config.cache_store = :null_store + + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/src/spec/stub/rails80/config/initializers/content_security_policy.rb b/src/spec/stub/rails80/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..b3076b38f --- /dev/null +++ b/src/spec/stub/rails80/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/src/spec/stub/rails80/config/initializers/filter_parameter_logging.rb b/src/spec/stub/rails80/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..c0b717f7e --- /dev/null +++ b/src/spec/stub/rails80/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be partially matched (e.g. passw matches password) and 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 += [ + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc +] diff --git a/src/spec/stub/rails80/config/initializers/inflections.rb b/src/spec/stub/rails80/config/initializers/inflections.rb new file mode 100644 index 000000000..3860f659e --- /dev/null +++ b/src/spec/stub/rails80/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/src/spec/stub/rails80/config/locales/en.yml b/src/spec/stub/rails80/config/locales/en.yml new file mode 100644 index 000000000..6c349ae5e --- /dev/null +++ b/src/spec/stub/rails80/config/locales/en.yml @@ -0,0 +1,31 @@ +# Files in the config/locales directory are used for internationalization and +# are automatically loaded by Rails. If you want to use locales other than +# English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t "hello" +# +# In views, this is aliased to just `t`: +# +# <%= t("hello") %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. +# +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: +# +# en: +# "yes": yup +# enabled: "ON" + +en: + hello: "Hello world" diff --git a/src/spec/stub/rails80/config/master.key b/src/spec/stub/rails80/config/master.key new file mode 100644 index 000000000..6f3181b8a --- /dev/null +++ b/src/spec/stub/rails80/config/master.key @@ -0,0 +1 @@ +84d2b16f6454c9ac885725a8974f9bfc \ No newline at end of file diff --git a/src/spec/stub/rails80/config/puma.rb b/src/spec/stub/rails80/config/puma.rb new file mode 100644 index 000000000..787e4ce98 --- /dev/null +++ b/src/spec/stub/rails80/config/puma.rb @@ -0,0 +1,38 @@ +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. +# +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch("PORT", 3000) + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/src/spec/stub/rails80/config/routes.rb b/src/spec/stub/rails80/config/routes.rb new file mode 100644 index 000000000..48254e88e --- /dev/null +++ b/src/spec/stub/rails80/config/routes.rb @@ -0,0 +1,14 @@ +Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + # Can be used by load balancers and uptime monitors to verify that the app is live. + get "up" => "rails/health#show", as: :rails_health_check + + # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) + # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest + # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker + + # Defines the root path route ("/") + # root "posts#index" +end diff --git a/src/spec/stub/rails80/public/robots.txt b/src/spec/stub/rails80/public/robots.txt new file mode 100644 index 000000000..c19f78ab6 --- /dev/null +++ b/src/spec/stub/rails80/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file