diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index d00decb4..11876b9d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: node: [20] - gemfile: ["Gemfile.rails_6", "Gemfile.rails_7_0", "Gemfile"] + gemfile: ["Gemfile.rails_6", "Gemfile.rails_7_0", "Gemfile.rails_7_2", "Gemfile"] steps: - name: Checkout code diff --git a/.gitignore b/.gitignore index 42d99d88..1b999455 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,13 @@ spec/dummy/log/*.log spec/dummy/storage/ spec/dummy/tmp/ spec/dummy/public/*theme* +spec/legacy_dummy/db/*.sqlite3 +spec/legacy_dummy/db/*.sqlite3-journal +spec/legacy_dummy/db/*.sqlite3-* +spec/legacy_dummy/log/*.log +spec/legacy_dummy/storage/ +spec/legacy_dummy/tmp/ +spec/legacy_dummy/public/*theme* .DS_Store tmp/ node_modules/ diff --git a/.rubocop.yml b/.rubocop.yml index afd543bc..18507c95 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,7 +21,7 @@ Documentation: Enabled: false AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.0 Exclude: - 'bin/*' - 'coverage/**/*' diff --git a/Gemfile b/Gemfile index 1d1df77b..42c5bfde 100644 --- a/Gemfile +++ b/Gemfile @@ -8,19 +8,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } # development dependencies will be added by default to the :development group. gemspec -gem 'rails', '~> 7.2.1' +gem 'rails', '~> 8.0.0' # Use Active Storage variant gem 'image_processing', '~> 1.12.2' -# Use Sprockets to deal with assets in the dummy app -gem 'sprockets-rails' - -# Rack vulnerable to ReDoS in content type parsing -gem 'rack', '~> 3.0.10' - -# REXML contains a denial of service vulnerability -gem 'rexml', '>= 3.3.6' +# Use Propshaft to deal with assets in the dummy app +gem 'propshaft' # Temporary use this branch because it solves a bug # gem 'maglev-injectable', path: '../injectable' @@ -34,7 +28,6 @@ gem 'rexml', '>= 3.3.6' # gem 'byebug', group: [:development, :test] group :development, :test do - # Use SCSS for stylesheets gem 'bcrypt' gem 'factory_bot_rails', '~> 6.2.0' diff --git a/Gemfile.lock b/Gemfile.lock index b73babd4..6cce5a31 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,74 +5,74 @@ PATH jbuilder (~> 2.12.0) kaminari (~> 1.2.1) maglev-injectable (~> 2.1.1) - rails (>= 6, < 7.3) + rails (>= 6, < 9) vite_rails (>= 3, < 4) vite_ruby (>= 3.5) GEM remote: https://rubygems.org/ specs: - actioncable (7.2.1) - actionpack (= 7.2.1) - activesupport (= 7.2.1) + actioncable (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.1) - actionpack (= 7.2.1) - activejob (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) + actionmailbox (8.0.0) + actionpack (= 8.0.0) + activejob (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) mail (>= 2.8.0) - actionmailer (7.2.1) - actionpack (= 7.2.1) - actionview (= 7.2.1) - activejob (= 7.2.1) - activesupport (= 7.2.1) + actionmailer (8.0.0) + actionpack (= 8.0.0) + actionview (= 8.0.0) + activejob (= 8.0.0) + activesupport (= 8.0.0) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.1) - actionview (= 7.2.1) - activesupport (= 7.2.1) + actionpack (8.0.0) + actionview (= 8.0.0) + activesupport (= 8.0.0) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.2) + rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.1) - actionpack (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) + actiontext (8.0.0) + actionpack (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.1) - activesupport (= 7.2.1) + actionview (8.0.0) + activesupport (= 8.0.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.1) - activesupport (= 7.2.1) + activejob (8.0.0) + activesupport (= 8.0.0) globalid (>= 0.3.6) - activemodel (7.2.1) - activesupport (= 7.2.1) - activerecord (7.2.1) - activemodel (= 7.2.1) - activesupport (= 7.2.1) + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) timeout (>= 0.4.0) - activestorage (7.2.1) - actionpack (= 7.2.1) - activejob (= 7.2.1) - activerecord (= 7.2.1) - activesupport (= 7.2.1) + activestorage (8.0.0) + actionpack (= 8.0.0) + activejob (= 8.0.0) + activerecord (= 8.0.0) + activesupport (= 8.0.0) marcel (~> 1.0) - activesupport (7.2.1) + activesupport (8.0.0) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) @@ -82,18 +82,20 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) - annotate (3.2.0) - activerecord (>= 3.2, < 8.0) - rake (>= 10.4, < 14.0) + uri (>= 0.13.1) + annotate (2.6.5) + activerecord (>= 2.3.0) + rake (>= 0.8.7) ast (2.4.2) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.4.0) bigdecimal (3.1.8) builder (3.3.0) concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) - date (3.3.4) + date (3.4.0) diff-lcs (1.5.1) docile (1.4.0) drb (2.2.1) @@ -151,7 +153,7 @@ GEM mini_magick (4.13.1) mini_mime (1.1.5) minitest (5.24.1) - net-imap (0.4.14) + net-imap (0.5.1) date net-protocol net-pop (0.1.2) @@ -160,7 +162,7 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) + nio4r (2.7.4) nokogiri (1.16.6-x86_64-darwin) racc (~> 1.4) nokogiri (1.16.6-x86_64-linux) @@ -169,7 +171,12 @@ GEM parser (3.3.3.0) ast (~> 2.4.1) racc - pg (1.5.6) + pg (1.5.9) + propshaft (1.1.0) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + railties (>= 7.0.0) psych (5.1.2) stringio racc (1.8.0) @@ -183,20 +190,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.2.1) - actioncable (= 7.2.1) - actionmailbox (= 7.2.1) - actionmailer (= 7.2.1) - actionpack (= 7.2.1) - actiontext (= 7.2.1) - actionview (= 7.2.1) - activejob (= 7.2.1) - activemodel (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) + rails (8.0.0) + actioncable (= 8.0.0) + actionmailbox (= 8.0.0) + actionmailer (= 8.0.0) + actionpack (= 8.0.0) + actiontext (= 8.0.0) + actionview (= 8.0.0) + activejob (= 8.0.0) + activemodel (= 8.0.0) + activerecord (= 8.0.0) + activestorage (= 8.0.0) + activesupport (= 8.0.0) bundler (>= 1.15.0) - railties (= 7.2.1) + railties (= 8.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -204,9 +211,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.2.1) - actionpack (= 7.2.1) - activesupport (= 7.2.1) + railties (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -286,13 +293,6 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) stringio (3.1.1) strscan (3.1.0) thor (1.3.1) @@ -300,9 +300,10 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uri (1.0.2) useragent (0.16.10) - vite_rails (3.0.17) - railties (>= 5.1, < 8) + vite_rails (3.0.19) + railties (>= 5.1, < 9) vite_ruby (~> 3.0, >= 3.2.2) vite_ruby (3.8.2) dry-cli (>= 0.7, < 2) @@ -326,17 +327,15 @@ DEPENDENCIES image_processing (~> 1.12.2) maglevcms! nokogiri (>= 1.15.6) - pg (~> 1.5.6) - rack (~> 3.0.10) - rails (~> 7.2.1) + pg (~> 1.5.9) + propshaft + rails (~> 8.0.0) rdoc (>= 6.6.3.1) - rexml (>= 3.3.6) rspec-rails rubocop rubocop-rails_config rubocop-rspec simplecov - sprockets-rails BUNDLED WITH 2.4.22 diff --git a/Gemfile.rails_6.lock b/Gemfile.rails_6.lock index b2aacb37..e9651d38 100644 --- a/Gemfile.rails_6.lock +++ b/Gemfile.rails_6.lock @@ -5,7 +5,7 @@ PATH jbuilder (~> 2.12.0) kaminari (~> 1.2.1) maglev-injectable (~> 2.1.1) - rails (>= 6, < 7.3) + rails (>= 6, < 9) vite_rails (>= 3, < 4) vite_ruby (>= 3.5) @@ -160,7 +160,7 @@ GEM parser (3.3.5.0) ast (~> 2.4.1) racc - pg (1.5.8) + pg (1.5.9) racc (1.8.1) rack (2.2.9) rack-proxy (0.7.7) @@ -302,7 +302,7 @@ DEPENDENCIES maglevcms! mini_magick (~> 4.11) nokogiri (>= 1.13.10) - pg (~> 1.5.6) + pg (~> 1.5.9) rails (~> 6.1) rspec-rails rubocop diff --git a/Gemfile.rails_7_0.lock b/Gemfile.rails_7_0.lock index 3fb6c85b..245d27ff 100644 --- a/Gemfile.rails_7_0.lock +++ b/Gemfile.rails_7_0.lock @@ -5,7 +5,7 @@ PATH jbuilder (~> 2.12.0) kaminari (~> 1.2.1) maglev-injectable (~> 2.1.1) - rails (>= 6, < 7.3) + rails (>= 6, < 9) vite_rails (>= 3, < 4) vite_ruby (>= 3.5) @@ -166,7 +166,7 @@ GEM parser (3.3.5.0) ast (~> 2.4.1) racc - pg (1.5.8) + pg (1.5.9) racc (1.8.1) rack (2.2.9) rack-proxy (0.7.7) @@ -308,7 +308,7 @@ DEPENDENCIES maglevcms! mini_magick (~> 4.11) nokogiri (>= 1.13.10) - pg (~> 1.5.6) + pg (~> 1.5.9) rails (= 7.0.8) rspec-rails rubocop diff --git a/Gemfile.rails_7_2 b/Gemfile.rails_7_2 new file mode 100644 index 00000000..8a02067b --- /dev/null +++ b/Gemfile.rails_7_2 @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +# Declare your gem's dependencies in maglev.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +gem 'rails', '~> 7.2.2' + +# Use Active Storage variant +gem 'image_processing', '~> 1.12.2' + +# Use Sprockets to deal with assets in the dummy app +gem 'sprockets-rails' + +# Rack vulnerable to ReDoS in content type parsing +gem 'rack', '~> 3.0.10' + +# REXML contains a denial of service vulnerability +gem 'rexml', '>= 3.3.6' + +# Temporary use this branch because it solves a bug +# gem 'maglev-injectable', path: '../injectable' + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use a debugger +# gem 'byebug', group: [:development, :test] + +group :development, :test do + # Use SCSS for stylesheets + gem 'bcrypt' + + gem 'factory_bot_rails', '~> 6.2.0' + gem 'rspec-rails' + + gem 'rubocop', require: false + gem 'rubocop-rails_config' + gem 'rubocop-rspec' + + gem 'generator_spec' + + gem 'nokogiri', '>= 1.15.6' + + gem 'annotate' + + gem 'rdoc', '>= 6.6.3.1' +end + +group :test do + gem 'simplecov', require: false +end diff --git a/Gemfile.rails_7_2.lock b/Gemfile.rails_7_2.lock new file mode 100644 index 00000000..1c3b7beb --- /dev/null +++ b/Gemfile.rails_7_2.lock @@ -0,0 +1,371 @@ +PATH + remote: . + specs: + maglevcms (1.7.3) + jbuilder (~> 2.12.0) + kaminari (~> 1.2.1) + maglev-injectable (~> 2.1.1) + rails (>= 6, < 9) + vite_rails (>= 3, < 4) + vite_ruby (>= 3.5) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) + actionmailer (7.2.2) + actionpack (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.2) + actionview (= 7.2.2) + activesupport (= 7.2.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4, < 3.2) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.2) + actionpack (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.2.2) + activesupport (= 7.2.2) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.2.2) + activesupport (= 7.2.2) + globalid (>= 0.3.6) + activemodel (7.2.2) + activesupport (= 7.2.2) + activerecord (7.2.2) + activemodel (= 7.2.2) + activesupport (= 7.2.2) + timeout (>= 0.4.0) + activestorage (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activesupport (= 7.2.2) + marcel (~> 1.0) + activesupport (7.2.2) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + annotate (3.2.0) + activerecord (>= 3.2, < 8.0) + rake (>= 10.4, < 14.0) + ast (2.4.2) + base64 (0.2.0) + bcrypt (3.1.20) + benchmark (0.4.0) + bigdecimal (3.1.8) + builder (3.3.0) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + crass (1.0.6) + date (3.4.0) + diff-lcs (1.5.1) + docile (1.4.1) + drb (2.2.1) + dry-cli (1.2.0) + erubi (1.13.0) + factory_bot (6.2.1) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + generator_spec (0.10.0) + activesupport (>= 3.0.0) + railties (>= 3.0.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + image_processing (1.12.2) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + json (2.8.2) + kaminari (1.2.2) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) + actionview + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) + activerecord + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) + language_server-protocol (3.17.0.3) + logger (1.6.1) + loofah (2.23.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + maglev-injectable (2.1.1) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + mini_magick (4.13.2) + mini_mime (1.1.5) + minitest (5.25.2) + mutex_m (0.3.0) + net-imap (0.5.1) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.4) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + parallel (1.26.3) + parser (3.3.6.0) + ast (~> 2.4.1) + racc + pg (1.5.9) + psych (5.2.0) + stringio + racc (1.8.1) + rack (3.0.11) + rack-proxy (0.7.7) + rack + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.2.1) + rack (>= 3) + rails (7.2.2) + actioncable (= 7.2.2) + actionmailbox (= 7.2.2) + actionmailer (= 7.2.2) + actionpack (= 7.2.2) + actiontext (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activemodel (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) + bundler (>= 1.15.0) + railties (= 7.2.2) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rdoc (6.8.1) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.11) + io-console (~> 0.5) + rexml (3.3.9) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (7.1.0) + actionpack (>= 7.0) + activesupport (>= 7.0) + railties (>= 7.0) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) + rubocop (1.68.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.36.1) + parser (>= 3.3.1.0) + rubocop-md (1.2.4) + rubocop (>= 1.45) + rubocop-minitest (0.36.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-packaging (0.5.2) + rubocop (>= 1.33, < 2.0) + rubocop-performance (1.23.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.27.0) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.52.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails_config (1.16.0) + rubocop (>= 1.57.0) + rubocop-ast (>= 1.26.0) + rubocop-md + rubocop-minitest (~> 0.22) + rubocop-packaging (~> 0.5) + rubocop-performance (~> 1.11) + rubocop-rails (~> 2.0) + rubocop-rspec (3.2.0) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + ruby-vips (2.2.2) + ffi (~> 1.12) + logger + securerandom (0.3.2) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) + stringio (3.1.2) + thor (1.3.2) + timeout (0.4.2) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.6.0) + useragent (0.16.10) + vite_rails (3.0.19) + railties (>= 5.1, < 9) + vite_ruby (~> 3.0, >= 3.2.2) + vite_ruby (3.9.1) + dry-cli (>= 0.7, < 2) + logger (~> 1.6) + mutex_m + rack-proxy (~> 0.6, >= 0.6.1) + zeitwerk (~> 2.2) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.7.1) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + annotate + bcrypt + factory_bot_rails (~> 6.2.0) + generator_spec + image_processing (~> 1.12.2) + maglevcms! + nokogiri (>= 1.15.6) + pg (~> 1.5.9) + rack (~> 3.0.10) + rails (~> 7.2.2) + rdoc (>= 6.6.3.1) + rexml (>= 3.3.6) + rspec-rails + rubocop + rubocop-rails_config + rubocop-rspec + simplecov + sprockets-rails + +BUNDLED WITH + 2.5.7 diff --git a/Rakefile b/Rakefile index 142071c8..9357f7d6 100644 --- a/Rakefile +++ b/Rakefile @@ -20,7 +20,8 @@ require 'vite_ruby' ViteRuby.install_tasks ViteRuby.config.root # Ensure the engine is set as the root. -APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__) +rakefile_path = Rails::VERSION::MAJOR >= 8 ? 'spec/dummy/Rakefile' : 'spec/legacy_dummy/Rakefile' +APP_RAKEFILE = File.expand_path(rakefile_path, __dir__) load 'rails/tasks/engine.rake' load 'rails/tasks/statistics.rake' diff --git a/app/models/maglev/site/locales_concern.rb b/app/models/maglev/site/locales_concern.rb index 6db9f0ff..13b1d484 100644 --- a/app/models/maglev/site/locales_concern.rb +++ b/app/models/maglev/site/locales_concern.rb @@ -6,7 +6,7 @@ module Maglev::Site::LocalesConcern included do ## serializers ## - if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR.positive? + if Rails::VERSION::MAJOR >= 8 || (Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR.positive?) serialize :locales, coder: LocalesSerializer else serialize :locales, LocalesSerializer diff --git a/config/routes.rb b/config/routes.rb index 745c3d8a..57f89b7c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,7 +33,7 @@ # Admin namespace :admin do root to: 'dashboard#index' - resource :theme, only: %i[index show] + resource :theme, only: %i[show] namespace :sections, path: 'sections/:id' do get :preview, to: 'previews#show' get :preview_in_frame, to: 'previews#iframe_show' diff --git a/lib/maglev/preview_constraint.rb b/lib/maglev/preview_constraint.rb index 2b394028..fb9756a5 100644 --- a/lib/maglev/preview_constraint.rb +++ b/lib/maglev/preview_constraint.rb @@ -4,7 +4,7 @@ module Maglev class PreviewConstraint - CRAWLER_USER_AGENTS = /Googlebot|Twitterbot|facebookexternalhit|LinkedInBot/o.freeze + CRAWLER_USER_AGENTS = /Googlebot|Twitterbot|facebookexternalhit|LinkedInBot/o attr_reader :preview_host diff --git a/maglevcms.gemspec b/maglevcms.gemspec index 9af54a66..010722d9 100644 --- a/maglevcms.gemspec +++ b/maglevcms.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| MaglevCMS integrates a powerful website/page builder with a polished UX/UI into your Ruby on Rails application, backed by a flexible and robust CMS engine. DOC spec.license = 'MIT' - spec.required_ruby_version = '>= 2.6' + spec.required_ruby_version = '>= 3.0' # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host. @@ -48,10 +48,10 @@ Gem::Specification.new do |spec| spec.add_dependency 'jbuilder', '~> 2.12.0' spec.add_dependency 'kaminari', '~> 1.2.1' spec.add_dependency 'maglev-injectable', '~> 2.1.1' - spec.add_dependency 'rails', '< 7.3', '>= 6' + spec.add_dependency 'rails', '< 9', '>= 6' spec.add_dependency 'vite_rails', '< 4', '>= 3' spec.add_dependency 'vite_ruby', '>= 3.5' - spec.add_development_dependency 'pg', '~> 1.5.6' + spec.add_development_dependency 'pg', '~> 1.5.9' end # rubocop:enable Metrics/BlockLength diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb index 673f86ab..08c74478 100644 --- a/spec/dummy/app/controllers/application_controller.rb +++ b/spec/dummy/app/controllers/application_controller.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true 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 + rescue_from Maglev::Errors::NotAuthorized, with: :unauthorized_maglev private diff --git a/spec/dummy/app/models/application_record.rb b/spec/dummy/app/models/application_record.rb index 71fbba5b..08dc5379 100644 --- a/spec/dummy/app/models/application_record.rb +++ b/spec/dummy/app/models/application_record.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true + primary_abstract_class end diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb index 3d763b6a..a759563f 100644 --- a/spec/dummy/app/views/layouts/application.html.erb +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -1,12 +1,26 @@ - - <%= content_for?(:page_title) ? yield(:page_title) : '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/assets/stylesheets %> + <%= stylesheet_link_tag :app %> + <%= yield %> diff --git a/spec/dummy/app/views/layouts/mailer.html.erb b/spec/dummy/app/views/layouts/mailer.html.erb index cbd34d2e..3aac9002 100644 --- a/spec/dummy/app/views/layouts/mailer.html.erb +++ b/spec/dummy/app/views/layouts/mailer.html.erb @@ -1,7 +1,7 @@ - + diff --git a/spec/dummy/app/views/products/show.html.erb b/spec/dummy/app/views/products/show.html.erb index 28252b8b..57df3aed 100644 --- a/spec/dummy/app/views/products/show.html.erb +++ b/spec/dummy/app/views/products/show.html.erb @@ -1,4 +1,4 @@ <%= render_maglev_section :navbar %> -<% content_for(:page_title) { @product.name } %> +<% content_for(:title) { @product.name } %>

