From 9756f9f3075f79739c33e099e32ba454758ab7e1 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:07:35 -0400 Subject: [PATCH 01/12] $ bundle update rails sqlite3 --- Gemfile | 4 +- Gemfile.lock | 182 +++++++++++++++++++++++++-------------------------- 2 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Gemfile b/Gemfile index b1d4e929..c34d0d2d 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec gem "puma" -gem "sqlite3", "< 2" +gem "sqlite3" gem "debug", ">= 1.7.0" gem "mocha" gem "rubocop-shopify", "~> 2.15", require: false @@ -17,7 +17,7 @@ gem "rubocop-sorbet", "~> 0.8", require: false gem "sorbet-static-and-runtime", platforms: :ruby gem "tapioca", "~> 0.13", require: false, platforms: :ruby gem "psych", "~> 5.1", require: false -gem "rails" +gem "rails", "8.0.0.beta1" gem "webmock" platforms :mingw, :x64_mingw, :mswin, :jruby do diff --git a/Gemfile.lock b/Gemfile.lock index f8d67382..18836b95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,87 +7,85 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3.3) - actionpack (= 7.1.3.3) - activesupport (= 7.1.3.3) + actioncable (8.0.0.beta1) + actionpack (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.3) - actionpack (= 7.1.3.3) - activejob (= 7.1.3.3) - activerecord (= 7.1.3.3) - activestorage (= 7.1.3.3) - activesupport (= 7.1.3.3) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.3) - actionpack (= 7.1.3.3) - actionview (= 7.1.3.3) - activejob (= 7.1.3.3) - activesupport (= 7.1.3.3) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (8.0.0.beta1) + actionpack (= 8.0.0.beta1) + activejob (= 8.0.0.beta1) + activerecord (= 8.0.0.beta1) + activestorage (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) + mail (>= 2.8.0) + actionmailer (8.0.0.beta1) + actionpack (= 8.0.0.beta1) + actionview (= 8.0.0.beta1) + activejob (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3.3) - actionview (= 7.1.3.3) - activesupport (= 7.1.3.3) + actionpack (8.0.0.beta1) + actionview (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) nokogiri (>= 1.8.5) - racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.3) - actionpack (= 7.1.3.3) - activerecord (= 7.1.3.3) - activestorage (= 7.1.3.3) - activesupport (= 7.1.3.3) + useragent (~> 0.16) + actiontext (8.0.0.beta1) + actionpack (= 8.0.0.beta1) + activerecord (= 8.0.0.beta1) + activestorage (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.3) - activesupport (= 7.1.3.3) + actionview (8.0.0.beta1) + activesupport (= 8.0.0.beta1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.3) - activesupport (= 7.1.3.3) + activejob (8.0.0.beta1) + activesupport (= 8.0.0.beta1) globalid (>= 0.3.6) - activemodel (7.1.3.3) - activesupport (= 7.1.3.3) - activerecord (7.1.3.3) - activemodel (= 7.1.3.3) - activesupport (= 7.1.3.3) + activemodel (8.0.0.beta1) + activesupport (= 8.0.0.beta1) + activerecord (8.0.0.beta1) + activemodel (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) timeout (>= 0.4.0) - activestorage (7.1.3.3) - actionpack (= 7.1.3.3) - activejob (= 7.1.3.3) - activerecord (= 7.1.3.3) - activesupport (= 7.1.3.3) + activestorage (8.0.0.beta1) + actionpack (= 8.0.0.beta1) + activejob (= 8.0.0.beta1) + activerecord (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) marcel (~> 1.0) - activesupport (7.1.3.3) + activesupport (8.0.0.beta1) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) base64 (0.2.0) + benchmark (0.3.0) bigdecimal (3.1.8) - builder (3.2.4) - concurrent-ruby (1.2.3) + builder (3.3.0) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crack (1.0.0) bigdecimal @@ -98,14 +96,14 @@ GEM irb (~> 1.10) reline (>= 0.3.8) drb (2.2.1) - erubi (1.12.0) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) hashdiff (1.1.0) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) io-console (0.7.2) - irb (1.13.1) + irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) json (2.7.2) @@ -121,11 +119,10 @@ GEM net-smtp marcel (1.0.4) mini_mime (1.1.5) - minitest (5.23.0) + minitest (5.25.1) mocha (2.3.0) ruby2_keywords (>= 0.0.5) - mutex_m (0.2.0) - net-imap (0.4.11) + net-imap (0.4.16) date net-protocol net-pop (0.1.2) @@ -136,13 +133,13 @@ GEM net-protocol netrc (0.11.0) nio4r (2.7.3) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x64-mingw-ucrt) + nokogiri (1.16.7-x64-mingw-ucrt) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) parallel (1.24.0) parser (3.3.1.0) @@ -154,8 +151,8 @@ GEM public_suffix (5.0.5) puma (6.4.3) nio4r (~> 2.0) - racc (1.7.3) - rack (3.0.11) + racc (1.8.1) + rack (3.1.7) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -163,20 +160,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.3.3) - actioncable (= 7.1.3.3) - actionmailbox (= 7.1.3.3) - actionmailer (= 7.1.3.3) - actionpack (= 7.1.3.3) - actiontext (= 7.1.3.3) - actionview (= 7.1.3.3) - activejob (= 7.1.3.3) - activemodel (= 7.1.3.3) - activerecord (= 7.1.3.3) - activestorage (= 7.1.3.3) - activesupport (= 7.1.3.3) + rails (8.0.0.beta1) + actioncable (= 8.0.0.beta1) + actionmailbox (= 8.0.0.beta1) + actionmailer (= 8.0.0.beta1) + actionpack (= 8.0.0.beta1) + actiontext (= 8.0.0.beta1) + actionview (= 8.0.0.beta1) + activejob (= 8.0.0.beta1) + activemodel (= 8.0.0.beta1) + activerecord (= 8.0.0.beta1) + activestorage (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) bundler (>= 1.15.0) - railties (= 7.1.3.3) + railties (= 8.0.0.beta1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -184,10 +181,10 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.3) - actionpack (= 7.1.3.3) - activesupport (= 7.1.3.3) - irb + railties (8.0.0.beta1) + actionpack (= 8.0.0.beta1) + activesupport (= 8.0.0.beta1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -199,10 +196,10 @@ GEM sorbet-runtime (>= 0.5.9204) rbs (3.6.1) logger - rdoc (6.6.3.1) + rdoc (6.7.0) psych (>= 4.0.0) regexp_parser (2.9.0) - reline (0.5.7) + reline (0.5.10) io-console (~> 0.5) rexml (3.3.8) rubocop (1.63.4) @@ -234,6 +231,7 @@ GEM sorbet-runtime (>= 0.5.10782) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) + securerandom (0.3.1) sorbet (0.5.11577) sorbet-static (= 0.5.11577) sorbet-runtime (0.5.11577) @@ -247,11 +245,11 @@ GEM prism (>= 0.19.0) sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) - sqlite3 (1.7.3-arm64-darwin) - sqlite3 (1.7.3-x64-mingw-ucrt) - sqlite3 (1.7.3-x86_64-darwin) - sqlite3 (1.7.3-x86_64-linux) - stringio (3.1.0) + sqlite3 (2.1.0-arm64-darwin) + sqlite3 (2.1.0-x64-mingw-ucrt) + sqlite3 (2.1.0-x86_64-darwin) + sqlite3 (2.1.0-x86_64-linux-gnu) + stringio (3.1.1) tapioca (0.16.2) bundler (>= 2.2.25) netrc (>= 0.11.0) @@ -261,13 +259,15 @@ GEM spoom (>= 1.2.0) thor (>= 1.2.0) yard-sorbet - thor (1.3.1) + thor (1.3.2) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) tzinfo-data (1.2024.1) tzinfo (>= 1.0.0) unicode-display_width (2.5.0) + uri (0.13.1) + useragent (0.16.10) webmock (3.23.1) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -280,7 +280,7 @@ GEM yard-sorbet (0.8.1) sorbet-runtime (>= 0.5) yard (>= 0.9) - zeitwerk (2.6.14) + zeitwerk (2.6.18) PLATFORMS arm64-darwin @@ -293,14 +293,14 @@ DEPENDENCIES mocha psych (~> 5.1) puma - rails + rails (= 8.0.0.beta1) rubocop-minitest (~> 0.35.0) rubocop-rake (~> 0.6.0) rubocop-shopify (~> 2.15) rubocop-sorbet (~> 0.8) ruby-lsp-rails! sorbet-static-and-runtime - sqlite3 (< 2) + sqlite3 tapioca (~> 0.13) tzinfo tzinfo-data From 284dc56e153e4bf4ff5bde521a8a02a68acac88e Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:32:09 -0400 Subject: [PATCH 02/12] Ignore RuboCop for dummy app --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4e5efdd6..e910070a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,7 +10,7 @@ AllCops: NewCops: disable SuggestExtensions: false Exclude: - - "test/dummy/db/**/*.rb" + - "test/dummy/**/*" Naming/FileName: Exclude: From 47369d216bc5b79c4db7020fa2d8bea4421d204a Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:31:21 -0400 Subject: [PATCH 03/12] Re-generate dummy app using Rails 8.0.0.beta1 --- test/dummy/Rakefile | 2 - .../app/controllers/application_controller.rb | 5 +- test/dummy/app/helpers/application_helper.rb | 2 - test/dummy/app/jobs/application_job.rb | 7 + test/dummy/app/mailers/application_mailer.rb | 4 + test/dummy/app/models/application_record.rb | 2 - .../app/views/layouts/application.html.erb | 14 +- test/dummy/app/views/layouts/mailer.html.erb | 2 +- test/dummy/app/views/pwa/manifest.json.erb | 22 +++ test/dummy/app/views/pwa/service-worker.js | 26 +++ test/dummy/bin/dev | 2 + test/dummy/bin/rails | 2 - test/dummy/bin/rake | 2 - test/dummy/bin/setup | 16 +- test/dummy/config.ru | 3 - test/dummy/config/application.rb | 26 +-- test/dummy/config/boot.rb | 6 +- test/dummy/config/database.yml | 13 +- test/dummy/config/environment.rb | 2 - test/dummy/config/environments/development.rb | 52 ++--- test/dummy/config/environments/production.rb | 104 +++++----- test/dummy/config/environments/test.rb | 53 +++--- .../config/initializers/action_dispatch.rb | 5 - .../initializers/content_security_policy.rb | 6 +- .../initializers/filter_parameter_logging.rb | 10 +- test/dummy/config/initializers/inflections.rb | 2 - .../config/initializers/permissions_policy.rb | 13 -- test/dummy/config/locales/en.yml | 24 ++- test/dummy/config/puma.rb | 68 +++---- test/dummy/config/routes.rb | 14 +- test/dummy/db/schema.rb | 2 +- test/dummy/lib/assets/.keep | 0 test/dummy/public/400.html | 114 +++++++++++ test/dummy/public/404.html | 179 +++++++++++------- .../dummy/public/406-unsupported-browser.html | 114 +++++++++++ test/dummy/public/422.html | 179 +++++++++++------- test/dummy/public/500.html | 178 ++++++++++------- .../public/apple-touch-icon-precomposed.png | 0 test/dummy/public/apple-touch-icon.png | 0 test/dummy/public/favicon.ico | 0 test/dummy/public/icon.png | Bin 0 -> 4166 bytes test/dummy/public/icon.svg | 3 + 42 files changed, 837 insertions(+), 441 deletions(-) create mode 100644 test/dummy/app/jobs/application_job.rb create mode 100644 test/dummy/app/mailers/application_mailer.rb create mode 100644 test/dummy/app/views/pwa/manifest.json.erb create mode 100644 test/dummy/app/views/pwa/service-worker.js create mode 100755 test/dummy/bin/dev delete mode 100644 test/dummy/config/initializers/action_dispatch.rb delete mode 100644 test/dummy/config/initializers/permissions_policy.rb delete mode 100644 test/dummy/lib/assets/.keep create mode 100644 test/dummy/public/400.html create mode 100644 test/dummy/public/406-unsupported-browser.html delete mode 100644 test/dummy/public/apple-touch-icon-precomposed.png delete mode 100644 test/dummy/public/apple-touch-icon.png delete mode 100644 test/dummy/public/favicon.ico create mode 100644 test/dummy/public/icon.png create mode 100644 test/dummy/public/icon.svg diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile index d2a78aa2..9a5ea738 100644 --- a/test/dummy/Rakefile +++ b/test/dummy/Rakefile @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 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. diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index 4cb2998a..ac4c0af9 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationController < ActionController::Base def create user_path(1) @@ -8,4 +6,7 @@ def create archive_users_path invalid_path end + + # 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/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb index 15b06f0f..de6be794 100644 --- a/test/dummy/app/helpers/application_helper.rb +++ b/test/dummy/app/helpers/application_helper.rb @@ -1,4 +1,2 @@ -# frozen_string_literal: true - module ApplicationHelper end diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb new file mode 100644 index 00000000..d394c3d1 --- /dev/null +++ b/test/dummy/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb new file mode 100644 index 00000000..3c34c814 --- /dev/null +++ b/test/dummy/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout "mailer" +end diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb index 08dc5379..b63caeb8 100644 --- a/test/dummy/app/models/application_record.rb +++ b/test/dummy/app/models/application_record.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class ApplicationRecord < ActiveRecord::Base primary_abstract_class end diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index f72b4ef0..53c7e34d 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -1,11 +1,23 @@ - Dummy + <%= content_for(:title) || "Dummy" %> + + <%= csrf_meta_tags %> <%= csp_meta_tag %> + <%= yield :head %> + + <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> + <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> + + + + + + <%# Includes all stylesheet files in app/views/stylesheets %> <%= stylesheet_link_tag "application" %> diff --git a/test/dummy/app/views/layouts/mailer.html.erb b/test/dummy/app/views/layouts/mailer.html.erb index cbd34d2e..3aac9002 100644 --- a/test/dummy/app/views/layouts/mailer.html.erb +++ b/test/dummy/app/views/layouts/mailer.html.erb @@ -1,7 +1,7 @@ - + diff --git a/test/dummy/app/views/pwa/manifest.json.erb b/test/dummy/app/views/pwa/manifest.json.erb new file mode 100644 index 00000000..a3c046e4 --- /dev/null +++ b/test/dummy/app/views/pwa/manifest.json.erb @@ -0,0 +1,22 @@ +{ + "name": "Dummy", + "icons": [ + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512" + }, + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512", + "purpose": "maskable" + } + ], + "start_url": "/", + "display": "standalone", + "scope": "/", + "description": "Dummy.", + "theme_color": "red", + "background_color": "red" +} diff --git a/test/dummy/app/views/pwa/service-worker.js b/test/dummy/app/views/pwa/service-worker.js new file mode 100644 index 00000000..b3a13fb7 --- /dev/null +++ b/test/dummy/app/views/pwa/service-worker.js @@ -0,0 +1,26 @@ +// Add a service worker for processing Web Push notifications: +// +// self.addEventListener("push", async (event) => { +// const { title, options } = await event.data.json() +// event.waitUntil(self.registration.showNotification(title, options)) +// }) +// +// self.addEventListener("notificationclick", function(event) { +// event.notification.close() +// event.waitUntil( +// clients.matchAll({ type: "window" }).then((clientList) => { +// for (let i = 0; i < clientList.length; i++) { +// let client = clientList[i] +// let clientPath = (new URL(client.url)).pathname +// +// if (clientPath == event.notification.data.path && "focus" in client) { +// return client.focus() +// } +// } +// +// if (clients.openWindow) { +// return clients.openWindow(event.notification.data.path) +// } +// }) +// ) +// }) diff --git a/test/dummy/bin/dev b/test/dummy/bin/dev new file mode 100755 index 00000000..5f91c205 --- /dev/null +++ b/test/dummy/bin/dev @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +exec "./bin/rails", "server", *ARGV diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index 22f2d8de..efc03774 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake index e436ea54..4fbf10b9 100755 --- a/test/dummy/bin/rake +++ b/test/dummy/bin/rake @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - require_relative "../config/boot" require "rake" Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup index a131de0c..be8ac5b5 100755 --- a/test/dummy/bin/setup +++ b/test/dummy/bin/setup @@ -1,22 +1,19 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - require "fileutils" -# path to your application root. APP_ROOT = File.expand_path("..", __dir__) +APP_NAME = "dummy" def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end -FileUtils.chdir(APP_ROOT) do +FileUtils.chdir APP_ROOT do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. puts "== Installing dependencies ==" - system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" @@ -30,6 +27,9 @@ FileUtils.chdir(APP_ROOT) do puts "\n== Removing old logs and tempfiles ==" system! "bin/rails log:clear tmp:clear" - puts "\n== Restarting application server ==" - system! "bin/rails restart" + unless ARGV.include?("--skip-server") + puts "\n== Starting development server ==" + STDOUT.flush # flush the output before exec(2) so that it displays + exec "bin/dev" + end end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index a9930218..4a3c09a6 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -1,6 +1,3 @@ -# typed: strict -# frozen_string_literal: true - # This file is used by Rack-based servers to start the application. require_relative "config/environment" diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index a50dff65..636d329c 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,30 +1,19 @@ -# frozen_string_literal: true - require_relative "boot" -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 "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -require "ruby-lsp-rails" module Dummy class Application < Rails::Application - config.load_defaults(Rails::VERSION::STRING.to_f) + config.load_defaults Rails::VERSION::STRING.to_f - # For compatibility with applications that use this config - config.action_controller.include_all_helpers = false + # 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. # @@ -33,8 +22,5 @@ class Application < Rails::Application # # 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/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index ee3010b6..116591a4 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,9 +1,5 @@ -# frozen_string_literal: true - # Set up gems listed in the Gemfile. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -$LOAD_PATH.unshift(File.expand_path("../../../lib", __dir__)) - -require "sorbet-runtime" +$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index fcba57f1..01bebb50 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -11,15 +11,22 @@ default: &default development: <<: *default - database: db/development.sqlite3 + database: storage/development.sqlite3 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: storage/test.sqlite3 + +# SQLite3 write its data on the local filesystem, as such it requires +# persistent disks. If you are deploying to a managed service, you should +# make sure it provides disk persistence, as many don't. +# +# Similarly, if you deploy your application as a Docker container, you must +# ensure the database is located in a persisted volume. production: <<: *default - database: db/production.sqlite3 + # database: path/to/persistent/storage/production.sqlite3 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb index 7df99e89..cac53157 100644 --- a/test/dummy/config/environment.rb +++ b/test/dummy/config/environment.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Load the Rails application. require_relative "application" diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 84c12bb4..263e0c41 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,14 +1,10 @@ -# frozen_string_literal: true - 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 + # Make code changes take effect immediately without server restart. + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -16,54 +12,58 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. + # 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.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}", - } + 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 + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + # Store uploaded files on the local file system (see config/storage.yml for options). - # config.active_storage.service = :local + config.active_storage.service = :local # Don't care if the mailer can't send. - # config.action_mailer.raise_delivery_errors = false + config.action_mailer.raise_delivery_errors = false + + # Make template changes take effect immediately. + config.action_mailer.perform_caching = false - # config.action_mailer.perform_caching = false + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "localhost", port: 3000 } # 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 = [] - # 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 + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = 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 # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + 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 + + # 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/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index 48580073..17496077 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,89 +1,89 @@ -# frozen_string_literal: true - 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 + 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. + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). 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 + # Full error reports are disabled. + config.consider_all_requests_local = false - # 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 + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = 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? + # 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" - # 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 - # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + # 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 + 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 + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - # Prepend all log lines with the following tags. - config.log_tags = [:request_id] + # Log to STDOUT with the current request id as a default log tag. + config.log_tags = [ :request_id ] + config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) - # Use a different cache store in production. - # config.cache_store = :mem_cache_store + # Change to "debug" to log everything (including potentially personally-identifiable information!) + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - # 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 = "dummy_production" + # 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 - config.action_mailer.perform_caching = false + # Replace the default in-process and non-durable queuing backend for Active Job. + # config.active_job.queue_adapter = :resque # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + + # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. + # config.action_mailer.smtp_settings = { + # user_name: Rails.application.credentials.dig(:smtp, :user_name), + # password: Rails.application.credentials.dig(:smtp, :password), + # address: "smtp.example.com", + # port: 587, + # authentication: :plain + # } + # 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 - # 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 + # /.*\.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/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 15226965..c2095b11 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,7 +1,3 @@ -# frozen_string_literal: true - -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 @@ -10,43 +6,48 @@ 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 + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # 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 = true + # 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}", - } + # 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 and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true config.cache_store = :null_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # 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 + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + + # 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/test/dummy/config/initializers/action_dispatch.rb b/test/dummy/config/initializers/action_dispatch.rb deleted file mode 100644 index d47a77e7..00000000 --- a/test/dummy/config/initializers/action_dispatch.rb +++ /dev/null @@ -1,5 +0,0 @@ -# typed: true -# frozen_string_literal: true - -# Route source locations are normally only available in development, so we need to enable this in test mode. -ActionDispatch::Routing::Mapper.route_source_locations = true diff --git a/test/dummy/config/initializers/content_security_policy.rb b/test/dummy/config/initializers/content_security_policy.rb index 53538c14..b3076b38 100644 --- a/test/dummy/config/initializers/content_security_policy.rb +++ b/test/dummy/config/initializers/content_security_policy.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Define an application-wide content security policy. @@ -18,9 +16,9 @@ # # policy.report_uri "/csp-violation-report-endpoint" # end # -# # Generate session nonces for permitted importmap and inline scripts +# # 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) +# config.content_security_policy_nonce_directives = %w(script-src style-src) # # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index 615869a8..c0b717f7 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -1,10 +1,8 @@ -# frozen_string_literal: true - # 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. +# 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, + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc ] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb index 9e049dcc..3860f659 100644 --- a/test/dummy/config/initializers/inflections.rb +++ b/test/dummy/config/initializers/inflections.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/test/dummy/config/initializers/permissions_policy.rb b/test/dummy/config/initializers/permissions_policy.rb deleted file mode 100644 index 810aadeb..00000000 --- a/test/dummy/config/initializers/permissions_policy.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# 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/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml index 8ca56fc7..6c349ae5 100644 --- a/test/dummy/config/locales/en.yml +++ b/test/dummy/config/locales/en.yml @@ -1,6 +1,6 @@ -# 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. +# 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`: # @@ -16,18 +16,16 @@ # # 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: +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. # -# true, false, on, off, yes, no +# 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: # -# 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: +# "yes": yup +# enabled: "ON" en: hello: "Hello world" diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb index 1b1501de..787e4ce9 100644 --- a/test/dummy/config/puma.rb +++ b/test/dummy/config/puma.rb @@ -1,48 +1,38 @@ -# frozen_string_literal: true - -# 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. +# 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. # - -T.bind(self, Puma::DSL) - -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. +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. # -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# 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. # -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. +# 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. # -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). +# 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. # -# 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. +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. # -# preload_app! +# 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/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 268b29a0..4795a558 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,7 +1,17 @@ -# frozen_string_literal: true - Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html resources :users do get :archive, on: :collection end + + # 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/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index d15d6c1f..9d61df68 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_10_25_225348) do +ActiveRecord::Schema[8.0].define(version: 2024_05_21_183200) do create_table "composite_primary_keys", primary_key: ["order_id", "product_id"], force: :cascade do |t| t.integer "order_id" t.integer "product_id" diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/dummy/public/400.html b/test/dummy/public/400.html new file mode 100644 index 00000000..282dbc8c --- /dev/null +++ b/test/dummy/public/400.html @@ -0,0 +1,114 @@ + + + + + + + The server cannot process the request due to a client error (400 Bad Request) + + + + + + + + + + + + + +
+
+ +
+
+

