diff --git a/.gitattributes b/.gitattributes index 31eeee0..5168571 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,5 +3,8 @@ # Mark the database schema as having been generated. db/schema.rb linguist-generated +# Mark the yarn lockfile as having been generated. +yarn.lock linguist-generated + # Mark any vendored files as having been vendored. vendor/* linguist-vendored diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 0d7790f..171e535 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -47,6 +47,14 @@ jobs: bundle exec rails db:create bundle exec rails db:schema:load + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: 16.20.0 + + - name: Install yarn dependencies and precompile assets + run: bundle exec rails assets:precompile + - name: RSpec tests run: bundle exec rspec --color @@ -78,5 +86,8 @@ jobs: - name: StandardRB run: bundle exec standardrb --format simple - - name: JavaScript Audit - run: bin/importmap audit + - name: Install yarn dependencies + run: yarn install --frozen-lockfile + + - name: Yarn audit + run: yarn run improved-yarn-audit --ignore-dev-deps diff --git a/.gitignore b/.gitignore index f293bf8..9606af5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,9 @@ # Ignore uploaded files in development. /storage/* !/storage/.keep -/tmp/storage/* -!/tmp/storage/ -!/tmp/storage/.keep /public/assets +.byebug_history # Ignore master key for decrypting credentials and more. /config/master.key @@ -31,3 +29,10 @@ /.idea /.env.* /coverage + +/public/packs +/public/packs-test +/node_modules +/yarn-error.log +yarn-debug.log* +.yarn-integrity diff --git a/.iyarc b/.iyarc new file mode 100644 index 0000000..114cbd1 --- /dev/null +++ b/.iyarc @@ -0,0 +1,10 @@ +# No dependency path exists to fix this vulnerability currently + +# glob-parent +GHSA-ww39-953v-wcq6 + +# nth-check +GHSA-rp65-9cf3-cjxr + +# semver +GHSA-c2qf-rxjj-qqgw diff --git a/Dockerfile b/Dockerfile index f5cb7d3..d61f90b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ WORKDIR /home/webapp/app RUN apk upgrade --no-cache # Install rails/app dependencies -RUN apk --no-cache add libc6-compat git postgresql-libs tzdata +RUN apk --no-cache add libc6-compat git postgresql-libs tzdata nodejs=~16.20 yarn # Copy dependency definitions and lock files COPY Gemfile Gemfile.lock ./ diff --git a/Gemfile b/Gemfile index a65f413..817fa92 100644 --- a/Gemfile +++ b/Gemfile @@ -7,76 +7,63 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.0.6" -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.0.7" - -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" - +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem "rails", "~> 6.1.3" # Use sqlite3 as the database for Active Record -# gem "sqlite3", "~> 1.4" - -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", "~> 5.0" - -# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" - -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" - -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" - -# Build JSON APIs with ease [https://github.com/rails/jbuilder] -gem "jbuilder" - +# gem 'sqlite3', '~> 1.4' +# Use Puma as the app server +gem "puma", "~> 5.6" +# Use SCSS for stylesheets +gem "sass-rails", ">= 6" +# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker +gem "webpacker", "~> 5.0" +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +# gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem "jbuilder", "~> 2.7" # Use Redis adapter to run Action Cable in production -# gem "redis", "~> 4.0" - -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" +# gem 'redis', '~> 4.0' +# Use Active Model has_secure_password +# gem 'bcrypt', '~> 3.1.7' -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby] +# Use Active Storage variant +# gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false - -# Use Sass to process CSS -gem "sassc-rails" - -# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] -# gem "image_processing", "~> 1.2" +gem "bootsnap", ">= 1.4.4", require: false group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[mri mingw x64_mingw] + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem "byebug", platforms: [:mri, :mingw, :x64_mingw] end group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" - - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] - # gem "rack-mini-profiler" - - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem "web-console", ">= 4.1.0" + # Display performance information such as SQL time and flame graphs for each request in your browser. + # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md + gem "rack-mini-profiler", "~> 2.0" + gem "listen", "~> 3.3" + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem "spring" + gem "spring-watcher-listen", "~> 2.0.0" end group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" + # Adds support for Capybara system testing and selenium driver + gem "capybara", ">= 3.26" gem "selenium-webdriver" - # gem "webdrivers" + # Easy installation and use of web drivers to run system tests with browsers + gem "webdrivers" + gem "simplecov-cobertura" # Codecov, CI only end +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] + gem "pg" +gem "active_admin_flat_skin" gem "activeadmin" gem "activeadmin_addons" gem "adobe-campaign", "~> 0.2" @@ -96,14 +83,12 @@ gem "omniauth-oktaoauth", github: "CruGlobal/omniauth-oktaoauth" gem "omniauth-rails_csrf_protection" gem "ougai", "~> 1.7" gem "rack-cors" -gem "redis", "< 5.0" gem "redis-actionpack" gem "rollbar" -gem "sidekiq", "~> 6.5.10" gem "sidekiq-failures" gem "sidekiq-unique-jobs" gem "standardrb" -gem "strip_attributes", "~> 1.11" +gem "strip_attributes", "~> 1.11.0" group :development, :test do gem "database_cleaner-active_record" @@ -111,7 +96,6 @@ group :development, :test do gem "factory_bot_rails" gem "faker" gem "rspec-rails" - gem "simplecov-cobertura", require: false gem "webmock" gem "pry-byebug" end diff --git a/Gemfile.lock b/Gemfile.lock index 1d7bb00..413b68a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,89 +15,83 @@ GEM GEM remote: https://rubygems.org/ specs: - actioncable (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + actioncable (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.7.2) - actionpack (= 7.0.7.2) - activejob (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionmailbox (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.7.2) - actionpack (= 7.0.7.2) - actionview (= 7.0.7.2) - activejob (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionmailer (6.1.7.6) + actionpack (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.7.2) - actionview (= 7.0.7.2) - activesupport (= 7.0.7.2) - rack (~> 2.0, >= 2.2.4) + actionpack (6.1.7.6) + actionview (= 6.1.7.6) + activesupport (= 6.1.7.6) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.7.2) - actionpack (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) - globalid (>= 0.6.0) + actiontext (6.1.7.6) + actionpack (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) nokogiri (>= 1.8.5) - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) + active_admin_flat_skin (0.1.2) active_material (1.5.2) - activeadmin (3.1.0) + activeadmin (2.9.0) arbre (~> 1.2, >= 1.2.1) - formtastic (>= 3.1) - formtastic_i18n (>= 0.4) + formtastic (>= 3.1, < 5.0) + formtastic_i18n (~> 0.4) inherited_resources (~> 1.7) - jquery-rails (>= 4.2) - kaminari (>= 1.2.1) - railties (>= 6.1) - ransack (>= 4.0) - activeadmin_addons (1.10.1) + jquery-rails (~> 4.2) + kaminari (~> 1.0, >= 1.2.1) + railties (>= 5.2, < 6.2) + ransack (~> 2.1, >= 2.1.1) + activeadmin_addons (1.7.1) active_material railties - redcarpet - require_all - sassc - sassc-rails + require_all (~> 1.5) + sass + select2-rails (~> 4.0) xdan-datetimepicker-rails (~> 2.5.1) - activejob (7.0.7.2) - activesupport (= 7.0.7.2) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (7.0.7.2) - activesupport (= 7.0.7.2) - activerecord (7.0.7.2) - activemodel (= 7.0.7.2) - activesupport (= 7.0.7.2) - activestorage (7.0.7.2) - actionpack (= 7.0.7.2) - activejob (= 7.0.7.2) - activerecord (= 7.0.7.2) - activesupport (= 7.0.7.2) + activemodel (6.1.7.6) + activesupport (= 6.1.7.6) + activerecord (6.1.7.6) + activemodel (= 6.1.7.6) + activesupport (= 6.1.7.6) + activestorage (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activesupport (= 6.1.7.6) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.7.2) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) adobe-campaign (0.3.2) @@ -105,13 +99,12 @@ GEM jwt (~> 1.0) rails (>= 3.1) rest-client (>= 1.6.0) - arbre (1.7.0) - activesupport (>= 3.0.0) - ruby2_keywords (>= 0.0.2) + arbre (1.4.0) + activesupport (>= 3.0.0, < 6.2) + ruby2_keywords (>= 0.0.2, < 1.0) ast (2.4.2) awesome_print (1.9.2) - base64 (0.2.0) - bcrypt (3.1.20) + bcrypt (3.1.18) bindex (0.8.1) bootsnap (1.13.0) msgpack (~> 1.2) @@ -126,18 +119,18 @@ GEM bundler (>= 1.2.0, < 3) thor (~> 1.0) byebug (9.1.0) - capybara (3.39.2) + capybara (3.35.3) addressable - matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (3.0.0) coderay (1.1.2) concurrent-ruby (1.2.2) - connection_pool (2.4.1) + connection_pool (2.2.5) countries (3.0.1) i18n_data (~> 0.10.0) sixarm_ruby_unaccent (~> 1.1) @@ -156,10 +149,7 @@ GEM libddwaf (~> 1.3.0.2.0) msgpack debase-ruby_core_source (0.10.16) - debug (1.8.0) - irb (>= 1.5.0) - reline (>= 0.3.1) - devise (4.9.3) + devise (4.8.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) @@ -182,16 +172,15 @@ GEM railties (>= 3.0.0) faker (2.23.0) i18n (>= 1.8.11, < 2) - faraday (2.7.12) - base64 + faraday (2.6.0) faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.2) - ffi (1.15.5) - font-awesome-rails (4.7.0.8) - railties (>= 3.2, < 8.0) - formtastic (5.0.0) - actionpack (>= 6.0.0) + faraday-net_http (3.0.1) + ffi (1.15.1) + font-awesome-rails (4.7.0.7) + railties (>= 3.2, < 7) + formtastic (4.0.0) + actionpack (>= 5.2.0) formtastic_i18n (0.7.0) global_registry (1.5.1) activesupport @@ -202,7 +191,7 @@ GEM retryable-rb (~> 1.1) globalid (1.2.1) activesupport (>= 6.1) - has_scope (0.8.2) + has_scope (0.8.0) actionpack (>= 5.2) activesupport (>= 5.2) hashdiff (0.3.7) @@ -213,45 +202,42 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) i18n_data (0.10.0) - importmap-rails (1.2.1) - actionpack (>= 6.0.0) - railties (>= 6.0.0) - inherited_resources (1.14.0) - actionpack (>= 6.0) - has_scope (>= 0.6) - railties (>= 6.0) - responders (>= 2) - io-console (0.6.0) - irb (1.7.4) - reline (>= 0.3.6) + inherited_resources (1.13.0) + actionpack (>= 5.2, < 6.2) + has_scope (~> 0.6) + railties (>= 5.2, < 6.2) + responders (>= 2, < 4) jbuilder (2.10.0) activesupport (>= 5.0.0) - jquery-rails (4.6.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jwt (1.5.6) - kaminari (1.2.2) + kaminari (1.2.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.2) - kaminari-activerecord (= 1.2.2) - kaminari-core (= 1.2.2) - kaminari-actionview (1.2.2) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) actionview - kaminari-core (= 1.2.2) - kaminari-activerecord (1.2.2) + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) activerecord - kaminari-core (= 1.2.2) - kaminari-core (1.2.2) + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) libdatadog (0.7.0.1.1) libddwaf (1.3.0.2.0) ffi (~> 1.0) + listen (3.5.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) lograge (0.11.1) actionpack (>= 4) activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.22.0) + loofah (2.21.3) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -260,13 +246,12 @@ GEM net-pop net-smtp marcel (1.0.2) - matrix (0.4.2) method_source (0.9.2) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) mini_mime (1.1.5) - mini_portile2 (2.8.5) + mini_portile2 (2.8.4) minitest (5.20.0) msgpack (1.5.6) multi_xml (0.6.0) @@ -281,7 +266,7 @@ GEM net-protocol netrc (0.11.0) nio4r (2.5.9) - nokogiri (1.15.5) + nokogiri (1.15.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth2 (2.0.9) @@ -293,16 +278,15 @@ GEM version_gem (~> 1.1) oj (3.7.12) oj_mimic_json (1.0.1) - omniauth (2.1.1) + omniauth (1.9.2) hashie (>= 3.4.6) - rack (>= 2.2.3) - rack-protection - omniauth-oauth2 (1.8.0) + rack (>= 1.6.2, < 3) + omniauth-oauth2 (1.7.3) oauth2 (>= 1.4, < 3) - omniauth (~> 2.0) - omniauth-rails_csrf_protection (1.0.1) + omniauth (>= 1.9, < 3) + omniauth-rails_csrf_protection (0.1.2) actionpack (>= 4.2) - omniauth (~> 2.0) + omniauth (>= 1.3.1) orm_adapter (0.5.0) ougai (1.7.1) oj (~> 3.4) @@ -319,28 +303,31 @@ GEM public_suffix (4.0.6) puma (5.6.7) nio4r (~> 2.0) - racc (1.7.3) + racc (1.7.1) rack (2.2.8) rack-cors (1.1.1) rack (>= 2.0.0) - rack-protection (3.1.0) - rack (~> 2.2, >= 2.2.4) + rack-mini-profiler (2.3.2) + rack (>= 1.2.0) + rack-proxy (0.6.5) + rack rack-test (2.1.0) rack (>= 1.3) - rails (7.0.7.2) - actioncable (= 7.0.7.2) - actionmailbox (= 7.0.7.2) - actionmailer (= 7.0.7.2) - actionpack (= 7.0.7.2) - actiontext (= 7.0.7.2) - actionview (= 7.0.7.2) - activejob (= 7.0.7.2) - activemodel (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + rails (6.1.7.6) + actioncable (= 6.1.7.6) + actionmailbox (= 6.1.7.6) + actionmailer (= 6.1.7.6) + actionpack (= 6.1.7.6) + actiontext (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activemodel (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) bundler (>= 1.15.0) - railties (= 7.0.7.2) + railties (= 6.1.7.6) + sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -348,46 +335,45 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source rake (>= 12.2) thor (~> 1.0) - zeitwerk (~> 2.5) rainbow (3.0.0) - rake (13.1.0) - ransack (4.1.1) - activerecord (>= 6.1.5) - activesupport (>= 6.1.5) + rake (13.0.6) + ransack (2.4.2) + activerecord (>= 5.2.4) + activesupport (>= 5.2.4) i18n - redcarpet (3.6.0) - redis (4.8.1) - redis-actionpack (5.3.0) - actionpack (>= 5, < 8) + rb-fsevent (0.11.0) + rb-inotify (0.10.1) + ffi (~> 1.0) + redis (4.7.1) + redis-actionpack (5.2.0) + actionpack (>= 5, < 7) redis-rack (>= 2.1.0, < 3) redis-store (>= 1.1.0, < 2) - redis-rack (2.1.4) + redis-rack (2.1.2) rack (>= 2.0.8, < 3) redis-store (>= 1.2, < 2) - redis-store (1.9.2) - redis (>= 4, < 6) + redis-store (1.9.0) + redis (>= 4, < 5) regexp_parser (2.1.1) - reline (0.3.8) - io-console (~> 0.5) request_store (1.4.1) rack (>= 1.4) - require_all (3.0.0) - responders (3.1.1) - actionpack (>= 5.2) - railties (>= 5.2) + require_all (1.5.0) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retryable-rb (1.1.0) - rexml (3.2.6) + rexml (3.2.5) rollbar (3.4.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) @@ -422,8 +408,15 @@ GEM rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) - rubyzip (2.3.2) + rubyzip (2.3.0) safe_yaml (1.0.4) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) @@ -432,14 +425,15 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (4.11.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sidekiq (6.5.12) - connection_pool (>= 2.2.5, < 3) + select2-rails (4.0.13) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + semantic_range (3.0.0) + sidekiq (6.5.1) + connection_pool (>= 2.2.2) rack (~> 2.0) - redis (>= 4.5.0, < 5) + redis (>= 4.2.0) sidekiq-failures (1.0.1) sidekiq (>= 4.0.0) sidekiq-unique-jobs (7.1.25) @@ -460,6 +454,11 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) + spring (2.0.2) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -472,17 +471,11 @@ GEM rubocop-performance (= 1.11.4) standardrb (1.0.0) standard - stimulus-rails (1.2.2) - railties (>= 6.0.0) - strip_attributes (1.13.0) - activemodel (>= 3.0, < 8.0) - thor (1.3.0) - tilt (2.2.0) + strip_attributes (1.11.0) + activemodel (>= 3.0, < 7.0) + thor (1.2.2) + tilt (2.0.10) timeout (0.4.0) - turbo-rails (1.4.0) - actionpack (>= 6.0.0) - activejob (>= 6.0.0) - railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unf (0.1.4) @@ -491,7 +484,7 @@ GEM unicode-display_width (2.0.0) unicode_utils (1.4.0) uri (0.10.3) - version_gem (1.1.3) + version_gem (1.1.1) warden (1.2.9) rack (>= 2.0.9) web-console (4.1.0) @@ -499,11 +492,19 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) + webdrivers (4.3.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (>= 3.0, < 4.0) webmock (3.4.2) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - websocket (1.2.9) + webpacker (5.4.0) + activesupport (>= 5.2) + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -512,24 +513,25 @@ GEM rails (>= 3.2.16) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.12) + zeitwerk (2.6.11) PLATFORMS ruby DEPENDENCIES + active_admin_flat_skin activeadmin activeadmin_addons adobe-campaign (~> 0.2) awesome_print - bootsnap + bootsnap (>= 1.4.4) brakeman bundle-audit - capybara + byebug + capybara (>= 3.26) countries database_cleaner-active_record ddtrace (~> 1.4) - debug devise dogstatsd-ruby (~> 5.3) dotenv-rails @@ -537,8 +539,8 @@ DEPENDENCIES faker font-awesome-rails global_registry (~> 1.5) - importmap-rails - jbuilder + jbuilder (~> 2.7) + listen (~> 3.3) lograge loofah (>= 2.2.3) nokogiri (>= 1.8.5) @@ -547,29 +549,29 @@ DEPENDENCIES ougai (~> 1.7) pg pry-byebug - puma (~> 5.0) + puma (~> 5.6) rack-cors - rails (~> 7.0.7) - redis (< 5.0) + rack-mini-profiler (~> 2.0) + rails (~> 6.1.3) redis-actionpack rollbar rspec-rails - sassc-rails + sass-rails (>= 6) selenium-webdriver - sidekiq (~> 6.5.10) sidekiq-failures sidekiq-pro! sidekiq-unique-jobs simplecov-cobertura - sprockets-rails + spring + spring-watcher-listen (~> 2.0.0) standardrb - stimulus-rails - strip_attributes (~> 1.11) - turbo-rails + strip_attributes (~> 1.11.0) tzinfo-data uri (~> 0.10.3) - web-console + web-console (>= 4.1.0) + webdrivers webmock + webpacker (~> 5.0) RUBY VERSION ruby 3.0.6p216 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 957b4d3..48e139d 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,3 +1 @@ -//= link_directory ../stylesheets .scss -//= link_tree ../../javascript .js -//= link_tree ../../../vendor/javascript .js +//= link_directory ../javascripts .js diff --git a/app/assets/javascripts/active_admin.js b/app/assets/javascripts/active_admin.js new file mode 120000 index 0000000..f2facb1 --- /dev/null +++ b/app/assets/javascripts/active_admin.js @@ -0,0 +1 @@ +../../javascript/active_admin_custom.js \ No newline at end of file diff --git a/app/assets/stylesheets/active_admin.scss b/app/assets/stylesheets/active_admin.scss index 9d24842..611a25c 100644 --- a/app/assets/stylesheets/active_admin.scss +++ b/app/assets/stylesheets/active_admin.scss @@ -12,6 +12,7 @@ $am-theme-primary: #342e48; @import 'activeadmin_addons/all'; @import "active_admin/mixins"; @import "active_admin/base"; +@import "active_admin_flat_skin"; @import "font-awesome"; // Overriding any non-variable SASS must be done after the fact. diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss deleted file mode 100644 index c99326d..0000000 --- a/app/assets/stylesheets/print.scss +++ /dev/null @@ -1,2 +0,0 @@ -/* Active Admin Print Stylesheet */ -@import "print"; diff --git a/app/javascript/custom/active_admin_custom.js b/app/javascript/active_admin_custom.js similarity index 95% rename from app/javascript/custom/active_admin_custom.js rename to app/javascript/active_admin_custom.js index 479b6d1..7695466 100644 --- a/app/javascript/custom/active_admin_custom.js +++ b/app/javascript/active_admin_custom.js @@ -5,6 +5,7 @@ */ //= require active_admin/base //= require activeadmin_addons/all +//= require active_admin_flat_skin $(document).on('change', '.form_form_fields_select', function() { var options = $(this).parents('ol:first').find('.has_many_container.campaign_options'); @@ -20,4 +21,4 @@ $(document).on('ready page:load', function() { return $($(this).data('toggle')).toggle($(this).prop('checked')); }); return $('[data-field-type="campaign"]:selected').parents('ol:first').find('.has_many_container.campaign_options').show(); -}); +}); \ No newline at end of file diff --git a/app/javascript/application.js b/app/javascript/application.js deleted file mode 100644 index 6d1e000..0000000 --- a/app/javascript/application.js +++ /dev/null @@ -1,9 +0,0 @@ -import 'jquery' -import 'jquery-ui' -import 'jquery-ujs' -import 'jquery-form' -import 'jquery-validation' -import '@activeadmin/activeadmin' - -import './custom/active_admin_custom' -import './custom/campaign-form' diff --git a/app/javascript/custom/campaign-form.js b/app/javascript/campaign-form.js similarity index 100% rename from app/javascript/custom/campaign-form.js rename to app/javascript/campaign-form.js diff --git a/app/javascript/packs/active_admin.js b/app/javascript/packs/active_admin.js new file mode 100644 index 0000000..d4c4a65 --- /dev/null +++ b/app/javascript/packs/active_admin.js @@ -0,0 +1,6 @@ +// Load Active Admin's styles into Webpacker, +// see `active_admin.scss` for customization. +import "../stylesheets/active_admin"; + +import "@activeadmin/activeadmin"; +require("active_admin_custom") diff --git a/app/javascript/packs/active_admin/print.scss b/app/javascript/packs/active_admin/print.scss new file mode 100644 index 0000000..79ac036 --- /dev/null +++ b/app/javascript/packs/active_admin/print.scss @@ -0,0 +1,2 @@ +/* Active Admin Print Stylesheet */ +@import "~@activeadmin/activeadmin/src/scss/print"; diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js new file mode 100644 index 0000000..6cfa414 --- /dev/null +++ b/app/javascript/packs/application.js @@ -0,0 +1,8 @@ +// This file is automatically compiled by Webpack, along with any other files +// present in this directory. You're encouraged to place your actual application logic in +// a relevant structure within app/javascript and only use these pack files to reference +// that code so it'll be compiled. + +import Rails from "@rails/ujs" + +Rails.start() diff --git a/app/javascript/packs/campaign.js b/app/javascript/packs/campaign.js new file mode 100644 index 0000000..a1c81d7 --- /dev/null +++ b/app/javascript/packs/campaign.js @@ -0,0 +1,4 @@ +require("jquery") +require("jquery-form") +require("jquery-validation") +require("campaign-form") diff --git a/app/javascript/stylesheets/active_admin.scss b/app/javascript/stylesheets/active_admin.scss new file mode 100644 index 0000000..d1c7b3b --- /dev/null +++ b/app/javascript/stylesheets/active_admin.scss @@ -0,0 +1,17 @@ +// SASS variable overrides must be declared before loading up Active Admin's styles. +// +// To view the variables that Active Admin provides, take a look at +// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the +// Active Admin source. +// +// For example, to change the sidebar width: +// $sidebar-width: 242px; + +// Active Admin's got SASS! +@import "~@activeadmin/activeadmin/src/scss/mixins"; +@import "~@activeadmin/activeadmin/src/scss/base"; + +// Overriding any non-variable SASS must be done after the fact. +// For example, to change the default status-tag color: +// +// .status_tag { background: #6090DB; } diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 08dc537..71fbba5 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class ApplicationRecord < ActiveRecord::Base - primary_abstract_class + self.abstract_class = true end diff --git a/app/views/admin/forms/_form.html.erb b/app/views/admin/forms/_form.html.erb index 60032e3..84517d9 100644 --- a/app/views/admin/forms/_form.html.erb +++ b/app/views/admin/forms/_form.html.erb @@ -33,4 +33,5 @@ Terms of Service apply. +<%= javascript_pack_tag 'campaign' %> <% if form.use_recaptcha %><% end %> diff --git a/app/views/login/new.html.erb b/app/views/login/new.html.erb index 772ff57..a21e4ff 100644 --- a/app/views/login/new.html.erb +++ b/app/views/login/new.html.erb @@ -1,6 +1,7 @@ + <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..12f98da --- /dev/null +++ b/babel.config.js @@ -0,0 +1,72 @@ +module.exports = function(api) { + var validEnv = ['development', 'test', 'production'] + var currentEnv = api.env() + var isDevelopmentEnv = api.env('development') + var isProductionEnv = api.env('production') + var isTestEnv = api.env('test') + + if (!validEnv.includes(currentEnv)) { + throw new Error( + 'Please specify a valid `NODE_ENV` or ' + + '`BABEL_ENV` environment variables. Valid values are "development", ' + + '"test", and "production". Instead, received: ' + + JSON.stringify(currentEnv) + + '.' + ) + } + + return { + presets: [ + isTestEnv && [ + '@babel/preset-env', + { + targets: { + node: 'current' + } + } + ], + (isProductionEnv || isDevelopmentEnv) && [ + '@babel/preset-env', + { + forceAllTransforms: true, + useBuiltIns: 'entry', + corejs: 3, + modules: false, + exclude: ['transform-typeof-symbol'] + } + ] + ].filter(Boolean), + plugins: [ + 'babel-plugin-macros', + '@babel/plugin-syntax-dynamic-import', + isTestEnv && 'babel-plugin-dynamic-import-node', + '@babel/plugin-transform-destructuring', + [ + '@babel/plugin-proposal-class-properties', + { + loose: true + } + ], + [ + '@babel/plugin-proposal-object-rest-spread', + { + useBuiltIns: true + } + ], + [ + '@babel/plugin-transform-runtime', + { + helpers: false, + regenerator: true, + corejs: false + } + ], + [ + '@babel/plugin-transform-regenerator', + { + async: false + } + ] + ].filter(Boolean) + } +} diff --git a/bin/importmap b/bin/importmap deleted file mode 100755 index 36502ab..0000000 --- a/bin/importmap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../config/application" -require "importmap/commands" diff --git a/bin/rails b/bin/rails index efc0377..21d3e02 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,5 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) +load File.expand_path("spring", __dir__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/bin/rake b/bin/rake index 4fbf10b..7327f47 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +load File.expand_path("spring", __dir__) require_relative "../config/boot" require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index ec47b79..90700ac 100755 --- a/bin/setup +++ b/bin/setup @@ -2,7 +2,7 @@ require "fileutils" # path to your application root. -APP_ROOT = File.expand_path("..", __dir__) +APP_ROOT = File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -13,21 +13,24 @@ FileUtils.chdir APP_ROOT do # 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 '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies + system! 'bin/yarn' # 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 ==" - system! "bin/rails db:prepare" + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system! "bin/rails restart" + system! 'bin/rails restart' end diff --git a/config/application.rb b/config/application.rb index 9a8c6ba..ef2b52a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,7 +5,7 @@ require "rails" # Pick the frameworks you want: require "active_model/railtie" -require "active_job/railtie" +# require 'active_job/railtie' require "active_record/railtie" require "action_controller/railtie" # require "action_mailer/railtie" @@ -22,7 +22,7 @@ module CampaignForms class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 6.1 # Configuration for the application, engines, and railties goes here. # diff --git a/config/environments/development.rb b/config/environments/development.rb index fb64abc..9557b17 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -14,12 +14,9 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing - config.server_timing = true - # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? + if Rails.root.join("tmp", "caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true @@ -46,11 +43,16 @@ config.active_support.disallowed_deprecation_warnings = [] # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load + # 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 = false + # Suppress logger output for asset requests. config.assets.quiet = true @@ -60,6 +62,10 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true diff --git a/config/environments/production.rb b/config/environments/production.rb index b43c6e9..916a31c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -31,19 +31,19 @@ config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" + # config.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + # config.action_dispatch.x_sendfile_header = 'X-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.*/ ] + # 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. if ENV["AWS_EXECUTION_ENV"].present? @@ -79,15 +79,21 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Don't log any deprecations. - config.active_support.report_deprecations = false + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] # Use default logging formatter so that PID and timestamp are not suppressed. # config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new($stdout) @@ -98,5 +104,26 @@ # 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 + config.action_controller.asset_host = ENV.fetch("SITE_URL") end diff --git a/config/environments/test.rb b/config/environments/test.rb index f443039..91b8f1e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,13 +8,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + config.cache_classes = false + config.action_view.cache_template_loading = true - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. - config.eager_load = ENV["CI"].present? + # 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 diff --git a/config/importmap.rb b/config/importmap.rb deleted file mode 100644 index bf3b4a7..0000000 --- a/config/importmap.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Pin npm packages by running ./bin/importmap - -# The entrypoint -pin "application", preload: true - -# ActiveAdmin and dependencies -pin "@activeadmin/activeadmin", to: "https://cdn.jsdelivr.net/npm/@activeadmin/activeadmin@2.13.1/app/assets/javascripts/active_admin/base.min.js" -pin "jquery", to: "https://ga.jspm.io/npm:jquery@3.7.0/dist/jquery.js" -pin "jquery-ui", to: "https://cdn.jsdelivr.net/npm/jquery-ui@1.13.2/dist/jquery-ui.min.js" -pin "jquery-ujs", to: "https://cdn.jsdelivr.net/npm/jquery-ujs@1.2.3/src/rails.min.js" -pin "jquery-validation", to: "https://ga.jspm.io/npm:jquery-validation@1.19.5/dist/jquery.validate.js" -pin "jquery-form", to: "https://ga.jspm.io/npm:jquery-form@4.3.0/dist/jquery.form.min.js" diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index 9788e66..171b962 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -294,23 +294,4 @@ # You can inherit it with own class and inject it for all resources # # config.order_clause = MyOrderClause - - # clear previous asset for javascript to make the asset pipeline - # happy - config.clear_javascripts! -end - -# https://medium.com/@henrikbjorn/til-using-activeadmin-with-importmap-rails-289cde6f76b8 -module ActiveAdmin - module Views - module Head - def build_active_admin_head - within super do - text_node javascript_importmap_tags("application") - end - end - end - end end - -ActiveAdmin::Views::Pages::Base.send :prepend, ActiveAdmin::Views::Head diff --git a/config/initializers/activeadmin_addons.rb b/config/initializers/activeadmin_addons.rb index 1fdef71..c332ffc 100644 --- a/config/initializers/activeadmin_addons.rb +++ b/config/initializers/activeadmin_addons.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + ActiveadminAddons.setup do |config| # Change to "default" if you want to use ActiveAdmin's default select control. config.default_select = "default" # Set default options for DateTimePickerInput. The options you can provide are the same as in - # xdan's datetimepicker library (https://github.com/xdan/datetimepicker/tree/2.5.4). You need to + # xdan's datetimepicker library (https://github.com/xdan/datetimepicker/tree/2.5.4). Yo need to # pass a ruby hash, avoid camelCase keys. For example: use min_date instead of minDate key. # config.datetime_picker_default_options = {} diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2eeef96..f8aa155 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,3 +1,5 @@ +# 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. @@ -5,8 +7,12 @@ # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join("node_modules") # 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 ) + +# Disable asset digests +Rails.application.config.assets.digest = true diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..33699c3 --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code +# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". +Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 54f47cf..35d0f26 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,25 +1,30 @@ # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy. -# See the Securing Rails Applications Guide for more information: -# https://guides.rubyonrails.org/security.html#content-security-policy-header +# 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.configure do -# config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # Generate session nonces for permitted importmap and inline scripts -# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) -# -# # Report violations without enforcing the policy. -# # config.content_security_policy_report_only = true +# 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 +# # If you are using webpack-dev-server then specify webpack-dev-server host +# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? + +# # 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/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 8a8653e..1cbe09b 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Avoid CORS issues when API is called from the frontend app. diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 26ef9f0..80b941c 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -3,10 +3,6 @@ # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| - # 4.9 changes - config.responder.error_status = :unprocessable_entity - config.responder.redirect_status = :see_other - # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. diff --git a/config/initializers/devise_sign_out_monkeypatch.rb b/config/initializers/devise_sign_out_monkeypatch.rb deleted file mode 100644 index 4c87267..0000000 --- a/config/initializers/devise_sign_out_monkeypatch.rb +++ /dev/null @@ -1,14 +0,0 @@ -# This monkey patch modifies the redirect to allow it to redirect to a different host on log out. - -Rails.application.config.to_prepare do - class Devise::SessionsController < DeviseController # rubocop:disable Lint/ConstantDefinitionInBlock - def respond_to_on_destroy - # We actually need to hardcode this as Rails default responder doesn't - # support returning empty response on GET request - respond_to do |format| - format.all { head :no_content } - format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status, allow_other_host: true } - end - end - end -end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index adc6568..856a2f2 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,6 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be filtered from the log file. Use this to limit dissemination of -# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported -# notations and behaviors. +# Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :password ] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 3860f65..ac033bf 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,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" +# inflect.acronym 'RESTful' # end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb new file mode 100644 index 0000000..9526b83 --- /dev/null +++ b/config/initializers/new_framework_defaults_6_1.rb @@ -0,0 +1,67 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 6.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Support for inversing belongs_to -> has_many Active Record associations. +# Rails.application.config.active_record.has_many_inversing = true + +# Track Active Storage variants in the database. +# Rails.application.config.active_storage.track_variants = true + +# Apply random variation to the delay when retrying failed jobs. +# Rails.application.config.active_job.retry_jitter = 0.15 + +# Stop executing `after_enqueue`/`after_perform` callbacks if +# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. +# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true + +# Specify cookies SameSite protection level: either :none, :lax, or :strict. +# +# This change is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.1. +# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax + +# Generate CSRF tokens that are encoded in URL-safe Base64. +# +# This change is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.1. +# Rails.application.config.action_controller.urlsafe_csrf_tokens = true + +# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an +# UTC offset or a UTC time. +# ActiveSupport.utc_to_local_returns_utc_offset_times = true + +# Change the default HTTP status code to `308` when redirecting non-GET/HEAD +# requests to HTTPS in `ActionDispatch::SSL` middleware. +# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 + +# Use new connection handling API. For most applications this won't have any +# effect. For applications using multiple databases, this new API provides +# support for granular connection swapping. +# Rails.application.config.active_record.legacy_connection_handling = false + +# Make `form_with` generate non-remote forms by default. +# Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Set the default queue name for the analysis job to the queue adapter default. +# Rails.application.config.active_storage.queues.analysis = nil + +# Set the default queue name for the purge job to the queue adapter default. +# Rails.application.config.active_storage.queues.purge = nil + +# Set the default queue name for the incineration job to the queue adapter default. +# Rails.application.config.action_mailbox.queues.incineration = nil + +# Set the default queue name for the routing job to the queue adapter default. +# Rails.application.config.action_mailbox.queues.routing = nil + +# Set the default queue name for the mail deliver job to the queue adapter default. +# Rails.application.config.action_mailer.deliver_later_queue_name = nil + +# Generate a `Link` header that gives a hint to modern browsers about +# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. +# Rails.application.config.action_view.preload_links_header = true diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb deleted file mode 100644 index b2fc168..0000000 --- a/config/initializers/new_framework_defaults_7_0.rb +++ /dev/null @@ -1,141 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -# `button_to` view helper will render `