<%= @product.name %>

Price: <%= number_to_currency @product.price %>

\ No newline at end of file diff --git a/spec/dummy/app/views/pwa/manifest.json.erb b/spec/dummy/app/views/pwa/manifest.json.erb new file mode 100644 index 00000000..a3c046e4 --- /dev/null +++ b/spec/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/spec/dummy/app/views/pwa/service-worker.js b/spec/dummy/app/views/pwa/service-worker.js new file mode 100644 index 00000000..b3a13fb7 --- /dev/null +++ b/spec/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/spec/dummy/bin/dev b/spec/dummy/bin/dev new file mode 100755 index 00000000..39257831 --- /dev/null +++ b/spec/dummy/bin/dev @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +exec './bin/rails', 'server', *ARGV diff --git a/spec/dummy/bin/setup b/spec/dummy/bin/setup index 65a6ca72..f9291716 100755 --- a/spec/dummy/bin/setup +++ b/spec/dummy/bin/setup @@ -3,25 +3,23 @@ require 'fileutils' -# path to your application root. APP_ROOT = File.expand_path('..', __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do - # This script is a way to setup or update your development environment automatically. - # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # 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 ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" @@ -30,6 +28,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/spec/dummy/config.ru b/spec/dummy/config.ru index 842bccc3..6dc83218 100644 --- a/spec/dummy/config.ru +++ b/spec/dummy/config.ru @@ -5,3 +5,4 @@ require_relative 'config/environment' run Rails.application +Rails.application.load_server diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index 71c7ff9a..f597fa8b 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -4,23 +4,29 @@ 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 'maglev' module Dummy class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - if Rails::VERSION::MAJOR > 6 - config.load_defaults 7.0 - else - config.load_defaults 6.0 - end + config.load_defaults Rails::VERSION::STRING.to_f - # Settings in config/environments/* take precedence over those specified here. - # Application configuration can go into files in config/initializers - # -- all .rb files in that directory are automatically loaded after loading - # the framework and any gems in your application. + # For compatibility with applications that use this config + config.action_controller.include_all_helpers = false - config.i18n.available_locales = %i[en fr] + # 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") end end diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb index 62979965..25d6c428 100644 --- a/spec/dummy/config/environments/development.rb +++ b/spec/dummy/config/environments/development.rb @@ -1,12 +1,12 @@ # 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 on - # every request. 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 @@ -14,30 +14,34 @@ # 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. + # 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.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 # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Make template changes take effect immediately. 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 @@ -47,18 +51,21 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = true - # Suppress logger output for asset requests. - config.assets.quiet = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # 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 - # 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 + # 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/spec/dummy/config/environments/production.rb b/spec/dummy/config/environments/production.rb index 0eecdbb9..a4828229 100644 --- a/spec/dummy/config/environments/production.rb +++ b/spec/dummy/config/environments/production.rb @@ -1,114 +1,91 @@ # 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 - - # 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 + # Full error reports are disabled. + config.consider_all_requests_local = false - # 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? - - # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + # 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.action_controller.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 + # config.asset_host = "http://assets.example.com" # 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 - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # 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. + # 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') + + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = '/up' - # 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" + # 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 - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # 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 - # 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. + # 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` + # ] # - # 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 + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index 151eab39..7d2a64e5 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -8,50 +8,53 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = false - config.action_view.cache_template_loading = 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 + # 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 - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR > 0 - :none - else - false - end + # 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 # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test - + config.active_storage.variant_processor = :mini_magick - config.action_mailer.perform_caching = false - # 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 + # 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.action_view.raise_on_missing_translations = true + # 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 + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = :none end diff --git a/spec/dummy/config/initializers/assets.rb b/spec/dummy/config/initializers/assets.rb index bcafccdd..019d0bbb 100644 --- a/spec/dummy/config/initializers/assets.rb +++ b/spec/dummy/config/initializers/assets.rb @@ -7,8 +7,3 @@ # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path - -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in the app/assets -# folder are already added. -# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/spec/dummy/config/initializers/content_security_policy.rb b/spec/dummy/config/initializers/content_security_policy.rb index 87fd451f..35ab3fd6 100644 --- a/spec/dummy/config/initializers/content_security_policy.rb +++ b/spec/dummy/config/initializers/content_security_policy.rb @@ -2,29 +2,26 @@ # 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 +# 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.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" +# 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 - -# 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/spec/dummy/config/initializers/filter_parameter_logging.rb b/spec/dummy/config/initializers/filter_parameter_logging.rb index 7a4f47b4..d81a902e 100644 --- a/spec/dummy/config/initializers/filter_parameter_logging.rb +++ b/spec/dummy/config/initializers/filter_parameter_logging.rb @@ -2,5 +2,9 @@ # 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 += [:password] +# 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 += %i[ + passw email secret token _key crypt salt certificate otp ssn cvv cvc +] diff --git a/spec/dummy/config/initializers/inflections.rb b/spec/dummy/config/initializers/inflections.rb index 1f5f9d63..9e049dcc 100644 --- a/spec/dummy/config/initializers/inflections.rb +++ b/spec/dummy/config/initializers/inflections.rb @@ -6,13 +6,13 @@ # 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.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 +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/spec/dummy/config/puma.rb b/spec/dummy/config/puma.rb index 69e2645f..f4aa1fea 100644 --- a/spec/dummy/config/puma.rb +++ b/spec/dummy/config/puma.rb @@ -1,40 +1,40 @@ # 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. # -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 `port` that Puma will listen on to receive requests; default is 3000. +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. # -port ENV.fetch('PORT', 3000) - -# Specifies the `environment` that Puma will run in. +# 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. # -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). +# 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. # -# 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. +# 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. # -# 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 -# Allow puma to be restarted by `rails restart` command. +# 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/spec/dummy/config/storage.yml b/spec/dummy/config/storage.yml index d32f76e8..4942ab66 100644 --- a/spec/dummy/config/storage.yml +++ b/spec/dummy/config/storage.yml @@ -6,27 +6,27 @@ local: service: Disk root: <%= Rails.root.join("storage") %> -# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) # amazon: # service: S3 # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> # region: us-east-1 -# bucket: your_own_bucket +# bucket: your_own_bucket-<%= Rails.env %> # Remember not to checkin your GCS keyfile to a repository # google: # service: GCS # project: your_project # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> -# bucket: your_own_bucket +# bucket: your_own_bucket-<%= Rails.env %> -# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) # microsoft: # service: AzureStorage # storage_account_name: your_account_name # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> -# container: your_container_name +# container: your_container_name-<%= Rails.env %> # mirror: # service: Mirror diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 4a05ed06..5077c1e8 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -10,16 +10,15 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_06_12_092235) do - +ActiveRecord::Schema[8.0].define(version: 2022_06_12_092235) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension "pg_catalog.plpgsql" create_table "accounts", force: :cascade do |t| t.string "email" t.string "password_digest" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "active_storage_attachments", force: :cascade do |t| @@ -27,7 +26,7 @@ t.string "record_type", null: false t.bigint "record_id", null: false t.bigint "blob_id", null: false - t.datetime "created_at", null: false + t.datetime "created_at", precision: nil, null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end @@ -39,7 +38,7 @@ t.text "metadata" t.bigint "byte_size", null: false t.string "checksum", null: false - t.datetime "created_at", null: false + t.datetime "created_at", precision: nil, null: false t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end @@ -56,8 +55,8 @@ t.integer "width" t.integer "height" t.integer "byte_size" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "maglev_page_paths", force: :cascade do |t| @@ -72,8 +71,8 @@ create_table "maglev_pages", force: :cascade do |t| t.boolean "visible", default: true - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.jsonb "title_translations", default: {} t.jsonb "seo_title_translations", default: {} t.jsonb "meta_description_translations", default: {} @@ -86,8 +85,8 @@ create_table "maglev_sites", force: :cascade do |t| t.string "name" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.jsonb "navigation", default: [] t.jsonb "locales", default: [] t.jsonb "sections_translations", default: {} @@ -106,8 +105,8 @@ t.string "sku" t.float "price" t.boolean "sold_out", default: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" diff --git a/spec/dummy/public/400.html b/spec/dummy/public/400.html new file mode 100644 index 00000000..282dbc8c --- /dev/null +++ b/spec/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/spec/dummy/public/404.html b/spec/dummy/public/404.html index 2be3af26..c0670bc8 100644 --- a/spec/dummy/public/404.html +++ b/spec/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/spec/dummy/public/406-unsupported-browser.html b/spec/dummy/public/406-unsupported-browser.html new file mode 100644 index 00000000..9532a9cc --- /dev/null +++ b/spec/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/spec/dummy/public/422.html b/spec/dummy/public/422.html index c08eac0d..8bcf0601 100644 --- a/spec/dummy/public/422.html +++ b/spec/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/spec/dummy/public/500.html b/spec/dummy/public/500.html index 78a030af..d77718c3 100644 --- a/spec/dummy/public/500.html +++ b/spec/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/spec/dummy/public/icon.png b/spec/dummy/public/icon.png new file mode 100644 index 00000000..c4c9dbfb Binary files /dev/null and b/spec/dummy/public/icon.png differ diff --git a/spec/dummy/public/icon.svg b/spec/dummy/public/icon.svg new file mode 100644 index 00000000..04b34bf8 --- /dev/null +++ b/spec/dummy/public/icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/spec/dummy/.browserslistrc b/spec/legacy_dummy/.browserslistrc similarity index 100% rename from spec/dummy/.browserslistrc rename to spec/legacy_dummy/.browserslistrc diff --git a/spec/dummy/.ruby-version b/spec/legacy_dummy/.ruby-version similarity index 100% rename from spec/dummy/.ruby-version rename to spec/legacy_dummy/.ruby-version diff --git a/spec/legacy_dummy/Rakefile b/spec/legacy_dummy/Rakefile new file mode 100644 index 00000000..488c551f --- /dev/null +++ b/spec/legacy_dummy/Rakefile @@ -0,0 +1,8 @@ +# 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. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/spec/dummy/app/assets/config/manifest.js b/spec/legacy_dummy/app/assets/config/manifest.js similarity index 100% rename from spec/dummy/app/assets/config/manifest.js rename to spec/legacy_dummy/app/assets/config/manifest.js diff --git a/spec/dummy/lib/assets/.keep b/spec/legacy_dummy/app/assets/images/.keep similarity index 100% rename from spec/dummy/lib/assets/.keep rename to spec/legacy_dummy/app/assets/images/.keep diff --git a/spec/legacy_dummy/app/assets/images/new-logo.png b/spec/legacy_dummy/app/assets/images/new-logo.png new file mode 100644 index 00000000..151709ba Binary files /dev/null and b/spec/legacy_dummy/app/assets/images/new-logo.png differ diff --git a/spec/legacy_dummy/app/assets/images/themes/sections/jumbotron.png b/spec/legacy_dummy/app/assets/images/themes/sections/jumbotron.png new file mode 100644 index 00000000..92b00652 Binary files /dev/null and b/spec/legacy_dummy/app/assets/images/themes/sections/jumbotron.png differ diff --git a/spec/legacy_dummy/app/assets/stylesheets/application.css b/spec/legacy_dummy/app/assets/stylesheets/application.css new file mode 100644 index 00000000..0ebd7fe8 --- /dev/null +++ b/spec/legacy_dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/spec/dummy/app/channels/application_cable/channel.rb b/spec/legacy_dummy/app/channels/application_cable/channel.rb similarity index 100% rename from spec/dummy/app/channels/application_cable/channel.rb rename to spec/legacy_dummy/app/channels/application_cable/channel.rb diff --git a/spec/dummy/app/channels/application_cable/connection.rb b/spec/legacy_dummy/app/channels/application_cable/connection.rb similarity index 100% rename from spec/dummy/app/channels/application_cable/connection.rb rename to spec/legacy_dummy/app/channels/application_cable/connection.rb diff --git a/spec/legacy_dummy/app/controllers/application_controller.rb b/spec/legacy_dummy/app/controllers/application_controller.rb new file mode 100644 index 00000000..673f86ab --- /dev/null +++ b/spec/legacy_dummy/app/controllers/application_controller.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class ApplicationController < ActionController::Base + rescue_from Maglev::Errors::NotAuthorized, with: :unauthorized_maglev + + private + + def current_account + Account.first + end + + protected + + def exotic_locale + 'fr' + end + + def unauthorized_maglev + flash[:error] = "You're not authorized to access the Maglev editor!" + redirect_to main_app.nocoffee_path + end +end diff --git a/spec/dummy/public/apple-touch-icon-precomposed.png b/spec/legacy_dummy/app/controllers/concerns/.keep similarity index 100% rename from spec/dummy/public/apple-touch-icon-precomposed.png rename to spec/legacy_dummy/app/controllers/concerns/.keep diff --git a/spec/legacy_dummy/app/controllers/products_controller.rb b/spec/legacy_dummy/app/controllers/products_controller.rb new file mode 100644 index 00000000..d6b8463b --- /dev/null +++ b/spec/legacy_dummy/app/controllers/products_controller.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class ProductsController < ApplicationController + include Maglev::StandaloneSectionsConcern + + def show + fetch_maglev_site_scoped_sections + @product = Product.find(params[:id]) + end +end diff --git a/spec/legacy_dummy/app/helpers/application_helper.rb b/spec/legacy_dummy/app/helpers/application_helper.rb new file mode 100644 index 00000000..15b06f0f --- /dev/null +++ b/spec/legacy_dummy/app/helpers/application_helper.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +module ApplicationHelper +end diff --git a/spec/dummy/app/javascript/packs/application.js b/spec/legacy_dummy/app/javascript/packs/application.js similarity index 100% rename from spec/dummy/app/javascript/packs/application.js rename to spec/legacy_dummy/app/javascript/packs/application.js diff --git a/spec/legacy_dummy/app/jobs/application_job.rb b/spec/legacy_dummy/app/jobs/application_job.rb new file mode 100644 index 00000000..bef39599 --- /dev/null +++ b/spec/legacy_dummy/app/jobs/application_job.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +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/spec/legacy_dummy/app/mailers/application_mailer.rb b/spec/legacy_dummy/app/mailers/application_mailer.rb new file mode 100644 index 00000000..d84cb6e7 --- /dev/null +++ b/spec/legacy_dummy/app/mailers/application_mailer.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/spec/legacy_dummy/app/models/account.rb b/spec/legacy_dummy/app/models/account.rb new file mode 100644 index 00000000..6a6b4549 --- /dev/null +++ b/spec/legacy_dummy/app/models/account.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class Account < ApplicationRecord + has_secure_password +end + +# == Schema Information +# +# Table name: accounts +# +# id :bigint not null, primary key +# email :string +# password_digest :string +# created_at :datetime not null +# updated_at :datetime not null +# diff --git a/spec/legacy_dummy/app/models/application_record.rb b/spec/legacy_dummy/app/models/application_record.rb new file mode 100644 index 00000000..71fbba5b --- /dev/null +++ b/spec/legacy_dummy/app/models/application_record.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/spec/dummy/public/apple-touch-icon.png b/spec/legacy_dummy/app/models/concerns/.keep similarity index 100% rename from spec/dummy/public/apple-touch-icon.png rename to spec/legacy_dummy/app/models/concerns/.keep diff --git a/spec/legacy_dummy/app/models/product.rb b/spec/legacy_dummy/app/models/product.rb new file mode 100644 index 00000000..570ba755 --- /dev/null +++ b/spec/legacy_dummy/app/models/product.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class Product < ApplicationRecord + has_one_attached :thumbnail + + def thumbnail_url + return nil unless thumbnail.attached? + + Rails.application.routes.url_helpers.cdn_image_url( + thumbnail.variant(resize_to_limit: [200, 200]) + ) + end + + # rubocop:disable Lint/UnusedMethodArgument + def self.maglev_fetch_sold_out(site:, keyword:, max_items: 10) + all + .where(sold_out: true) + .where(keyword.present? ? Product.arel_table[:name].matches("%#{keyword}%") : nil) + .limit(max_items) + .order(:name) + end + # rubocop:enable Lint/UnusedMethodArgument +end + +# == Schema Information +# +# Table name: products +# +# id :bigint not null, primary key +# name :string +# price :float +# sku :string +# sold_out :boolean default(FALSE) +# created_at :datetime not null +# updated_at :datetime not null +# diff --git a/spec/legacy_dummy/app/theme/.keep b/spec/legacy_dummy/app/theme/.keep new file mode 100644 index 00000000..4f07f1ca --- /dev/null +++ b/spec/legacy_dummy/app/theme/.keep @@ -0,0 +1 @@ +.keep \ No newline at end of file diff --git a/spec/legacy_dummy/app/theme/sections/features/featured_product.yml b/spec/legacy_dummy/app/theme/sections/features/featured_product.yml new file mode 100644 index 00000000..68e5a046 --- /dev/null +++ b/spec/legacy_dummy/app/theme/sections/features/featured_product.yml @@ -0,0 +1,15 @@ +name: Featured product + +category: features + +settings: +- label: "Title" + id: title + type: text + +- label: "Product" + id: product + type: collection_item + collection_id: products + +blocks: [] \ No newline at end of file diff --git a/spec/legacy_dummy/app/theme/sections/features/showcase.yml b/spec/legacy_dummy/app/theme/sections/features/showcase.yml new file mode 100644 index 00000000..3ad26c64 --- /dev/null +++ b/spec/legacy_dummy/app/theme/sections/features/showcase.yml @@ -0,0 +1,46 @@ +# Name of the section displayed in the editor UI +name: Showcase + +# Category of the section in the editor UI (header, features, testimonials, ...etc) +category: features + +# Definition of the settings: +# A setting type can be one of the following values: text, image, checkbox, link and color. +# Please visit: https://docs.maglev.dev/concepts/setting for more explanation. +settings: +- label: "Title" + id: title + type: text + # html: true + # line_break: true + default: "My work" + +# Definition of the blocks. +# You can define as many types of blocks as you want. +blocks: +- name: "Item" + type: item + settings: + - label: "Title" + id: title + type: text + # html: true + # line_break: true + default: "Work #1" + + - label: "Image" + id: image + type: image + default: "/samples/images/default.svg" + + - label: "Description" + id: description + type: text + html: true + nb_rows: 6 + # line_break: true + default: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eros nisi, feugiat non molestie ac, pretium sodales eros. Nullam faucibus malesuada orci non dignissim. " + +# By default, in the editor UI, blocks will be listed below the "Content" title. +# The title can be changed with the following property: +# blocks_label: "My list of items" \ No newline at end of file diff --git a/spec/legacy_dummy/app/theme/sections/headers/jumbotron.yml b/spec/legacy_dummy/app/theme/sections/headers/jumbotron.yml new file mode 100644 index 00000000..51199507 --- /dev/null +++ b/spec/legacy_dummy/app/theme/sections/headers/jumbotron.yml @@ -0,0 +1,28 @@ +# Name of the section displayed in the editor UI +name: Jumbotron + +category: headers + +# Definition of the settings: +# A setting type can be one of the following values: text, image, checkbox, link and color. +# Please visit: https://docs.maglev.dev/concepts/setting for more explanation. +settings: +- label: "Title" + id: title + type: text + # html: true + # line_break: true + +- label: "Body" + id: body + type: text + html: true + line_break: true + +# Definition of the blocks. +# You can define as many types of blocks as you want. +blocks: [] + +# By default, in the editor UI, blocks will be listed below the "Content" title. +# The title can be changed with the following property: +# blocks_label: "My list of items" \ No newline at end of file diff --git a/spec/legacy_dummy/app/theme/sections/headers/navbar.yml b/spec/legacy_dummy/app/theme/sections/headers/navbar.yml new file mode 100644 index 00000000..7c5f20a3 --- /dev/null +++ b/spec/legacy_dummy/app/theme/sections/headers/navbar.yml @@ -0,0 +1,38 @@ +# Name of the section displayed in the editor UI +name: Navbar + +category: headers + +site_scoped: true + +# Definition of the settings: +# A setting type can be one of the following values: text, image, checkbox, link and color. +# Please visit: https://docs.maglev.dev/concepts/setting for more explanation. +settings: +- label: "Logo" + id: logo + type: image + default: 'awesome-logo.png' + +# Definition of the blocks. +# You can define as many types of blocks as you want. +blocks: +- name: "Menu item" + type: menu_item + settings: + - label: "Label" + id: label + type: text + # html: true + # line_break: true + default: "Menu item" + - label: "Link" + id: link + type: link + default: "/" + +# By default, in the editor UI, blocks will be listed below the "Content" title. +# The title can be changed with the following property: +blocks_label: "Menu" + +blocks_presentation: "tree" \ No newline at end of file diff --git a/spec/legacy_dummy/app/theme/theme.yml b/spec/legacy_dummy/app/theme/theme.yml new file mode 100644 index 00000000..ae793793 --- /dev/null +++ b/spec/legacy_dummy/app/theme/theme.yml @@ -0,0 +1,32 @@ +id: "simple" +name: "My simple theme" + +section_categories: +- name: Headers + id: headers +- name: Features +- name: Call to Actions + +style_settings: +- label: "Primary color" + id: primary_color + type: color + presets: ["#F87171", "#FBBF24", "#34D399"] + default: "#F87171" +- label: "Font name" + id: font_name + type: text + +pages: +- title: "Home page" + path: "index" + sections: + - type: "jumbotron" + settings: + title: "Let's create the product
your clients
will love." + body: "