The server cannot process the request due to a client error. Please check the request and try again. If you’re the application owner check the logs for more information.

+
+
+ + + + diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html index 2be3af26..c0670bc8 100644 --- a/test/dummy/public/404.html +++ b/test/dummy/public/404.html @@ -1,67 +1,114 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- + + + + + + + The page you were looking for doesn’t exist (404 Not found) + + + + + + + + + + + + + +
+
+ +
+
+

The page you were looking for doesn’t exist. You may have mistyped the address or the page may have moved. If you’re the application owner check the logs for more information.

+
+
+ + + diff --git a/test/dummy/public/406-unsupported-browser.html b/test/dummy/public/406-unsupported-browser.html new file mode 100644 index 00000000..9532a9cc --- /dev/null +++ b/test/dummy/public/406-unsupported-browser.html @@ -0,0 +1,114 @@ + + + + + + + Your browser is not supported (406 Not Acceptable) + + + + + + + + + + + + + +
+
+ +
+
+

Your browser is not supported.
Please upgrade your browser to continue.

+
+
+ + + + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html index c08eac0d..8bcf0601 100644 --- a/test/dummy/public/422.html +++ b/test/dummy/public/422.html @@ -1,67 +1,114 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- + + + + + + + The change you wanted was rejected (422 Unprocessable Entity) + + + + + + + + + + + + + +
+
+ +
+
+