NoCoffee, passionated developers,
creators of web applications, mobiles apps and
fancy R&D projects.

" + blocks: [] + - type: "showcase" + settings: + title: "Our projects" + blocks: [] \ No newline at end of file diff --git a/spec/legacy_dummy/app/views/layouts/application.html.erb b/spec/legacy_dummy/app/views/layouts/application.html.erb new file mode 100644 index 00000000..c067a516 --- /dev/null +++ b/spec/legacy_dummy/app/views/layouts/application.html.erb @@ -0,0 +1,11 @@ + + + + <%= content_for?(:page_title) ? yield(:page_title) : 'Dummy' %> + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + + <%= yield %> + + diff --git a/spec/legacy_dummy/app/views/layouts/mailer.html.erb b/spec/legacy_dummy/app/views/layouts/mailer.html.erb new file mode 100644 index 00000000..cbd34d2e --- /dev/null +++ b/spec/legacy_dummy/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/spec/legacy_dummy/app/views/layouts/mailer.text.erb b/spec/legacy_dummy/app/views/layouts/mailer.text.erb new file mode 100644 index 00000000..37f0bddb --- /dev/null +++ b/spec/legacy_dummy/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/spec/legacy_dummy/app/views/products/show.html.erb b/spec/legacy_dummy/app/views/products/show.html.erb new file mode 100644 index 00000000..28252b8b --- /dev/null +++ b/spec/legacy_dummy/app/views/products/show.html.erb @@ -0,0 +1,4 @@ +<%= render_maglev_section :navbar %> +<% content_for(:page_title) { @product.name } %> +

<%= @product.name %>

+

Price: <%= number_to_currency @product.price %>

\ No newline at end of file diff --git a/spec/legacy_dummy/app/views/theme/layout.html.erb b/spec/legacy_dummy/app/views/theme/layout.html.erb new file mode 100644 index 00000000..3a222327 --- /dev/null +++ b/spec/legacy_dummy/app/views/theme/layout.html.erb @@ -0,0 +1,26 @@ + + + + <%= maglev_site.name %> - <%= maglev_page.title %> + + + + + + + + + + <%= render_maglev_alternate_links %> + <%= maglev_live_preview_client_javascript_tag %> + + +
+ <%= render_maglev_sections %> +
+ + \ No newline at end of file diff --git a/spec/legacy_dummy/app/views/theme/sections/features/showcase.html.erb b/spec/legacy_dummy/app/views/theme/sections/features/showcase.html.erb new file mode 100644 index 00000000..b21be33c --- /dev/null +++ b/spec/legacy_dummy/app/views/theme/sections/features/showcase.html.erb @@ -0,0 +1,17 @@ +<%= tag.section class: 'showcase', data: section.tag_data do %> +
+ <%= tag.h2 class: 'display-4', data: section.settings.title.tag_data do %> + <%= raw section.settings.title %> + <% end %> + +
+<% end %> diff --git a/spec/legacy_dummy/app/views/theme/sections/headers/jumbotron.html.erb b/spec/legacy_dummy/app/views/theme/sections/headers/jumbotron.html.erb new file mode 100644 index 00000000..302e0dca --- /dev/null +++ b/spec/legacy_dummy/app/views/theme/sections/headers/jumbotron.html.erb @@ -0,0 +1,6 @@ +
class="jumbotron"> +
+