The change you wanted was rejected. Maybe you tried to change something you didn’t have access to. If you’re the application owner check the logs for more information.

+
+
+ + + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html index 78a030af..d77718c3 100644 --- a/test/dummy/public/500.html +++ b/test/dummy/public/500.html @@ -1,66 +1,114 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- + + + + + + + We’re sorry, but something went wrong (500 Internal Server Error) + + + + + + + + + + + + + +
+
+ +
+
+

We’re sorry, but something went wrong.
If you’re the application owner check the logs for more information.

+
+
+ + + diff --git a/test/dummy/public/apple-touch-icon-precomposed.png b/test/dummy/public/apple-touch-icon-precomposed.png deleted file mode 100644 index e69de29b..00000000 diff --git a/test/dummy/public/apple-touch-icon.png b/test/dummy/public/apple-touch-icon.png deleted file mode 100644 index e69de29b..00000000 diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/test/dummy/public/icon.png b/test/dummy/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c4c9dbfbbd2f7c1421ffd5727188146213abbcef GIT binary patch literal 4166 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 literal 0 HcmV?d00001 diff --git a/test/dummy/public/icon.svg b/test/dummy/public/icon.svg new file mode 100644 index 00000000..04b34bf8 --- /dev/null +++ b/test/dummy/public/icon.svg @@ -0,0 +1,3 @@ + + + From ad5f781193c0373f0ceb0347893301d29bf851e3 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:03:44 -0400 Subject: [PATCH 04/12] Update tests due to line number change --- test/ruby_lsp_rails/code_lens_test.rb | 2 +- test/ruby_lsp_rails/definition_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ruby_lsp_rails/code_lens_test.rb b/test/ruby_lsp_rails/code_lens_test.rb index 98c7650a..09c03187 100644 --- a/test/ruby_lsp_rails/code_lens_test.rb +++ b/test/ruby_lsp_rails/code_lens_test.rb @@ -315,7 +315,7 @@ def index uri = response[0].command.arguments.first.first assert_match("GET /users(.:format)", response[0].command.title) - assert_match("config/routes.rb#L4", uri) + assert_match("config/routes.rb#L3", uri) end test "doesn't break when analyzing a file without a class" do diff --git a/test/ruby_lsp_rails/definition_test.rb b/test/ruby_lsp_rails/definition_test.rb index 7b251f48..7e9283b3 100644 --- a/test/ruby_lsp_rails/definition_test.rb +++ b/test/ruby_lsp_rails/definition_test.rb @@ -186,8 +186,8 @@ def baz; end URI::Generic.from_path(path: File.join(dummy_root, "config", "routes.rb")).to_s, response[0].uri, ) - assert_equal(3, response[0].range.start.line) - assert_equal(3, response[0].range.end.line) + assert_equal(2, response[0].range.start.line) + assert_equal(2, response[0].range.end.line) end test "handles incomplete routes" do @@ -209,8 +209,8 @@ def baz; end URI::Generic.from_path(path: File.join(dummy_root, "config", "routes.rb")).to_s, response[0].uri, ) - assert_equal(4, response[0].range.start.line) - assert_equal(4, response[0].range.end.line) + assert_equal(3, response[0].range.start.line) + assert_equal(3, response[0].range.end.line) end test "ignored non-existing routes" do From af306143967e1cda22e0fc40075955e613118ce9 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:33:10 -0400 Subject: [PATCH 05/12] Fixes for Rails 8 --- lib/ruby_lsp/ruby_lsp_rails/server.rb | 6 ++++++ test/dummy/config/application.rb | 5 +++++ test/dummy/db/schema.rb | 2 +- test/ruby_lsp_rails/server_test.rb | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/ruby_lsp/ruby_lsp_rails/server.rb b/lib/ruby_lsp/ruby_lsp_rails/server.rb index 7cad461c..cbe0cca9 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/server.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/server.rb @@ -3,6 +3,12 @@ require "json" +if ActionDispatch::Routing::Mapper.respond_to?(:route_source_locations) + ActionDispatch::Routing::Mapper.route_source_locations = true +end + +Rails.application.routes.eager_load! + # NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the # client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key. diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 636d329c..129c4671 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -8,6 +8,11 @@ module Dummy class Application < Rails::Application + # Normally this is disabled for the test environment (see `actionpack/lib/action_dispatch/railtie.rb`) + initializer "enable_route_source_locations", after: "action_dispatch.configure" do |app| + ActionDispatch::Routing::Mapper.route_source_locations = true + end + config.load_defaults Rails::VERSION::STRING.to_f # Please, add to the `ignore` list any other `lib` subdirectories that do diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 9d61df68..fa61c344 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_05_21_183200) do +ActiveRecord::Schema[8.0].define(version: 2024_10_25_225348) do create_table "composite_primary_keys", primary_key: ["order_id", "product_id"], force: :cascade do |t| t.integer "order_id" t.integer "product_id" diff --git a/test/ruby_lsp_rails/server_test.rb b/test/ruby_lsp_rails/server_test.rb index 1b3f68ce..e255a9b1 100644 --- a/test/ruby_lsp_rails/server_test.rb +++ b/test/ruby_lsp_rails/server_test.rb @@ -116,7 +116,7 @@ def <(other) test "route location returns the location for a valid route" do @server.execute("route_location", { name: "user_path" }) location = response[:result][:location] - assert_match %r{test/dummy/config/routes.rb:4$}, location + assert_match %r{test/dummy/config/routes.rb:3$}, location end test "route location returns nil for invalid routes" do @@ -130,7 +130,7 @@ def <(other) result = response[:result] source_location_path, source_location_line = result[:source_location] - assert_equal "4", source_location_line + assert_equal "3", source_location_line assert source_location_path.end_with?("config/routes.rb") assert_equal "GET", result[:verb] assert_equal "/users(.:format)", result[:path] From e6050561e86cb929a1081f41eb3f550edb7d30e9 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:50:23 -0400 Subject: [PATCH 06/12] Apply RuboCop to Dummy app --- .rubocop.yml | 2 +- test/dummy/Rakefile | 2 ++ test/dummy/app/controllers/application_controller.rb | 2 ++ test/dummy/app/helpers/application_helper.rb | 2 ++ test/dummy/app/jobs/application_job.rb | 2 ++ test/dummy/app/mailers/application_mailer.rb | 2 ++ test/dummy/app/models/application_record.rb | 2 ++ test/dummy/bin/dev | 2 ++ test/dummy/bin/rails | 2 ++ test/dummy/bin/rake | 2 ++ test/dummy/bin/setup | 4 +++- test/dummy/config.ru | 3 +++ test/dummy/config/application.rb | 8 +++++--- test/dummy/config/boot.rb | 4 +++- test/dummy/config/environment.rb | 2 ++ test/dummy/config/environments/development.rb | 2 ++ test/dummy/config/environments/production.rb | 6 ++++-- test/dummy/config/environments/test.rb | 2 ++ test/dummy/config/initializers/content_security_policy.rb | 2 ++ .../dummy/config/initializers/filter_parameter_logging.rb | 4 +++- test/dummy/config/initializers/inflections.rb | 2 ++ test/dummy/config/puma.rb | 2 ++ test/dummy/config/routes.rb | 2 ++ 23 files changed, 54 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e910070a..4e5efdd6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,7 +10,7 @@ AllCops: NewCops: disable SuggestExtensions: false Exclude: - - "test/dummy/**/*" + - "test/dummy/db/**/*.rb" Naming/FileName: Exclude: diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile index 9a5ea738..d2a78aa2 100644 --- a/test/dummy/Rakefile +++ b/test/dummy/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # 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. diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index ac4c0af9..cb249efe 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base def create user_path(1) diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb index de6be794..15b06f0f 100644 --- a/test/dummy/app/helpers/application_helper.rb +++ b/test/dummy/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module ApplicationHelper end diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb index d394c3d1..bef39599 100644 --- a/test/dummy/app/jobs/application_job.rb +++ b/test/dummy/app/jobs/application_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb index 3c34c814..5cc63a0c 100644 --- a/test/dummy/app/mailers/application_mailer.rb +++ b/test/dummy/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: "from@example.com" layout "mailer" diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb index b63caeb8..08dc5379 100644 --- a/test/dummy/app/models/application_record.rb +++ b/test/dummy/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base primary_abstract_class end diff --git a/test/dummy/bin/dev b/test/dummy/bin/dev index 5f91c205..6981d917 100755 --- a/test/dummy/bin/dev +++ b/test/dummy/bin/dev @@ -1,2 +1,4 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + exec "./bin/rails", "server", *ARGV diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index efc03774..22f2d8de 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake index 4fbf10b9..e436ea54 100755 --- a/test/dummy/bin/rake +++ b/test/dummy/bin/rake @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require_relative "../config/boot" require "rake" Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup index be8ac5b5..8802d4ce 100755 --- a/test/dummy/bin/setup +++ b/test/dummy/bin/setup @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require "fileutils" APP_ROOT = File.expand_path("..", __dir__) @@ -8,7 +10,7 @@ def system!(*args) system(*args, exception: true) end -FileUtils.chdir APP_ROOT do +FileUtils.chdir(APP_ROOT) do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 4a3c09a6..a9930218 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -1,3 +1,6 @@ +# typed: strict +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. require_relative "config/environment" diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 129c4671..9d6ccae4 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "boot" require "rails/all" @@ -9,16 +11,16 @@ module Dummy class Application < Rails::Application # Normally this is disabled for the test environment (see `actionpack/lib/action_dispatch/railtie.rb`) - initializer "enable_route_source_locations", after: "action_dispatch.configure" do |app| + initializer "enable_route_source_locations", after: "action_dispatch.configure" do |_app| ActionDispatch::Routing::Mapper.route_source_locations = true end - config.load_defaults Rails::VERSION::STRING.to_f + config.load_defaults(Rails::VERSION::STRING.to_f) # 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]) + config.autoload_lib(ignore: ["assets", "tasks"]) # Configuration for the application, engines, and railties goes here. # diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 116591a4..91063c1a 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + # Set up gems listed in the Gemfile. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) +$LOAD_PATH.unshift(File.expand_path("../../../lib", __dir__)) diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb index cac53157..7df99e89 100644 --- a/test/dummy/config/environment.rb +++ b/test/dummy/config/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Load the Rails application. require_relative "application" diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 263e0c41..4fa6c6b3 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" Rails.application.configure do diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index 17496077..6f982779 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" Rails.application.configure do @@ -34,7 +36,7 @@ # 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.log_tags = [:request_id] config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) # Change to "debug" to log everything (including potentially personally-identifiable information!) @@ -76,7 +78,7 @@ config.active_record.dump_schema_after_migration = false # Only use :id for inspections in production. - config.active_record.attributes_for_inspect = [ :id ] + config.active_record.attributes_for_inspect = [:id] # Enable DNS rebinding protection and other `Host` header attacks. # config.hosts = [ diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index c2095b11..3b04bf52 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # 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 diff --git a/test/dummy/config/initializers/content_security_policy.rb b/test/dummy/config/initializers/content_security_policy.rb index b3076b38..35ab3fd6 100644 --- a/test/dummy/config/initializers/content_security_policy.rb +++ b/test/dummy/config/initializers/content_security_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide content security policy. diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index c0b717f7..7806a407 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # 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 + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc, ] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb index 3860f659..9e049dcc 100644 --- a/test/dummy/config/initializers/inflections.rb +++ b/test/dummy/config/initializers/inflections.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb index 787e4ce9..072ed49c 100644 --- a/test/dummy/config/puma.rb +++ b/test/dummy/config/puma.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # 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. diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 4795a558..0693d974 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.routes.draw do # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html resources :users do From f298acc8abf5263b8c90ac87584dea2d21227e5c Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:57:31 -0400 Subject: [PATCH 07/12] Fix line numbers --- test/ruby_lsp_rails/code_lens_test.rb | 2 +- test/ruby_lsp_rails/definition_test.rb | 8 ++++---- test/ruby_lsp_rails/server_test.rb | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/ruby_lsp_rails/code_lens_test.rb b/test/ruby_lsp_rails/code_lens_test.rb index 09c03187..30a769d2 100644 --- a/test/ruby_lsp_rails/code_lens_test.rb +++ b/test/ruby_lsp_rails/code_lens_test.rb @@ -315,7 +315,7 @@ def index uri = response[0].command.arguments.first.first assert_match("GET /users(.:format)", response[0].command.title) - assert_match("config/routes.rb#L3", uri) + assert_match("config/routes.rb#L5", uri) end test "doesn't break when analyzing a file without a class" do diff --git a/test/ruby_lsp_rails/definition_test.rb b/test/ruby_lsp_rails/definition_test.rb index 7e9283b3..581cb10a 100644 --- a/test/ruby_lsp_rails/definition_test.rb +++ b/test/ruby_lsp_rails/definition_test.rb @@ -186,8 +186,8 @@ def baz; end URI::Generic.from_path(path: File.join(dummy_root, "config", "routes.rb")).to_s, response[0].uri, ) - assert_equal(2, response[0].range.start.line) - assert_equal(2, response[0].range.end.line) + assert_equal(4, response[0].range.start.line) + assert_equal(4, response[0].range.end.line) end test "handles incomplete routes" do @@ -209,8 +209,8 @@ def baz; end URI::Generic.from_path(path: File.join(dummy_root, "config", "routes.rb")).to_s, response[0].uri, ) - assert_equal(3, response[0].range.start.line) - assert_equal(3, response[0].range.end.line) + assert_equal(5, response[0].range.start.line) + assert_equal(5, response[0].range.end.line) end test "ignored non-existing routes" do diff --git a/test/ruby_lsp_rails/server_test.rb b/test/ruby_lsp_rails/server_test.rb index e255a9b1..4120d921 100644 --- a/test/ruby_lsp_rails/server_test.rb +++ b/test/ruby_lsp_rails/server_test.rb @@ -116,7 +116,7 @@ def <(other) test "route location returns the location for a valid route" do @server.execute("route_location", { name: "user_path" }) location = response[:result][:location] - assert_match %r{test/dummy/config/routes.rb:3$}, location + assert_match %r{test/dummy/config/routes.rb:5$}, location end test "route location returns nil for invalid routes" do @@ -130,7 +130,7 @@ def <(other) result = response[:result] source_location_path, source_location_line = result[:source_location] - assert_equal "3", source_location_line + assert_equal "5", source_location_line assert source_location_path.end_with?("config/routes.rb") assert_equal "GET", result[:verb] assert_equal "/users(.:format)", result[:path] From f5cd208393c27327080172cfa9ce889b4db38e6b Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:58:58 -0400 Subject: [PATCH 08/12] Remove test/dummy/bin --- test/dummy/bin/dev | 4 ---- test/dummy/bin/rails | 6 ------ test/dummy/bin/rake | 6 ------ test/dummy/bin/setup | 37 ------------------------------------- 4 files changed, 53 deletions(-) delete mode 100755 test/dummy/bin/dev delete mode 100755 test/dummy/bin/rails delete mode 100755 test/dummy/bin/rake delete mode 100755 test/dummy/bin/setup diff --git a/test/dummy/bin/dev b/test/dummy/bin/dev deleted file mode 100755 index 6981d917..00000000 --- a/test/dummy/bin/dev +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -exec "./bin/rails", "server", *ARGV diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails deleted file mode 100755 index 22f2d8de..00000000 --- a/test/dummy/bin/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake deleted file mode 100755 index e436ea54..00000000 --- a/test/dummy/bin/rake +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require_relative "../config/boot" -require "rake" -Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup deleted file mode 100755 index 8802d4ce..00000000 --- a/test/dummy/bin/setup +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require "fileutils" - -APP_ROOT = File.expand_path("..", __dir__) -APP_NAME = "dummy" - -def system!(*args) - system(*args, exception: true) -end - -FileUtils.chdir(APP_ROOT) do - # This script is a way to set up or update your development environment automatically. - # This script is idempotent, so that you can run it at any time and get an expectable outcome. - # Add necessary setup steps to this file. - - puts "== Installing dependencies ==" - system("bundle check") || system!("bundle install") - - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" - # end - - puts "\n== Preparing database ==" - system! "bin/rails db:prepare" - - puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" - - unless ARGV.include?("--skip-server") - puts "\n== Starting development server ==" - STDOUT.flush # flush the output before exec(2) so that it displays - exec "bin/dev" - end -end From 8be1ebef04e45ab230b67b0fafaf83c03086f2e6 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:02:52 -0400 Subject: [PATCH 09/12] Remove test/dummy/public --- test/dummy/public/400.html | 114 ------------------ test/dummy/public/404.html | 114 ------------------ .../dummy/public/406-unsupported-browser.html | 114 ------------------ test/dummy/public/422.html | 114 ------------------ test/dummy/public/500.html | 114 ------------------ test/dummy/public/icon.png | Bin 4166 -> 0 bytes test/dummy/public/icon.svg | 3 - 7 files changed, 573 deletions(-) delete mode 100644 test/dummy/public/400.html delete mode 100644 test/dummy/public/404.html delete mode 100644 test/dummy/public/406-unsupported-browser.html delete mode 100644 test/dummy/public/422.html delete mode 100644 test/dummy/public/500.html delete mode 100644 test/dummy/public/icon.png delete mode 100644 test/dummy/public/icon.svg diff --git a/test/dummy/public/400.html b/test/dummy/public/400.html deleted file mode 100644 index 282dbc8c..00000000 --- a/test/dummy/public/400.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - The server cannot process the request due to a client error (400 Bad Request) - - - - - - - - - - - - - -
-
- -
-
-