class="display-3"><%= raw section.settings.title %>

+
><%= raw section.settings.body %>
+
+
\ No newline at end of file diff --git a/spec/legacy_dummy/app/views/theme/sections/headers/navbar.html.erb b/spec/legacy_dummy/app/views/theme/sections/headers/navbar.html.erb new file mode 100644 index 00000000..48e0665b --- /dev/null +++ b/spec/legacy_dummy/app/views/theme/sections/headers/navbar.html.erb @@ -0,0 +1,33 @@ +<%= maglev_section.wrapper_tag class: 'navbar' do %> + <%= link_to maglev_site_link do %> + <%= maglev_section.setting_tag :logo, class: 'brand-logo' %> + <% end %> + + +
+ <% maglev_site.locales.each do |locale| %> + <%= link_to t("lang.#{locale.prefix}"), maglev_alt_link(locale.prefix), class: { 'active': maglev_current_locale?(locale.prefix) } %> + <% end %> +
+<% end %> \ No newline at end of file diff --git a/spec/dummy/babel.config.js b/spec/legacy_dummy/babel.config.js similarity index 100% rename from spec/dummy/babel.config.js rename to spec/legacy_dummy/babel.config.js diff --git a/spec/legacy_dummy/bin/rails b/spec/legacy_dummy/bin/rails new file mode 100755 index 00000000..a31728ab --- /dev/null +++ b/spec/legacy_dummy/bin/rails @@ -0,0 +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/spec/legacy_dummy/bin/rake b/spec/legacy_dummy/bin/rake new file mode 100755 index 00000000..c1999550 --- /dev/null +++ b/spec/legacy_dummy/bin/rake @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/spec/legacy_dummy/bin/setup b/spec/legacy_dummy/bin/setup new file mode 100755 index 00000000..65a6ca72 --- /dev/null +++ b/spec/legacy_dummy/bin/setup @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'fileutils' + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to setup or update your development environment automatically. + # This script is idempotent, so that you can run it at anytime 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 ==" + # 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' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/spec/legacy_dummy/config.ru b/spec/legacy_dummy/config.ru new file mode 100644 index 00000000..842bccc3 --- /dev/null +++ b/spec/legacy_dummy/config.ru @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/spec/legacy_dummy/config/application.rb b/spec/legacy_dummy/config/application.rb new file mode 100644 index 00000000..71c7ff9a --- /dev/null +++ b/spec/legacy_dummy/config/application.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require_relative 'boot' + +require 'rails/all' + +Bundler.require(*Rails.groups) +require 'maglev' + +module Dummy + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + if Rails::VERSION::MAJOR > 6 + config.load_defaults 7.0 + else + config.load_defaults 6.0 + end + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + config.i18n.available_locales = %i[en fr] + end +end diff --git a/spec/legacy_dummy/config/boot.rb b/spec/legacy_dummy/config/boot.rb new file mode 100644 index 00000000..6d2cba07 --- /dev/null +++ b/spec/legacy_dummy/config/boot.rb @@ -0,0 +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__) diff --git a/spec/legacy_dummy/config/cable.yml b/spec/legacy_dummy/config/cable.yml new file mode 100644 index 00000000..98367f89 --- /dev/null +++ b/spec/legacy_dummy/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: dummy_production diff --git a/spec/legacy_dummy/config/database.yml b/spec/legacy_dummy/config/database.yml new file mode 100644 index 00000000..7d6a9c38 --- /dev/null +++ b/spec/legacy_dummy/config/database.yml @@ -0,0 +1,88 @@ +# PostgreSQL. Versions 9.3 and up are supported. +# +# Install the pg driver: +# gem install pg +# On macOS with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On macOS with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + host: <%= ENV.fetch('MAGLEV_APP_DATABASE_HOST') { 'localhost' } %> + username: <%= ENV.fetch('MAGLEV_APP_DATABASE_USERNAME') { nil } %> + password: <%= ENV.fetch('MAGLEV_APP_DATABASE_PASSWORD') { nil } %> + # For details on connection pooling, see Rails configuration guide + # https://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + database: maglev_engine_development + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. + #username: maglev_app + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# 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: maglev_engine_test + +# As with config/credentials.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: maglev_engine_production + username: maglev_engines + password: <%= ENV['MAGLEV_APP_DATABASE_PASSWORD'] %> \ No newline at end of file diff --git a/spec/legacy_dummy/config/environment.rb b/spec/legacy_dummy/config/environment.rb new file mode 100644 index 00000000..d5abe558 --- /dev/null +++ b/spec/legacy_dummy/config/environment.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/spec/legacy_dummy/config/environments/development.rb b/spec/legacy_dummy/config/environments/development.rb new file mode 100644 index 00000000..62979965 --- /dev/null +++ b/spec/legacy_dummy/config/environments/development.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +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 on + # every request. 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 + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # 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 + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = 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 +end diff --git a/spec/legacy_dummy/config/environments/production.rb b/spec/legacy_dummy/config/environments/production.rb new file mode 100644 index 00000000..0eecdbb9 --- /dev/null +++ b/spec/legacy_dummy/config/environments/production.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +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? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.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.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # 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 + + # 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" + + config.action_mailer.perform_caching = false + + # 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 + + # 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 + + # 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 + + # 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/spec/legacy_dummy/config/environments/test.rb b/spec/legacy_dummy/config/environments/test.rb new file mode 100644 index 00000000..151eab39 --- /dev/null +++ b/spec/legacy_dummy/config/environments/test.rb @@ -0,0 +1,57 @@ +# 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 +# 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 = false + config.action_view.cache_template_loading = 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 = if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR > 0 + :none + else + false + end + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + config.active_storage.variant_processor = :mini_magick + + config.action_mailer.perform_caching = false + + # 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 + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations. + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/dummy/config/initializers/application_controller_renderer.rb b/spec/legacy_dummy/config/initializers/application_controller_renderer.rb similarity index 100% rename from spec/dummy/config/initializers/application_controller_renderer.rb rename to spec/legacy_dummy/config/initializers/application_controller_renderer.rb diff --git a/spec/legacy_dummy/config/initializers/assets.rb b/spec/legacy_dummy/config/initializers/assets.rb new file mode 100644 index 00000000..bcafccdd --- /dev/null +++ b/spec/legacy_dummy/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/spec/dummy/config/initializers/backtrace_silencers.rb b/spec/legacy_dummy/config/initializers/backtrace_silencers.rb similarity index 100% rename from spec/dummy/config/initializers/backtrace_silencers.rb rename to spec/legacy_dummy/config/initializers/backtrace_silencers.rb diff --git a/spec/legacy_dummy/config/initializers/content_security_policy.rb b/spec/legacy_dummy/config/initializers/content_security_policy.rb new file mode 100644 index 00000000..87fd451f --- /dev/null +++ b/spec/legacy_dummy/config/initializers/content_security_policy.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# 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/spec/dummy/config/initializers/cookies_serializer.rb b/spec/legacy_dummy/config/initializers/cookies_serializer.rb similarity index 100% rename from spec/dummy/config/initializers/cookies_serializer.rb rename to spec/legacy_dummy/config/initializers/cookies_serializer.rb diff --git a/spec/legacy_dummy/config/initializers/filter_parameter_logging.rb b/spec/legacy_dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..7a4f47b4 --- /dev/null +++ b/spec/legacy_dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +# 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 += [:password] diff --git a/spec/legacy_dummy/config/initializers/inflections.rb b/spec/legacy_dummy/config/initializers/inflections.rb new file mode 100644 index 00000000..1f5f9d63 --- /dev/null +++ b/spec/legacy_dummy/config/initializers/inflections.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# 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/spec/legacy_dummy/config/initializers/maglev.rb b/spec/legacy_dummy/config/initializers/maglev.rb new file mode 100644 index 00000000..ddaf72c6 --- /dev/null +++ b/spec/legacy_dummy/config/initializers/maglev.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +Maglev.configure do |config| + config.uploader = :active_storage + + config.collections = { + products: { + model: 'Product', + fields: { + label: :name, + image: :thumbnail_url + } + } + } + + config.default_site_locales = [{ label: 'English', prefix: 'en' }, { label: 'French', prefix: 'fr' }] + + config.static_pages = [ + { + title: { en: 'Products', fr: 'Produits' }, + path: { en: 'products', fr: 'fr/produits' } + }, + { + title: { en: 'Authentication', fr: 'Authentification' }, + path: { en: 'sign-in', fr: 'fr/se-connecter' } + } + ] + + config.reserved_paths = %w[products sign-in search posts/*] +end diff --git a/spec/dummy/config/initializers/mime_types.rb b/spec/legacy_dummy/config/initializers/mime_types.rb similarity index 100% rename from spec/dummy/config/initializers/mime_types.rb rename to spec/legacy_dummy/config/initializers/mime_types.rb diff --git a/spec/dummy/config/initializers/wrap_parameters.rb b/spec/legacy_dummy/config/initializers/wrap_parameters.rb similarity index 100% rename from spec/dummy/config/initializers/wrap_parameters.rb rename to spec/legacy_dummy/config/initializers/wrap_parameters.rb diff --git a/spec/legacy_dummy/config/locales/en.yml b/spec/legacy_dummy/config/locales/en.yml new file mode 100644 index 00000000..9d47a02d --- /dev/null +++ b/spec/legacy_dummy/config/locales/en.yml @@ -0,0 +1,36 @@ +# 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" + lang: + en: "English" + fr: "Français" diff --git a/spec/legacy_dummy/config/locales/fr.yml b/spec/legacy_dummy/config/locales/fr.yml new file mode 100644 index 00000000..9d56d1db --- /dev/null +++ b/spec/legacy_dummy/config/locales/fr.yml @@ -0,0 +1,5 @@ +fr: + hello: "Bonjour le monde" + lang: + en: "English" + fr: "Français" diff --git a/spec/legacy_dummy/config/puma.rb b/spec/legacy_dummy/config/puma.rb new file mode 100644 index 00000000..69e2645f --- /dev/null +++ b/spec/legacy_dummy/config/puma.rb @@ -0,0 +1,40 @@ +# 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. +# +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 `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 `rails restart` command. +plugin :tmp_restart diff --git a/spec/legacy_dummy/config/routes.rb b/spec/legacy_dummy/config/routes.rb new file mode 100644 index 00000000..7a5213e3 --- /dev/null +++ b/spec/legacy_dummy/config/routes.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +Rails.application.routes.draw do + mount Maglev::Engine, as: :maglev, at: '/maglev' + + direct :cdn_image do |model, options| + if model.respond_to?(:signed_id) + route_for( + :rails_service_blob_proxy, + model.signed_id, + model.filename, + options.merge(host: ENV['CDN_HOST'] || 'http://example.local') + ) + else + signed_blob_id = model.blob.signed_id + variation_key = model.variation.key + filename = model.blob.filename + + route_for( + :rails_blob_representation_proxy, + signed_blob_id, + variation_key, + filename, + options.merge(host: ENV['CDN_HOST'] || 'http://example.local') + ) + end + end + + resources :products, only: [:show] + + root to: 'maglev/page_preview#index', defaults: { path: 'index' } + + get '/nocoffee_site', to: redirect('https://www.nocoffee.fr'), as: :nocoffee + + get '/sitemap', to: 'maglev/sitemap#index', defaults: { format: 'xml' } + + get '(*path)', to: 'maglev/page_preview#index', defaults: { path: 'index' }, + constraints: Maglev::PreviewConstraint.new +end diff --git a/spec/dummy/config/spring.rb b/spec/legacy_dummy/config/spring.rb similarity index 100% rename from spec/dummy/config/spring.rb rename to spec/legacy_dummy/config/spring.rb diff --git a/spec/legacy_dummy/config/storage.yml b/spec/legacy_dummy/config/storage.yml new file mode 100644 index 00000000..d32f76e8 --- /dev/null +++ b/spec/legacy_dummy/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/spec/legacy_dummy/db/migrate/20200824091231_create_accounts.rb b/spec/legacy_dummy/db/migrate/20200824091231_create_accounts.rb new file mode 100644 index 00000000..ce419d43 --- /dev/null +++ b/spec/legacy_dummy/db/migrate/20200824091231_create_accounts.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class CreateAccounts < ActiveRecord::Migration[6.0] + def change + create_table :accounts do |t| + t.string :email + t.string :password_digest + + t.timestamps + end + end +end diff --git a/spec/legacy_dummy/db/migrate/20201206122731_create_active_storage_tables.active_storage.rb b/spec/legacy_dummy/db/migrate/20201206122731_create_active_storage_tables.active_storage.rb new file mode 100644 index 00000000..8658881e --- /dev/null +++ b/spec/legacy_dummy/db/migrate/20201206122731_create_active_storage_tables.active_storage.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# This migration comes from active_storage (originally 20170806125915) +# rubocop:disable Metrics/MethodLength +class CreateActiveStorageTables < ActiveRecord::Migration[5.2] + def change + create_table :active_storage_blobs do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.bigint :byte_size, null: false + t.string :checksum, null: false + t.datetime :created_at, null: false + + t.index [:key], unique: true + end + + create_table :active_storage_attachments do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false + t.references :blob, null: false + + t.datetime :created_at, null: false + + t.index %i[record_type record_id name blob_id], name: 'index_active_storage_attachments_uniqueness', unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end +# rubocop:enable Metrics/MethodLength diff --git a/spec/legacy_dummy/db/migrate/20210129103813_add_service_name_to_active_storage_blobs.active_storage.rb b/spec/legacy_dummy/db/migrate/20210129103813_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 00000000..c297f7ba --- /dev/null +++ b/spec/legacy_dummy/db/migrate/20210129103813_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# rubocop:disable Style/GuardClause, Lint/AssignmentInCondition, Rails/SkipsModelValidations +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + remove_column :active_storage_blobs, :service_name + end +end +# rubocop:enable Style/GuardClause, Lint/AssignmentInCondition, Rails/SkipsModelValidations diff --git a/spec/legacy_dummy/db/migrate/20210129103814_create_active_storage_variant_records.active_storage.rb b/spec/legacy_dummy/db/migrate/20210129103814_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 00000000..ce8fff1d --- /dev/null +++ b/spec/legacy_dummy/db/migrate/20210129103814_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + create_table :active_storage_variant_records do |t| + t.belongs_to :blob, null: false, index: false + t.string :variation_digest, null: false + + t.index %i[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/spec/legacy_dummy/db/migrate/20210819081156_create_products.rb b/spec/legacy_dummy/db/migrate/20210819081156_create_products.rb new file mode 100644 index 00000000..a2d961bf --- /dev/null +++ b/spec/legacy_dummy/db/migrate/20210819081156_create_products.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateProducts < ActiveRecord::Migration[6.1] + def change + create_table :products do |t| + t.string :name + t.string :sku, unique: true + t.float :price + t.boolean :sold_out, default: false + + t.timestamps + end + end +end diff --git a/spec/legacy_dummy/db/schema.rb b/spec/legacy_dummy/db/schema.rb new file mode 100644 index 00000000..8d56c8e4 --- /dev/null +++ b/spec/legacy_dummy/db/schema.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true + +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20_220_612_092_235) do + # These are extensions that must be enabled in order to support this database + enable_extension 'plpgsql' + + create_table 'accounts', force: :cascade do |t| + t.string 'email' + t.string 'password_digest' + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + end + + create_table 'active_storage_attachments', force: :cascade do |t| + t.string 'name', null: false + t.string 'record_type', null: false + t.bigint 'record_id', null: false + t.bigint 'blob_id', null: false + t.datetime 'created_at', null: false + t.index ['blob_id'], name: 'index_active_storage_attachments_on_blob_id' + t.index %w[record_type record_id name blob_id], name: 'index_active_storage_attachments_uniqueness', + unique: true + end + + create_table 'active_storage_blobs', force: :cascade do |t| + t.string 'key', null: false + t.string 'filename', null: false + t.string 'content_type' + t.text 'metadata' + t.bigint 'byte_size', null: false + t.string 'checksum', null: false + t.datetime 'created_at', null: false + t.string 'service_name', null: false + t.index ['key'], name: 'index_active_storage_blobs_on_key', unique: true + end + + create_table 'active_storage_variant_records', force: :cascade do |t| + t.bigint 'blob_id', null: false + t.string 'variation_digest', null: false + t.index %w[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true + end + + create_table 'maglev_assets', force: :cascade do |t| + t.string 'filename' + t.string 'content_type' + t.integer 'width' + t.integer 'height' + t.integer 'byte_size' + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + end + + create_table 'maglev_page_paths', force: :cascade do |t| + t.bigint 'maglev_page_id' + t.string 'locale', null: false + t.string 'value', null: false + t.boolean 'canonical', default: true + t.index %w[canonical locale value], name: 'canonical_speed' + t.index %w[canonical maglev_page_id locale], name: 'scoped_canonical_speed' + t.index ['maglev_page_id'], name: 'index_maglev_page_paths_on_maglev_page_id' + end + + create_table 'maglev_pages', force: :cascade do |t| + t.boolean 'visible', default: true + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + t.jsonb 'title_translations', default: {} + t.jsonb 'seo_title_translations', default: {} + t.jsonb 'meta_description_translations', default: {} + t.jsonb 'sections_translations', default: {} + t.integer 'lock_version' + t.jsonb 'og_title_translations', default: {} + t.jsonb 'og_description_translations', default: {} + t.jsonb 'og_image_url_translations', default: {} + end + + create_table 'maglev_sites', force: :cascade do |t| + t.string 'name' + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + t.jsonb 'navigation', default: [] + t.jsonb 'locales', default: [] + t.jsonb 'sections_translations', default: {} + t.integer 'lock_version' + t.string 'siteable_type' + t.bigint 'siteable_id' + t.string 'handle' + t.string 'theme_id' + t.string 'domain' + t.jsonb 'style', default: [] + t.index %w[siteable_type siteable_id], name: 'index_maglev_sites_on_siteable' + end + + create_table 'products', force: :cascade do |t| + t.string 'name' + t.string 'sku' + t.float 'price' + t.boolean 'sold_out', default: false + t.datetime 'created_at', precision: 6, null: false + t.datetime 'updated_at', precision: 6, null: false + end + + add_foreign_key 'active_storage_attachments', 'active_storage_blobs', column: 'blob_id' + add_foreign_key 'active_storage_variant_records', 'active_storage_blobs', column: 'blob_id' +end diff --git a/spec/dummy/public/favicon.ico b/spec/legacy_dummy/lib/assets/.keep similarity index 100% rename from spec/dummy/public/favicon.ico rename to spec/legacy_dummy/lib/assets/.keep diff --git a/spec/dummy/lib/tasks/auto_annotate_models.rake b/spec/legacy_dummy/lib/tasks/auto_annotate_models.rake similarity index 100% rename from spec/dummy/lib/tasks/auto_annotate_models.rake rename to spec/legacy_dummy/lib/tasks/auto_annotate_models.rake diff --git a/spec/legacy_dummy/log/.keep b/spec/legacy_dummy/log/.keep new file mode 100644 index 00000000..e69de29b diff --git a/spec/dummy/postcss.config.js b/spec/legacy_dummy/postcss.config.js similarity index 100% rename from spec/dummy/postcss.config.js rename to spec/legacy_dummy/postcss.config.js diff --git a/spec/legacy_dummy/public/404.html b/spec/legacy_dummy/public/404.html new file mode 100644 index 00000000..2be3af26 --- /dev/null +++ b/spec/legacy_dummy/public/404.html @@ -0,0 +1,67 @@ + + + + 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.