The server cannot process the request due to a client error. Please check the request and try again. If you’re the application owner check the logs for more information.

-
-
- - - - diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html deleted file mode 100644 index c0670bc8..00000000 --- a/test/dummy/public/404.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - The page you were looking for doesn’t exist (404 Not found) - - - - - - - - - - - - - -
-
- -
-
-

The page you were looking for doesn’t exist. You may have mistyped the address or the page may have moved. If you’re the application owner check the logs for more information.

-
-
- - - - diff --git a/test/dummy/public/406-unsupported-browser.html b/test/dummy/public/406-unsupported-browser.html deleted file mode 100644 index 9532a9cc..00000000 --- a/test/dummy/public/406-unsupported-browser.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - Your browser is not supported (406 Not Acceptable) - - - - - - - - - - - - - -
-
- -
-
-

Your browser is not supported.
Please upgrade your browser to continue.

-
-
- - - - diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html deleted file mode 100644 index 8bcf0601..00000000 --- a/test/dummy/public/422.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - The change you wanted was rejected (422 Unprocessable Entity) - - - - - - - - - - - - - -
-
- -
-
-

The change you wanted was rejected. Maybe you tried to change something you didn’t have access to. If you’re the application owner check the logs for more information.

-
-
- - - - diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html deleted file mode 100644 index d77718c3..00000000 --- a/test/dummy/public/500.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - We’re sorry, but something went wrong (500 Internal Server Error) - - - - - - - - - - - - - -
-
- -
-
-