+
+ + diff --git a/spec/legacy_dummy/public/422.html b/spec/legacy_dummy/public/422.html new file mode 100644 index 00000000..c08eac0d --- /dev/null +++ b/spec/legacy_dummy/public/422.html @@ -0,0 +1,67 @@ + + + + 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.

+
+ + diff --git a/spec/legacy_dummy/public/500.html b/spec/legacy_dummy/public/500.html new file mode 100644 index 00000000..78a030af --- /dev/null +++ b/spec/legacy_dummy/public/500.html @@ -0,0 +1,66 @@ + + + + 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.

+
+ + diff --git a/spec/legacy_dummy/public/apple-touch-icon-precomposed.png b/spec/legacy_dummy/public/apple-touch-icon-precomposed.png new file mode 100644 index 00000000..e69de29b diff --git a/spec/legacy_dummy/public/apple-touch-icon.png b/spec/legacy_dummy/public/apple-touch-icon.png new file mode 100644 index 00000000..e69de29b diff --git a/spec/legacy_dummy/public/favicon.ico b/spec/legacy_dummy/public/favicon.ico new file mode 100644 index 00000000..e69de29b diff --git a/spec/legacy_dummy/public/sometheme/jumbotron.png b/spec/legacy_dummy/public/sometheme/jumbotron.png new file mode 100644 index 00000000..6cc84351 --- /dev/null +++ b/spec/legacy_dummy/public/sometheme/jumbotron.png @@ -0,0 +1 @@ +n‡r¡ûaz™à~)^ \ No newline at end of file diff --git a/spec/legacy_dummy/public/theme/jumbotron.jpg b/spec/legacy_dummy/public/theme/jumbotron.jpg new file mode 100644 index 00000000..0e1d05e1 Binary files /dev/null and b/spec/legacy_dummy/public/theme/jumbotron.jpg differ diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 0d9d79ab..c2f2ba8c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -8,7 +8,14 @@ ENV['RAILS_ENV'] ||= 'test' ENGINE_ROOT = File.join(File.dirname(__FILE__), '../') # require File.expand_path('../config/environment', __dir__) -require_relative './dummy/config/environment' + +require 'rails/version' +if Rails::VERSION::MAJOR < 8 + require_relative './legacy_dummy/config/environment' +else + require_relative './dummy/config/environment' +end + # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' @@ -46,7 +53,7 @@ end RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR > 0 + if Rails::VERSION::MAJOR >= 8 || (Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR > 0) config.fixture_paths = [File.join(File.dirname(__FILE__), 'fixtures')] else config.fixture_path = File.join(File.dirname(__FILE__), 'fixtures') diff --git a/spec/requests/maglev/api/assets_spec.rb b/spec/requests/maglev/api/assets_spec.rb index 2c85e656..3f952068 100644 --- a/spec/requests/maglev/api/assets_spec.rb +++ b/spec/requests/maglev/api/assets_spec.rb @@ -83,7 +83,8 @@ it 'returns errors if asset is missing' do post '/maglev/api/assets' expect(json_response['errors'].size).to eq(1) - expect(json_response['errors'].first).to match('param is missing or the value is empty: asset') + expect(json_response['errors'].first).to eq('param is missing or the value is empty: asset') + .or eq('param is missing or the value is empty or invalid: asset') expect(response).to have_http_status(:bad_request) end end diff --git a/spec/requests/products_spec.rb b/spec/requests/products_spec.rb index 77cc749c..cbde3495 100644 --- a/spec/requests/products_spec.rb +++ b/spec/requests/products_spec.rb @@ -19,41 +19,13 @@ it 'renders a page of the main app' do get "/products/#{product.id}" - expect(pretty_html(response.body)) - .to eq(<<~HTML.strip - - - - My awesome product - - - - -

My awesome product

-

Price: $42.00

- - - HTML - ) + html_response = pretty_html(response.body) + expect(html_response).to include('My awesome product') + # rubocop:disable Layout/LineLength + .and include('