We’re sorry, but something went wrong.
If you’re the application owner check the logs for more information.

-
-
- - - - diff --git a/test/dummy/public/icon.png b/test/dummy/public/icon.png deleted file mode 100644 index c4c9dbfbbd2f7c1421ffd5727188146213abbcef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4166 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 diff --git a/test/dummy/public/icon.svg b/test/dummy/public/icon.svg deleted file mode 100644 index 04b34bf8..00000000 --- a/test/dummy/public/icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - From ef91dfbc5d9244b0f15a282f75b796954337f649 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:07:52 -0400 Subject: [PATCH 10/12] Remove test/dummy/app/views/pwa --- test/dummy/app/views/pwa/manifest.json.erb | 22 ------------------ test/dummy/app/views/pwa/service-worker.js | 26 ---------------------- 2 files changed, 48 deletions(-) delete mode 100644 test/dummy/app/views/pwa/manifest.json.erb delete mode 100644 test/dummy/app/views/pwa/service-worker.js diff --git a/test/dummy/app/views/pwa/manifest.json.erb b/test/dummy/app/views/pwa/manifest.json.erb deleted file mode 100644 index a3c046e4..00000000 --- a/test/dummy/app/views/pwa/manifest.json.erb +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Dummy", - "icons": [ - { - "src": "/icon.png", - "type": "image/png", - "sizes": "512x512" - }, - { - "src": "/icon.png", - "type": "image/png", - "sizes": "512x512", - "purpose": "maskable" - } - ], - "start_url": "/", - "display": "standalone", - "scope": "/", - "description": "Dummy.", - "theme_color": "red", - "background_color": "red" -} diff --git a/test/dummy/app/views/pwa/service-worker.js b/test/dummy/app/views/pwa/service-worker.js deleted file mode 100644 index b3a13fb7..00000000 --- a/test/dummy/app/views/pwa/service-worker.js +++ /dev/null @@ -1,26 +0,0 @@ -// Add a service worker for processing Web Push notifications: -// -// self.addEventListener("push", async (event) => { -// const { title, options } = await event.data.json() -// event.waitUntil(self.registration.showNotification(title, options)) -// }) -// -// self.addEventListener("notificationclick", function(event) { -// event.notification.close() -// event.waitUntil( -// clients.matchAll({ type: "window" }).then((clientList) => { -// for (let i = 0; i < clientList.length; i++) { -// let client = clientList[i] -// let clientPath = (new URL(client.url)).pathname -// -// if (clientPath == event.notification.data.path && "focus" in client) { -// return client.focus() -// } -// } -// -// if (clients.openWindow) { -// return clients.openWindow(event.notification.data.path) -// } -// }) -// ) -// }) From 1ff2925823c18623980320c215d9d0a4997d5b34 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:16:28 -0400 Subject: [PATCH 11/12] Restore initializer, remove server.rb changes --- lib/ruby_lsp/ruby_lsp_rails/server.rb | 6 ------ test/dummy/config/initializers/action_dispatch.rb | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 test/dummy/config/initializers/action_dispatch.rb diff --git a/lib/ruby_lsp/ruby_lsp_rails/server.rb b/lib/ruby_lsp/ruby_lsp_rails/server.rb index cbe0cca9..7cad461c 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/server.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/server.rb @@ -3,12 +3,6 @@ require "json" -if ActionDispatch::Routing::Mapper.respond_to?(:route_source_locations) - ActionDispatch::Routing::Mapper.route_source_locations = true -end - -Rails.application.routes.eager_load! - # NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the # client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key. diff --git a/test/dummy/config/initializers/action_dispatch.rb b/test/dummy/config/initializers/action_dispatch.rb new file mode 100644 index 00000000..d47a77e7 --- /dev/null +++ b/test/dummy/config/initializers/action_dispatch.rb @@ -0,0 +1,5 @@ +# typed: true +# frozen_string_literal: true + +# Route source locations are normally only available in development, so we need to enable this in test mode. +ActionDispatch::Routing::Mapper.route_source_locations = true From 8fe81ace4086599104c36c72a3593dd8269d39d9 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:28:49 -0400 Subject: [PATCH 12/12] Lint --- test/dummy/config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index 6f982779..38d2d68d 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -37,7 +37,7 @@ # Log to STDOUT with the current request id as a default log tag. config.log_tags = [:request_id] - config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) + 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")